From ddb830911e10d0e1596da4977503b8067e4e8012 Mon Sep 17 00:00:00 2001 From: PatR <rankin@nethack.org> Date: Sat, 10 Mar 2018 12:32:52 -0800 Subject: [PATCH] more Unix gitinfo When make uses 'makedefs -v' to create date.h, force it to create gitinfo.txt all the time instead of just when that doesn't already exist. Use 'make GITINFO=0' to get the previous behavior. To skip it entirely, you need to do that and also make sure that some file by that name already exists. 'touch dat/gitinfo.txt' or perhaps 'echo "#no git" > dat/gitinfo.txt' would suffice. --- sys/unix/Makefile.src | 10 +++++++++- sys/unix/gitinfo.sh | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index f6b9371bc..56fef8b86 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -332,6 +332,14 @@ RANDOBJ = # used by `make depend' to reconstruct this Makefile; you shouldn't need this AWK = nawk +# when using 'makedefs -v', also force dat/gitinfo.txt to be up to date; +# changing this to 0 will change the behavior to only make that file if +# it doesn't already exist; to skip it completely, create an empty file +# of that name and also set this to 0; there shouldn't be any need to +# skip it--if nethack's sources don't reside in a git repository than +# the script which creates that file will fail benignly and 'makedefs -v' +# will proceed without it +GITINFO=1 #VERBOSEMAKE = 1 @@ -612,7 +620,7 @@ tile.c: ../win/share/tilemap.c $(HACK_H) # hack.h depends on makedefs' output, so we know makedefs will be # up to date before being executed ../include/date.h: $(VERSOURCES) $(HACK_H) - -$(SHELL) ../sys/unix/gitinfo.sh #../dat/gitinfo.txt for 'makedefs -v' + -$(SHELL) ../sys/unix/gitinfo.sh $(GITINFO) #before 'makedefs -v' ../util/makedefs -v diff --git a/sys/unix/gitinfo.sh b/sys/unix/gitinfo.sh index 72d300454..5cdb34715 100755 --- a/sys/unix/gitinfo.sh +++ b/sys/unix/gitinfo.sh @@ -1,7 +1,7 @@ #!/bin/sh # NetHack 3.6 gitinfo.sh $NHDT-Date: 1520201830 2018/03/04 22:17:10 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.0 $ -# if dat/gitinfo.txt doesn't exist, try to make one; called from Makefile.src +# bring dat/gitinfo.txt up to date; called from Makefile.src # # gitinfo.txt is used during development to augment the version number @@ -10,13 +10,16 @@ # this script to be skipped or to run but fail to generate dat/gitinfo.txt. # +always=0 +if [[ $1 -eq 1 || $1 == "force" || $1 == "always" ]]; then always=1; fi + # try to figure out where we are: top, one level down (expected), or sys/unix prefix=. if [ -f ../sys/unix/gitinfo.sh ]; then prefix=..; fi if [ -f ../../sys/unix/gitinfo.sh ]; then prefix=../..; fi # try to run a perl script which is part of nethack's git repository -if [[ ! -f $prefix/dat/gitinfo.txt ]]; then +if [[ $always -eq 1 || ! -f $prefix/dat/gitinfo.txt ]]; then ( cd $prefix; \ perl -IDEVEL/hooksdir -MNHgithook -e '&NHgithook::nhversioning' \ 2> /dev/null ) \ -- 2.40.0