From 4a08f200906409efc66a8397db87519f190bba26 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 20 Nov 2023 22:14:22 -0500 Subject: [PATCH] do the Makefile checking using make itself --- sys/unix/Makefile.check | 30 ++++++++++++++ sys/unix/Makefile.top | 6 +-- sys/unix/hints/include/general-pre.370 | 57 -------------------------- sys/unix/hints/linux.370 | 7 +++- sys/unix/hints/macOS.370 | 10 ++++- 5 files changed, 46 insertions(+), 64 deletions(-) create mode 100755 sys/unix/Makefile.check delete mode 100755 sys/unix/hints/include/general-pre.370 diff --git a/sys/unix/Makefile.check b/sys/unix/Makefile.check new file mode 100755 index 000000000..c3e933a0f --- /dev/null +++ b/sys/unix/Makefile.check @@ -0,0 +1,30 @@ +# NetHack 3.7 Makefile.check $NHDT-Date: 1599687610 2020/09/09 21:40:10 $ $NHDT-Branch: NetHack-3.7 + +mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +mkfile_dir := $(dir $(mkfile_path)) +SUPATH := sys/unix/ +MKINCLVERS := 370 +MKINCLPATH := $(SUPATH)hints/include/ +MKINCLNAMES := compiler cross-pre cross-post \ + gbdates-pre gbdates-post \ + multiw-1 multiw-2 multiw-3 \ + multisnd1-pre multisnd2-pre multisnd-post +MKINCLFILES := $(addprefix $(MKINCLPATH), $(addsuffix .$(MKINCLVERS), $(MKINCLNAMES))) + +allmakefiles: dat/Makefile src/Makefile util/Makefile doc/Makefile Makefile + +dat/Makefile: $(SUPATH)Makefile.dat $(MKINCLFILES) + @echo Attention: $@ is older than: $? + +src/Makefile: $(SUPATH)Makefile.src $(MKINCLFILES) + @echo Attention: $@ is older than: $? + +util/Makefile: $(SUPATH)Makefile.utl $(MKINCLFILES) + @echo Attention: $@ is older than: $? + +doc/Makefile: $(SUPATH)Makefile.doc $(MKINCLFILES) + @echo Attention: $@ is older than: $? + +Makefile: $(SUPATH)Makefile.top $(MKINCLFILES) + @echo Attention: $@ is older than: $? + diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index c2e52e250..3b9dd0956 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -112,7 +112,7 @@ LUA2NHTOP = ../../.. LUABASELIB = liblua-$(LUA_VERSION).a TOPLUALIB = lib/lua/$(LUABASELIB) -ALLDEP = $(GAME) recover Guidebook $(VARDAT) spec_levs check-dlb check-nhlua +ALLDEP = $(PRECHECK) $(GAME) recover Guidebook $(VARDAT) spec_levs check-dlb check-nhlua # first target is also the default target for 'make' without any arguments all: $(ALLDEP) @@ -338,7 +338,7 @@ fetch-lua-http: # 'make update' can be used to install a revised version after making # customizations or such. Unlike 'make install', it doesn't delete everything # from the target directory to have a clean start. -update: $(GAME) recover $(VARDAT) spec_levs +update: $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs # (don't yank the old version out from under people who're playing it) -mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old -mv $(INSTDIR)/nhdat $(INSTDIR)/nhdat.old @@ -352,7 +352,7 @@ update: $(GAME) recover $(VARDAT) spec_levs rootcheck: @true; $(ROOTCHECK) -install: rootcheck $(GAME) recover $(VARDAT) spec_levs +install: rootcheck $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs true; $(PREINSTALL) # set up the directories # not all mkdirs have -p; those that don't will create a -p directory diff --git a/sys/unix/hints/include/general-pre.370 b/sys/unix/hints/include/general-pre.370 deleted file mode 100755 index 4b6723470..000000000 --- a/sys/unix/hints/include/general-pre.370 +++ /dev/null @@ -1,57 +0,0 @@ -# NetHack 3.7 general-pre.370 $NHDT-Date: 1599687610 2020/09/09 21:40:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.11 $ - -ifdef MAKEFILE_TOP -mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) -mkfile_dir := $(dir $(mkfile_path)) -SUPATH :=$(mkfile_dir)sys/unix/ -#$(info $(.VARIABLES)) -ifeq ($(MAKELEVEL),0) -notified=No -touchquiet= -# Check the placed Makefiles against the time stamp -# of their source in sys/unix, and report if appropriate. -MFCHECKDAT := $(shell [ $(SUPATH)Makefile.dat -nt $(mkfile_dir)dat/Makefile ] \ - && echo "outdated") -MFCHECKSRC := $(shell [ $(SUPATH)Makefile.src -nt $(mkfile_dir)src/Makefile ] \ - && echo "outdated") -MFCHECKUTL := $(shell [ $(SUPATH)Makefile.utl -nt $(mkfile_dir)util/Makefile ] \ - && echo "outdated") -MFCHECKDOC := $(shell [ $(SUPATH)Makefile.doc -nt $(mkfile_dir)doc/Makefile ] \ - && echo "outdated") -MFCHECKTOP := $(shell [ $(SUPATH)Makefile.top -nt $(mkfile_dir)Makefile ] \ - && echo "outdated") -ifeq ($(MFCHECKDAT),outdated) -$(info Attention: ../sys/unix/Makefile.dat is newer than dat/Makefile) -notified=Yes -touchquiet += dat/Makefile -endif -ifeq ($(MFCHECKSRC),outdated) -$(info Attention: ../sys/unix/Makefile.src is newer than src/Makefile) -notified=Yes -touchquiet += src/Makefile -endif -ifeq ($(MFCHECKUTL),outdated) -$(info Attention: ../sys/unix/Makefile.utl is newer than util/Makefile) -notified=Yes -touchquiet += util/Makefile -endif -ifeq ($(MFCHECKDOC),outdated) -$(info Attention: ../sys/unix/Makefile.doc is newer than doc/Makefile) -notified=Yes -touchquiet += doc/Makefile -endif -ifeq ($(MFCHECKTOP),outdated) -$(info Attention: ../sys/unix/Makefile.top is newer than Makefile) -notified=Yes -touchquiet += Makefile -endif -ifeq ("$(notified)","Yes") -$(info You should consider re-executing sys/unix/setup.sh) -ifneq ("$(touchquiet)","") -$(info or to quiet this message: 'touch $(touchquiet)') -endif -$(info ) -endif # notified -endif # MAKELEVEL = 0 -endif # MAKEFILE_TOP -# --- end of general-post.370 diff --git a/sys/unix/hints/linux.370 b/sys/unix/hints/linux.370 index 580f5aad3..537cd66da 100755 --- a/sys/unix/hints/linux.370 +++ b/sys/unix/hints/linux.370 @@ -17,11 +17,10 @@ # as Ubuntu focal). # note: '#-INCLUDE' is not just a comment -# -#-INCLUDE general-pre.370 # multiw-1.370 contains sections 1 to 2 #-INCLUDE multiw-1.370 +PRECHECK+=checkmakefiles ifndef LIBXPM LIBXPM= -L/opt/X11/lib -lXpm @@ -360,6 +359,10 @@ GAMEPERM = 0755 #-INCLUDE multisnd-post.370 # +.PHONY: checkmakefiles +checkmakefiles: + ( $(MAKE) -f sys/unix/Makefile.check ) + ifdef WANT_LIBNH $(TARGETPFX)libnh.a: $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a $(AR) rcs $@ $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a diff --git a/sys/unix/hints/macOS.370 b/sys/unix/hints/macOS.370 index 0e4aacdb3..c2701658f 100755 --- a/sys/unix/hints/macOS.370 +++ b/sys/unix/hints/macOS.370 @@ -18,10 +18,11 @@ # # note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 2 -#-INCLUDE general-pre.370 -# #-INCLUDE multiw-1.370 + +PRECHECK+=checkmakefiles + ifneq "$(USEMACPORTS)" "1" HAVE_HOMEBREW := $(shell expr `which -s brew; echo $$?` = 0) endif @@ -487,6 +488,11 @@ endif # MAKEFILE_SRC #-INCLUDE multisnd-post.370 # +.PHONY: checkmakefiles +checkmakefiles: checkstamp + ( $(MAKE) -f sys/unix/Makefile.check ) + + ifdef WANT_LIBNH $(TARGETPFX)libnh.a: $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a $(AR) rcs $@ $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a