diff --git a/.gitignore b/.gitignore index c9416bb..1db11da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ -sunxi-fexc bin2fex fex2bin sunxi-bootinfo sunxi-fel -sunxi-pio +sunxi-fexc sunxi-nand-part +sunxi-pio +version.h *.o *.swp diff --git a/Makefile b/Makefile index 4f8ee35..975bf67 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ all: tools target-tools tools: $(TOOLS) $(FEXC_LINKS) target-tools: $(TARGET_TOOLS) -misc: $(MISC_TOOLS) +misc: version.h $(MISC_TOOLS) binfiles: $(BINFILES) @@ -85,9 +85,9 @@ install-target-tools: $(TARGET_TOOLS) clean: @rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS) - @rm -vf *.o *.elf *.sunxi *.bin *.nm *.orig + @rm -vf version.h *.o *.elf *.sunxi *.bin *.nm *.orig -$(TOOLS) $(TARGET_TOOLS): Makefile common.h +$(TOOLS) $(TARGET_TOOLS): Makefile common.h version.h fex2bin bin2fex: sunxi-fexc ln -nsf $< $@ @@ -158,7 +158,10 @@ sunxi-meminfo: meminfo.c sunxi-script_extractor: script_extractor.c $(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^ +version.h: + @./autoversion.sh > $@ + .gitignore: Makefile - @for x in $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) '*.o' '*.swp'; do \ + @for x in $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) version.h '*.o' '*.swp'; do \ echo "$$x"; \ - done > $@ + done | sort -V > $@ diff --git a/autoversion.sh b/autoversion.sh new file mode 100755 index 0000000..35f548b --- /dev/null +++ b/autoversion.sh @@ -0,0 +1,18 @@ +# +# This script auto-updates a VERSION string definition. +# It outputs informational messages to stderr, while the actual +# output (on stdout) can easily be redirected to a file. +# + +LATEST_RELEASE="v1.3" + +if VER=`git describe --tags --dirty --always`; then + echo "Setting version information: ${VER}" >&2 +else + VER=${LATEST_RELEASE} + echo "Unable to determine current version (using \"${VER}\" as fallback)" >&2 +fi +echo >&2 + +echo "/* Auto-generated information. DO NOT EDIT */" +echo "#define VERSION \"${VER}\"" diff --git a/common.h b/common.h index 66ca22e..488d1d4 100644 --- a/common.h +++ b/common.h @@ -19,6 +19,8 @@ #include /* offsetof */ +#include "version.h" /* auto-generated VERSION string */ + /** flag function argument as unused */ #ifdef UNUSED #elif defined(__GNUC__)