Commit 93458075 authored by David Griffith's avatar David Griffith 💬

Update build and Git hash reporting. Clean up dist target.

parent 248bf4f3
...@@ -2,3 +2,6 @@ ...@@ -2,3 +2,6 @@
minipro minipro
minipro-query-db minipro-query-db
version.h version.h
version.c
*.tar
*.gz
...@@ -13,12 +13,6 @@ PREFIX=/usr/local ...@@ -13,12 +13,6 @@ PREFIX=/usr/local
# Under normal circumstances, nothing below this point should be changed. # Under normal circumstances, nothing below this point should be changed.
########################################################################## ##########################################################################
# Versioning
VERSION_MAJOR = 0
VERSION_MINOR = 2
VERSION_SUFFIX = dev
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)-$(VERSION_SUFFIX)
# If we're working from git, we have access to proper variables. If # If we're working from git, we have access to proper variables. If
# not, make it clear that we're working from a release. # not, make it clear that we're working from a release.
GIT_DIR ?= .git GIT_DIR ?= .git
...@@ -34,14 +28,15 @@ else ...@@ -34,14 +28,15 @@ else
GIT_TAG = none GIT_TAG = none
endif endif
BUILD_DATE_TIME = $(shell date +%Y%m%d.%k%M%S | sed s/\ //g) BUILD_DATE_TIME = $(shell date +%Y%m%d.%k%M%S | sed s/\ //g)
VERSION_INFO = version.h VERSION_HEADER = version.h
VERSION_STRINGS = version.c
PKG_CONFIG := $(shell which pkg-config 2>/dev/null) PKG_CONFIG := $(shell which pkg-config 2>/dev/null)
ifeq ($(PKG_CONFIG),) ifeq ($(PKG_CONFIG),)
ERROR := $(error "pkg-config utility not found") ERROR := $(error "pkg-config utility not found")
endif endif
COMMON_OBJECTS=byte_utils.o database.o minipro.o fuses.o easyconfig.o COMMON_OBJECTS=byte_utils.o database.o minipro.o fuses.o easyconfig.o version.o
OBJECTS=$(COMMON_OBJECTS) main.o minipro-query-db.o OBJECTS=$(COMMON_OBJECTS) main.o minipro-query-db.o
PROGS=minipro minipro-query-db PROGS=minipro minipro-query-db
MINIPRO=minipro MINIPRO=minipro
...@@ -50,7 +45,7 @@ MINIPROHEX=miniprohex ...@@ -50,7 +45,7 @@ MINIPROHEX=miniprohex
TESTS=$(wildcard tests/test_*.c); TESTS=$(wildcard tests/test_*.c);
OBJCOPY=objcopy OBJCOPY=objcopy
DIST_DIR = $(MINIPRO)-$(VERSION) DIST_DIR = $(MINIPRO)-$(GIT_TAG)
BIN_INSTDIR=$(DESTDIR)$(PREFIX)/bin BIN_INSTDIR=$(DESTDIR)$(PREFIX)/bin
MAN_INSTDIR=$(DESTDIR)$(PREFIX)/share/man/man1 MAN_INSTDIR=$(DESTDIR)$(PREFIX)/share/man/man1
...@@ -63,33 +58,40 @@ override LIBS += $(libusb_LIBS) $(EXTRA_LIBS) ...@@ -63,33 +58,40 @@ override LIBS += $(libusb_LIBS) $(EXTRA_LIBS)
all: $(PROGS) all: $(PROGS)
version-info: $(VERSION_INFO) version_header: $(VERSION_HEADER)
$(VERSION_INFO): $(VERSION_HEADER):
@echo "Creating $@" @echo "Creating $@"
@echo "/*" > $@ @echo "/*" > $@
@echo " * This file is automatically generated. Do not edit." >> $@ @echo " * This file is automatically generated. Do not edit." >> $@
@echo " */" >> $@ @echo " */" >> $@
@echo "extern const char build_timestamp[];" >> $@
@echo "#define GIT_BRANCH \"$(GIT_BRANCH)\"" >> $@ @echo "#define GIT_BRANCH \"$(GIT_BRANCH)\"" >> $@
@echo "#define GIT_HASH \"$(GIT_HASH)\"" >> $@ @echo "#define GIT_HASH \"$(GIT_HASH)\"" >> $@
@echo "#define GIT_HASH_SHORT \"$(GIT_HASH_SHORT)\"" >> $@ @echo "#define GIT_HASH_SHORT \"$(GIT_HASH_SHORT)\"" >> $@
@echo "#define GIT_TAG \"$(GIT_TAG)\"" >> $@ @echo "#define GIT_TAG \"$(GIT_TAG)\"" >> $@
@echo "#define VERSION \"$(VERSION)\"" >> $@
@echo "#define VERSION_MAJOR \"$(VERSION_MAJOR)\"" >> $@
@echo "#define VERSION_MINOR \"$(VERSION_MINOR)\"" >> $@
@echo "#define VERSION_SUFFIX \"$(VERSION_SUFFIX)\"" >> $@
minipro: version-info $(COMMON_OBJECTS) main.o version_strings: $(VERSION_STRINGS)
$(VERSION_STRINGS):
@echo "Creating $@"
@echo "/*" > $@
@echo " * This file is automatically generated. Do not edit." >> $@
@echo " */" >> $@
@echo "#include \"minipro.h\"" >> $@
@echo "#include \"version.h\"" >> $@
@echo "const char build_timestamp[] = \"$(BUILD_DATE_TIME)\";" >> $@
minipro: $(VERSION_HEADER) $(VERSION_STRINGS) $(COMMON_OBJECTS) main.o
$(CC) $(COMMON_OBJECTS) main.o $(LIBS) -o $(MINIPRO) $(CC) $(COMMON_OBJECTS) main.o $(LIBS) -o $(MINIPRO)
minipro-query-db: version-info $(COMMON_OBJECTS) minipro-query-db.o minipro-query-db: $(VERSION_HEADER) $(VERSION_STRINGS) $(COMMON_OBJECTS) minipro-query-db.o
$(CC) $(COMMON_OBJECTS) minipro-query-db.o $(LIBS) -o $(MINIPRO_QUERY_DB) $(CC) $(COMMON_OBJECTS) minipro-query-db.o $(LIBS) -o $(MINIPRO_QUERY_DB)
clean: clean:
rm -f $(OBJECTS) $(PROGS) rm -f $(OBJECTS) $(PROGS)
rm -f version.h rm -f version.h version.c version.o
distclean: clean distclean: clean
rm -rf minipro-$(VERSION)* rm -rf minipro-$(GIT_TAG)*
install: install:
mkdir -p $(BIN_INSTDIR) mkdir -p $(BIN_INSTDIR)
...@@ -106,19 +108,14 @@ uninstall: ...@@ -106,19 +108,14 @@ uninstall:
rm -f $(MAN_INSTDIR)/minipro.1 rm -f $(MAN_INSTDIR)/minipro.1
dist: distclean version-info dist: distclean version-info
git archive --format=tar --prefix=minipro-$(VERSION)/ -o "minipro-$(VERSION).tar" HEAD git archive --format=tar --prefix=minipro-$(GIT_TAG)/ HEAD | tar xf -
tar -xf minipro-$(VERSION).tar sed -i "s/GIT_BRANCH = none/GIT_BRANCH = $(GIT_BRANCH)/" minipro-$(GIT_TAG)/Makefile
sed -i '/rm -f version.h/s/^/#/g' minipro-$(VERSION)/Makefile sed -i "s/GIT_HASH = none/GIT_HASH = $(GIT_HASH)/" minipro-$(GIT_TAG)/Makefile
sed -i "s/GIT_BRANCH = none/GIT_BRANCH = $(GIT_BRANCH)/" minipro-$(VERSION)/Makefile sed -i "s/GIT_HASH_SHORT = none/GIT_HASH_SHORT = $(GIT_HASH_SHORT)/" minipro-$(GIT_TAG)/Makefile
sed -i "s/GIT_HASH = none/GIT_HASH = $(GIT_HASH)/" minipro-$(VERSION)/Makefile sed -i "s/GIT_TAG = none/GIT_TAG = $(GIT_TAG)/" minipro-$(GIT_TAG)/Makefile
sed -i "s/GIT_HASH_SHORT = none/GIT_HASH_SHORT = $(GIT_HASH_SHORT)/" minipro-$(VERSION)/Makefile tar zcf minipro-$(GIT_TAG).tar.gz minipro-$(GIT_TAG)
sed -i "s/GIT_TAG = none/GIT_TAG = $(GIT_TAG)/" minipro-$(VERSION)/Makefile rm -rf minipro-$(GIT_TAG)
@echo Created minipro-$(GIT_TAG).tar.gz
cp -f $(VERSION_INFO) minipro-$(VERSION)
tar zcf minipro-$(VERSION).tar.gz minipro-$(VERSION)
rm -rf minipro-$(VERSION)
rm -f minipro-$(VERSION).tar
@echo Created minipro-$(VERSION).tar.gz
.PHONY: all dist distclean clean install test version-info .PHONY: all dist distclean clean install test version-info
...@@ -50,11 +50,11 @@ struct { ...@@ -50,11 +50,11 @@ struct {
void print_version_and_exit(int rv) { void print_version_and_exit(int rv) {
char output[] = char output[] =
"minipro version %s A free and open TL866XX programmer\n" "minipro version %s A free and open TL866XX programmer\n"
// "Build:\t\t%s\n" "Build:\t\t%s\n"
"Git commit:\t%s\n" "Git commit:\t%s\n"
"Git tag:\t%s\n" "Git tag:\t%s\n"
"Git branch:\t%s\n"; "Git branch:\t%s\n";
fprintf(rv ? stderr : stdout, output, VERSION, GIT_HASH, GIT_TAG, GIT_BRANCH); fprintf(rv ? stderr : stdout, output, GIT_TAG, build_timestamp, GIT_HASH, GIT_TAG, GIT_BRANCH);
exit(rv); exit(rv);
} }
...@@ -82,7 +82,7 @@ void print_help_and_exit(char *progname, int rv) { ...@@ -82,7 +82,7 @@ void print_help_and_exit(char *progname, int rv) {
" -y Do NOT error on ID mismatch\n" " -y Do NOT error on ID mismatch\n"
" -V Show version information\n" " -V Show version information\n"
" -h Show help (this text)\n"; " -h Show help (this text)\n";
fprintf(rv ? stderr : stdout, usage, VERSION, basename(progname)); fprintf(rv ? stderr : stdout, usage, GIT_TAG, basename(progname));
exit(rv); exit(rv);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment