diff mbox

[RFC] implement size_append in perl

Message ID 1279116063-4499-1-git-send-email-virtuoso@slind.org (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Shishkin July 14, 2010, 2:01 p.m. UTC
None
diff mbox

Patch

different shells and build environments and it remains a somewhat tricky
shell script. This patch replaces all the dependencies by a single line
of perl. Build dependency on perl is not new, so that shouldn't be a
problem.

The new implementation does exactly what it's supposed to: it outputs
a little-endian 32-bit unsigned integer of a file's length.

This might simplify matters with different build environments and
different shells and is also considerably shorter and hopefully more
readable.

Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Cc: Sebastian Dalfuß <sd@sedf.de>
Cc: Oliver Hartkopp <oliver@hartkopp.net>
Cc: Michael Guntsche <mike@it-loops.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>
Cc: Michael Tokarev <mjt@tls.msk.ru>
Cc: Alek Du <alek.du@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Albin Tonnerre <albin.tonnerre@free-electrons.com>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
 scripts/Makefile.lib |   16 +---------------
 1 files changed, 1 insertions(+), 15 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 54fd1b7..5bfd872 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -213,21 +213,7 @@  cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
 
 # Bzip2 and LZMA do not include size in file... so we have to fake that;
 # append the size as a 32-bit littleendian number as gzip does.
-size_append = printf $(shell						\
-dec_size=0;								\
-for F in $1; do								\
-	fsize=$$(stat -c "%s" $$F);					\
-	dec_size=$$(expr $$dec_size + $$fsize);				\
-done;									\
-printf "%08x\n" $$dec_size |						\
-	sed 's/\(..\)/\1 /g' | {					\
-		read ch0 ch1 ch2 ch3;					\
-		for ch in $$ch3 $$ch2 $$ch1 $$ch0; do			\
-			printf '%s%03o' '\\' $$((0x$$ch)); 		\
-		done;							\
-	}								\
-)
-
+size_append = $(PERL) -e 'print pack("V", (stat "$(lastword $1)")[7])'
 quiet_cmd_bzip2 = BZIP2   $@
 cmd_bzip2 = (cat $(filter-out FORCE,$^) | \
 	bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \