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.
This commit is contained in:
nhmall
2025-09-07 12:50:54 -04:00
parent d5d40b322c
commit 349fbe93b1
6 changed files with 52 additions and 3 deletions

1
src/.gitignore vendored
View File

@@ -16,6 +16,7 @@ nethack
tiles.bmp
*.moc
*.lnk
*.rsp
graphicschk
nhdat
o

View File

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

View File

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

View File

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

View File

@@ -448,6 +448,10 @@ MANDIR=/usr/share/man/man6
#-INCLUDE multisnd2-pre.370
#
#
#-INCLUDE response.370
#
#-POST
#

View File

@@ -461,6 +461,9 @@ SYSCONFENSURE = (if ! test -f $(INSTDIR)/sysconf ; then \
#
#-INCLUDE multisnd2-pre.370
#
#
#-INCLUDE response.370
#
ifdef MAKEFILE_TOP
.PHONY: bundle