From 13aa76d23158b33a375f87479ffe6d0f577e5d2c Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Wed, 1 May 2013 12:30:06 +0200 Subject: digital/ucoolib/build: compute CRC32 when building a .bin --- digital/ucoolib/build/arch.mk | 8 ++++++-- digital/ucoolib/build/tools/crc | 13 +++++++++++++ digital/ucoolib/build/top.mk | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 digital/ucoolib/build/tools/crc (limited to 'digital/ucoolib') diff --git a/digital/ucoolib/build/arch.mk b/digital/ucoolib/build/arch.mk index 62f0687c..99f0c5f2 100644 --- a/digital/ucoolib/build/arch.mk +++ b/digital/ucoolib/build/arch.mk @@ -88,16 +88,17 @@ define arch_bin_rules hex: hex.$1 srec: srec.$1 bin: bin.$1 +crc: crc.$1 all.$1: hex.$1 ifneq ($$(wildcard *.$1.srec),) all.$1: srec.$1 endif ifneq ($$(wildcard *.$1.bin),) -all.$1: bin.$1 +all.$1: bin.$1 crc.$1 endif -.PHONY: hex.$1 srec.$1 bin.$1 +.PHONY: hex.$1 srec.$1 bin.$1 crc.$1 hex.$1: $$($1_PROGS:%=%.$1.hex) srec.$1: $$($1_PROGS:%=%.$1.srec) @@ -113,6 +114,9 @@ bin.$1: $$($1_PROGS:%=%.$1.bin) @echo "BIN [$1] $$@" $$Q$$($1_OBJCOPY) -O binary $$< $$@ +crc.$1: $$($1_PROGS:%=%.$1.bin) + $Q$$(BASE)/build/tools/crc $$^ + $1_EXTRA_CLEAN += $$($1_PROGS:%=%.$1.hex) \ $$($1_PROGS:%=%.$1.srec) \ $$($1_PROGS:%=%.$1.bin) diff --git a/digital/ucoolib/build/tools/crc b/digital/ucoolib/build/tools/crc new file mode 100755 index 00000000..cb85a7ff --- /dev/null +++ b/digital/ucoolib/build/tools/crc @@ -0,0 +1,13 @@ +#!/usr/bin/python +"""Output CRC32 of files.""" +import optparse +import zlib + +parser = optparse.OptionParser(usage='%prog [options] files...') +options, args = parser.parse_args() + +for f in args: + with open(f) as fd: + content = fd.read() + crc = zlib.crc32(content) & 0xffffffff + print '%08x %s' % (crc, f) diff --git a/digital/ucoolib/build/top.mk b/digital/ucoolib/build/top.mk index d4f53fe4..5d87aa65 100644 --- a/digital/ucoolib/build/top.mk +++ b/digital/ucoolib/build/top.mk @@ -33,11 +33,12 @@ size: hex: srec: bin: +crc: clean: rmdir $(OBJDIR) 2> /dev/null || true -.PHONY: all lst size hex srec bin clean +.PHONY: all lst size hex srec bin crc clean # Modules and sources setup. -- cgit v1.2.3