do the Makefile checking using make itself

This commit is contained in:
nhmall
2023-11-20 22:14:22 -05:00
parent 18962b41d9
commit 4a08f20090
5 changed files with 46 additions and 64 deletions

30
sys/unix/Makefile.check Executable file
View File

@@ -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: $?

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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