First stab at using export-subst in .gitattributes.
authorDavid Griffith <dave@661.org>
Tue, 12 Feb 2019 08:49:29 +0000 (00:49 -0800)
committerDavid Griffith <dave@661.org>
Tue, 12 Feb 2019 08:49:29 +0000 (00:49 -0800)
.gitignore
Makefile
src/common/git_hash.h [new file with mode: 0644]

index 77bf838e9384a18e42eebd71ee505eac21fa318b..57b2b4ddb9c6547fe9217308f772e99f197bc8f9 100644 (file)
@@ -16,7 +16,7 @@ frotz-*
 *.tar
 *.gz
 src/common/version.c
-src/common/git_hash.h
+#src/common/git_hash.h
 src/common/defs.h
 src/curses/ux_defines.h
 *.z?
index 172331aab6f48135a4669806bac9ee1f17916fed..0a5b777a3c6c00908eb2fd94978122a29751e180 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -121,13 +121,9 @@ ifneq ($(and $(wildcard $(GIT_DIR)),$(shell which git)),)
        GIT_HASH = $(shell git rev-parse HEAD)
        GIT_HASH_SHORT = $(shell git rev-parse --short HEAD)
        GIT_TAG = $(shell git describe --abbrev=0 --tags)
-else
-       GIT_BRANCH = none
-       GIT_HASH = none
-       GIT_HASH_SHORT = none
-       GIT_TAG = none
+       GIT_DATE = $(shell git show -s --format=%ci)
 endif
-BUILD_DATE_TIME = $(shell date +%Y%m%d.%k%M%S | sed s/\ //g)
+BUILD_DATE_TIME = $(shell date --rfc-3339 seconds)
 export CFLAGS
 
 
@@ -268,17 +264,23 @@ endif
 ifdef COLOR
        @echo "#define COLOR_SUPPORT" >> $@
 endif
-
        @echo "#endif /* CURSES_DEFINES_H */" >> $@
 
 
 hash: $(HASH)
-$(HASH):
+ifneq ($(and $(wildcard $(GIT_DIR)),$(shell which git)),)
+       @echo "** Generating $@"
+       
+
+
+
+$(HASH_OLD):
        @echo "** Generating $@"
        @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 GIT_DATE \"$(GIT_DATE)\"" >> $@
 
 
 # Administrative stuff
@@ -336,7 +338,7 @@ clean: $(SUB_CLEAN)
                $(SRCDIR)/*.a \
                $(COMMON_DEFINES) \
                $(COMMON_STRINGS) \
-               $(HASH) \
+#              $(HASH) \
                $(CURSES_DEFINES) \
                $(NAME)*.tar.gz
 
diff --git a/src/common/git_hash.h b/src/common/git_hash.h
new file mode 100644 (file)
index 0000000..1fe2b90
--- /dev/null
@@ -0,0 +1,5 @@
+#define GIT_BRANCH "$Format: %D$"
+#define GIT_TAG "$Format: %D$"
+#define GIT_HASH "$Format: %H$"
+#define GIT_HASH_SHORT "$Format: $h$"
+#define GIT_DATE "$Format: $ci$"