From 349fbe93b162b094648a85615695d840cb7d119b Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 7 Sep 2025 12:50:54 -0400 Subject: [PATCH] less verbose compiler command lines during build If using hints file sys/unix/hints/linux.370 or sys/unix/hints/macOS.370 allow the majority of the boilerplate compile switches to reside in a compiler response file, instead of on the command line. Include one of the following on your make command line: make response=1 or make resp=1 It can be combined with other make command line options. See sys/unix/README-hints for further information about those. The response files that it uses are: CC (clang or gcc) src/nethack_cc.rsp CXx (clang++ or g++) src/nethack_cxx.rsp Note: I think the reduced clutter should actually become the default, and the override should be noresponse=1 to NOT use it, but I'm not sure how others feel, so for now, it requires make resp=1 Feedback on whether that should become the default or not is welcome. Tested on Linux with gcc-15 and on Linux with clang-20. I haven't had a chance to test it on macOS yet. --- src/.gitignore | 1 + sys/unix/Makefile.src | 9 ++++++-- sys/unix/README-hints | 5 ++++- sys/unix/hints/include/response.370 | 33 +++++++++++++++++++++++++++++ sys/unix/hints/linux.370 | 4 ++++ sys/unix/hints/macOS.370 | 3 +++ 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 sys/unix/hints/include/response.370 diff --git a/src/.gitignore b/src/.gitignore index 13097d000..30c020d13 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -16,6 +16,7 @@ nethack tiles.bmp *.moc *.lnk +*.rsp graphicschk nhdat o diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 57bd4b1db..e5763785f 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -198,7 +198,7 @@ ARFLAGS = rcs # The Qt and Be window systems are written in C++, while the rest of # NetHack is standard C. If using Qt, uncomment the LINK line here to get # the C++ libraries linked in. -CXXFLAGS = $(CCXXFLAGS) -I. -I$(QTDIR)/include $(QTCXXFLAGS) +CXXFLAGS ?= $(CCXXFLAGS) -I. -I$(QTDIR)/include $(QTCXXFLAGS) CXX ?= g++ MOC ?= moc MOCPATH ?= $(QTDIR)/bin/$(MOC) @@ -642,7 +642,11 @@ DATE_O = $(TARGETPFX)date.o all: $(GAME) @echo "" -pregame: +create_responsefiles: + echo $(CC_COMPILER_SWITCHES) >$(CC_RESPONSEFILE) + echo $(CXX_COMPILER_SWITCHES) >$(CXX_RESPONSEFILE) + +pregame: $(RESPONSEFILES) $(PREGAME) $(GAME): pregame $(MAKEDEFS) $(LUALIB) $(WAVS) $(SYSTEM) @@ -808,6 +812,7 @@ clean: -rm -f *.o $(HACK_H) $(CONFIG_H) -rm -f monstr.c vis_tab.c ../include/vis_tab.h #obsolete generated files true; $(CLEANMORE) + true; $(CLEAN_CC_RESPONSEFILE) $(CLEAN_CXX_RESPONSEFILE) spotless: clean -rm -f a.out core $(HACKLIB) $(GAMEBIN) Sys* diff --git a/sys/unix/README-hints b/sys/unix/README-hints index 9c5f06934..03c3fd893 100644 --- a/sys/unix/README-hints +++ b/sys/unix/README-hints @@ -49,7 +49,10 @@ make musl=1 Build with settings appropriate for linking with musl libc, instead of glibc. This causes NOCRASHREPORT to be defined, and avoids the use of 'col' during the build. - +make resp=1 Place the majority of the compiler switches into + a response file to de-clutter the build compiler + command lines and eliminate some of the + unsightly wrapping that occurs. make CROSS_TO_MSDOS=1 package Cross-compile for an MSDOS target package. make CROSS_TO_WASM=1 Cross-compile for a WASM target. make CROSS_TO_MIPS=1 Cross-compile for a mips target. diff --git a/sys/unix/hints/include/response.370 b/sys/unix/hints/include/response.370 new file mode 100644 index 000000000..4e893ea3e --- /dev/null +++ b/sys/unix/hints/include/response.370 @@ -0,0 +1,33 @@ +#------------------------------------------------------------------------------ +# NetHack 3.7 response.370 $NHDT-Date: 1668359835 2022/11/13 17:17:15 $ $NHDT-Branch: NetHack-3.7 $ + +ifeq "$(RESP)" "1" +USE_RESPONSEFILE=1 +endif +ifeq "$(resp)" "1" +USE_RESPONSEFILE=1 +endif +ifeq "$(RESPONSE)" "1" +USE_RESPONSEFILE=1 +endif +ifeq "$(response)" "1" +USE_RESPONSEFILE=1 +endif + +ifeq "$(USE_RESPONSEFILE)" "1" +RESPONSEFILES=create_responsefiles +CXXFLAGS = $(CCXXFLAGS) -I. -I$(QTDIR)/include $(QTCXXFLAGS) +CC_COMPILER_SWITCHES := $(subst \,\\,$(CFLAGS)) +CC_COMPILER_SWITCHES := $(subst ",\",$(CC_COMPILER_SWITCHES)) +CXX_COMPILER_SWITCHES := $(subst \,\\,$(CXXFLAGS)) +CXX_COMPILER_SWITCHES := $(subst ",\",$(CXX_COMPILER_SWITCHES)) +CC_RESPONSEFILE=../src/nethack_cc.rsp +CXX_RESPONSEFILE=../src/nethack_cxx.rsp +CFLAGS=@$(CC_RESPONSEFILE) +CXXFLAGS=@$(CXX_RESPONSEFILE) +CLEAN_CC_RESPONSEFILE=rm -f $(CC_RESPONSEFILE); +CLEAN_CXX_RESPONSEFILE=rm -f $(CXX_RESPONSEFILE); +endif + +#end of response.370 +#------------------------------------------------------------------------------ diff --git a/sys/unix/hints/linux.370 b/sys/unix/hints/linux.370 index 3ce7d47d4..4f49e9921 100755 --- a/sys/unix/hints/linux.370 +++ b/sys/unix/hints/linux.370 @@ -448,6 +448,10 @@ MANDIR=/usr/share/man/man6 #-INCLUDE multisnd2-pre.370 # +# +#-INCLUDE response.370 +# + #-POST # diff --git a/sys/unix/hints/macOS.370 b/sys/unix/hints/macOS.370 index ad522bb2f..13cb3afe1 100755 --- a/sys/unix/hints/macOS.370 +++ b/sys/unix/hints/macOS.370 @@ -461,6 +461,9 @@ SYSCONFENSURE = (if ! test -f $(INSTDIR)/sysconf ; then \ # #-INCLUDE multisnd2-pre.370 # +# +#-INCLUDE response.370 +# ifdef MAKEFILE_TOP .PHONY: bundle