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 @@
minipro
minipro-query-db
version.h
version.c
*.tar
*.gz
......@@ -13,12 +13,6 @@ PREFIX=/usr/local
# 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
# not, make it clear that we're working from a release.
GIT_DIR ?= .git
......@@ -34,14 +28,15 @@ else
GIT_TAG = none
endif
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)
ifeq ($(PKG_CONFIG),)
ERROR := $(error "pkg-config utility not found")
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
PROGS=minipro minipro-query-db
MINIPRO=minipro
......@@ -50,7 +45,7 @@ MINIPROHEX=miniprohex
TESTS=$(wildcard tests/test_*.c);
OBJCOPY=objcopy
DIST_DIR = $(MINIPRO)-$(VERSION)
DIST_DIR = $(MINIPRO)-$(GIT_TAG)
BIN_INSTDIR=$(DESTDIR)$(PREFIX)/bin
MAN_INSTDIR=$(DESTDIR)$(PREFIX)/share/man/man1
......@@ -63,33 +58,40 @@ override LIBS += $(libusb_LIBS) $(EXTRA_LIBS)
all: $(PROGS)
version-info: $(VERSION_INFO)
$(VERSION_INFO):
version_header: $(VERSION_HEADER)
$(VERSION_HEADER):
@echo "Creating $@"
@echo "/*" > $@
@echo " * This file is automatically generated. Do not edit." >> $@
@echo " */" >> $@
@echo "extern const char build_timestamp[];" >> $@
@echo "#define GIT_BRANCH \"$(GIT_BRANCH)\"" >> $@
@echo "#define GIT_HASH \"$(GIT_HASH)\"" >> $@
@echo "#define GIT_HASH_SHORT \"$(GIT_HASH_SHORT)\"" >> $@
@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)
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)
clean:
rm -f $(OBJECTS) $(PROGS)
rm -f version.h
rm -f version.h version.c version.o
distclean: clean
rm -rf minipro-$(VERSION)*
rm -rf minipro-$(GIT_TAG)*
install:
mkdir -p $(BIN_INSTDIR)
......@@ -106,19 +108,14 @@ uninstall:
rm -f $(MAN_INSTDIR)/minipro.1
dist: distclean version-info
git archive --format=tar --prefix=minipro-$(VERSION)/ -o "minipro-$(VERSION).tar" HEAD
tar -xf minipro-$(VERSION).tar
sed -i '/rm -f version.h/s/^/#/g' minipro-$(VERSION)/Makefile
sed -i "s/GIT_BRANCH = none/GIT_BRANCH = $(GIT_BRANCH)/" minipro-$(VERSION)/Makefile
sed -i "s/GIT_HASH = none/GIT_HASH = $(GIT_HASH)/" minipro-$(VERSION)/Makefile
sed -i "s/GIT_HASH_SHORT = none/GIT_HASH_SHORT = $(GIT_HASH_SHORT)/" minipro-$(VERSION)/Makefile
sed -i "s/GIT_TAG = none/GIT_TAG = $(GIT_TAG)/" minipro-$(VERSION)/Makefile
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
git archive --format=tar --prefix=minipro-$(GIT_TAG)/ HEAD | tar xf -
sed -i "s/GIT_BRANCH = none/GIT_BRANCH = $(GIT_BRANCH)/" minipro-$(GIT_TAG)/Makefile
sed -i "s/GIT_HASH = none/GIT_HASH = $(GIT_HASH)/" minipro-$(GIT_TAG)/Makefile
sed -i "s/GIT_HASH_SHORT = none/GIT_HASH_SHORT = $(GIT_HASH_SHORT)/" minipro-$(GIT_TAG)/Makefile
sed -i "s/GIT_TAG = none/GIT_TAG = $(GIT_TAG)/" minipro-$(GIT_TAG)/Makefile
tar zcf minipro-$(GIT_TAG).tar.gz minipro-$(GIT_TAG)
rm -rf minipro-$(GIT_TAG)
@echo Created minipro-$(GIT_TAG).tar.gz
.PHONY: all dist distclean clean install test version-info
......@@ -50,11 +50,11 @@ struct {
void print_version_and_exit(int rv) {
char output[] =
"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 tag:\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);
}
......@@ -82,7 +82,7 @@ void print_help_and_exit(char *progname, int rv) {
" -y Do NOT error on ID mismatch\n"
" -V Show version information\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);
}
......
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