]> granicus.if.org Git - nethack/commitdiff
adjust Makefile.mingw32 for 3.7 date and time stamping
authornhmall <nhmall@nethack.org>
Sun, 6 Feb 2022 02:34:55 +0000 (21:34 -0500)
committernhmall <nhmall@nethack.org>
Sun, 6 Feb 2022 02:34:55 +0000 (21:34 -0500)
NetHack 3.7 stores timestamp information, as well as github
commit hashs information if available, internally by compiling
date.c. It is important to ensure that date.c is always
recompiled after any other NetHack source files are compiled.

sys/windows/Makefile.mingw32
sys/windows/Makefile.msc

index e8be0ca68d7db4d84ca7e81989c6f8cf9b5c146e..3ca2ae6cd7e0b473d1ed23c4afa4a5bc006708f6 100644 (file)
@@ -1,5 +1,6 @@
 # NetHack 3.7  Makefile.mingw32
-# Copyright (c) 2022 by Michael Allison
+# Copyright (c) 2022 by Feiyun Wang
+#-Copyright (c) 2022 by Michael Allison
 # NetHack may be freely redistributed.  See license for details.
 #
 #==============================================================================
@@ -707,7 +708,7 @@ endif  # INTERNET_AVAILABLE
 # nethackw
 #==========================================
 COREOBJS = $(addsuffix .o, allmain alloc apply artifact attrib ball bones botl cmd cppregex \
-          date dbridge decl detect dig display dlb do do_name do_wear \
+          dbridge decl detect dig display dlb do do_name do_wear \
           dog dogmove dokick dothrow drawing dungeon \
           eat end engrave exper explode extralev files fountain \
           hack hacklib insight invent isaac64 light lock \
@@ -726,6 +727,7 @@ ONHW = $(O)nethackw
 NHWONLY = $(addsuffix .o, mhaskyn mhdlg mhfont mhinput mhmain mhmap mhmenu \
          mhmsgwnd mhrip mhsplash mhstatus mhtext mswproc tile NetHackW win10)
 NHWOBJS = $(addprefix $(ONHW)/, $(COREOBJS) $(NHWONLY))
+DATEW_O  = $(addsuffix .o, $(addprefix $(ONHW)/, date))
 TILEFILES = $(addprefix $(WSHR)/, monsters.txt objects.txt other.txt)
 BMPS = $(addprefix $(MSWIN)/, $(addsuffix .bmp, mnsel mnselcnt mnunsel petmark pilemark rip splash tiles))
 NHWRES = $(ONHW)/winres.o
@@ -733,12 +735,23 @@ NHWTARGETS = $(GAMEDIR)/NetHackW.exe
 
 nethackw: $(NHWTARGETS)
 
-$(GAMEDIR)/NetHackW.exe: $(NHWOBJS) $(NHWRES) $(LUALIB) | $(GAMEDIR)
+$(GAMEDIR)/NetHackW.exe: $(NHWOBJS) $(DATEW_O) $(NHWRES) $(LUALIB) | $(GAMEDIR)
        $(ld) $(LDFLAGS) -mwindows $^ $(LIBS) -static -lstdc++ -o$@
 
 $(ONHW)/%.o: $(SRC)/%.c $(NHLUAH) | $(ONHW)
        $(cc) $(CFLAGSW) $< -o$@
 
+#       In NetHack 3.7, date.c must be recompiled after any other file is compiled,
+#       otherwise the game internal build timestamp (and potentially git hash)
+#       will not be accurate.
+#       Therefore, date must not be included in COREOBJS (and by extension
+#       NHWOBJS, NHWONLY). That allows those to be listed as explicit dependencies
+#       to ensure that date.c is always recompiled again after anything else that
+#       was just recompiled. date.h is not used in the build of NetHack 3.7.
+#
+$(ONHW)/date.o: $(SRC)/date.c $(NHWOBJS)
+       $(cc) $(CFLAGSW) $(GITHASH) $(GITBRANCH) $< -o$@
+
 $(ONHW)/cppregex.o: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONHW)
        $(cc) $(CFLAGSW) $< -o$@
 
@@ -785,6 +798,7 @@ ifeq "$(ADD_CURSES)" "Y"
 CFLAGSNH += -DCURSES_GRAPHICS -DCHTYPE_32 -DPDC_NCMOUSE
 NHONLY += $(addsuffix .o, cursdial cursinit cursinvt cursmain cursmesg cursmisc cursstat curswins)
 endif
+DATE_O  = $(addsuffix .o, $(addprefix $(ONH)/, date))
 
 NHOBJS = $(addprefix $(ONH)/, $(COREOBJS) $(NHONLY))
 NHRES = $(ONH)/conres.o
@@ -792,12 +806,23 @@ NHTARGET = $(GAMEDIR)/NetHack.exe
 
 nethack: $(NHTARGET)
 
-$(GAMEDIR)/NetHack.exe: $(NHOBJS) $(NHRES) $(LUALIB) $(PDCLIB) | $(GAMEDIR)
+$(GAMEDIR)/NetHack.exe: $(NHOBJS) $(DATE_O) $(NHRES) $(LUALIB) $(PDCLIB) | $(GAMEDIR)
        $(ld) $(LDFLAGS) -mconsole $^ $(LIBS) -static -lstdc++ -o$@
 
 $(ONH)/%.o: $(SRC)/%.c $(NHLUAH) | $(ONH)
        $(cc) $(CFLAGSNH) $< -o$@
 
+#       In NetHack 3.7, date.c must be recompiled after any other file is compiled,
+#       otherwise the game internal build timestamp (and potentially git hash)
+#       will not be accurate.
+#       Therefore, date must not be included in COREOBJS (and by extension
+#       NHOBJS). That allows those to be listed as explicit dependencies of date.o
+#       to ensure that date.c is always recompiled again after anything else that
+#       was just recompiled. date.h is not used in the build of NetHack 3.7.
+#
+$(ONH)/date.o: $(SRC)/date.c $(NHOBJS) $(NHRES)
+       $(cc) $(CFLAGSNH) $(GITHASH) $(GITBRANCH) $< -o$@
+
 $(ONH)/cppregex.o: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONH)
        $(cc) $(CFLAGSNH) $< -o$@
 
index aa8af921b596b957460897646415caa759658057..8aeb51f462d9d56748d64f9bbc753f2cd86b97ff 100644 (file)
@@ -1184,9 +1184,9 @@ $(O)date.o: $(HACKINCL) $(HACKSRC) $(HACKOBJ) $(ALLOBJ)
 !ENDIF
 
 #
-#  date.h should be remade every time any of the source or include
-#  files is modified.
-#
+#  date.h is not used with NetHack 3.7
+#  onames.h is not used with NetHack 3.7
+#  pm.h is not used with NetHack 3.7
 
 $(INCL)\date.h $(OPTIONS_FILE) : $(U)makedefs.exe
        $(U)makedefs -v