This is an attempt to address the issue of switching from Qt 5 to Qt 6 or vice versa on Unix without running 'make spotless'. Various *.h files (but not all of them) in win/Qt/ are run through a program called 'moc' to create new files *.moc that are included by *.cpp. The problem is that the constructed files use the same names for Qt 5 or 6 but their contents apparently aren't compatible. This adds rules (specific to GNU make) that use a pair of timestamp files to track which version of moc made src/*.moc and to destroy them when switching Qt versions in order to force their re-creation. As it stands, a hints file which includes hints/include/compiler.370 is now required in order to build the Qt interface with the Unix Makefiles. There's no change for platforms that don't use those and I've no idea whether something comparable could be done for macOS Xcode IDE. The first time make is run with WANT_WIN_QT=1 after this is in place, all the .moc files will be rebuilt and the subset of .cpp files which include them will be recompiled. After that, the .moc files will be rebuilt as needed--and only as needed--just like any other constructed files.
141 lines
4.3 KiB
Plaintext
Executable File
141 lines
4.3 KiB
Plaintext
Executable File
#------------------------------------------------------------------------------
|
|
# NetHack 3.7 compiler.370 $NHDT-Date: 1637992237 2021/11/27 05:50:37 $ $NHDT-Branch: NetHack-3.7 $
|
|
|
|
# compiler flags: CCFLAGS is used to construct a value for CFLAGS with
|
|
# various -I, -D, and -W settings appended below;
|
|
# these are the settings of most interest for an end-user build
|
|
# (clang doesn't support '-Og', gcc needs 4.x or later)
|
|
CCFLAGS = -g
|
|
#CCFLAGS = -g -Og
|
|
#CCFLAGS = -O2
|
|
# Note: this is not the usual 'CFLAGS' which is used in default
|
|
# rules for compiling C code; specifying a value for that on the
|
|
# 'make' command line should be avoided.
|
|
|
|
#If you want to force use of one particular set of compilers, do it
|
|
#here, ahead of the detection, so that the detection will match your
|
|
#choice and set variables CCISCLANG, GCCGTEQ, CLANGPPGTEQ9 etc.
|
|
#accordingly.
|
|
#
|
|
#CC= gcc
|
|
#CXX= g++ -std-gnu++11
|
|
#
|
|
#CC= clang
|
|
#CXX=clang++ -std=gnu++11
|
|
|
|
#detection
|
|
CCISCLANG := $(shell echo `$(CC) --version` | grep clang)
|
|
ifeq "$(CCISCLANG)" ""
|
|
ifdef WANT_WIN_QT6
|
|
CXX=g++ -std=c++17
|
|
else
|
|
CXX=g++ -std=gnu++11
|
|
endif
|
|
else
|
|
ifdef WANT_WIN_QT6
|
|
CXX=clang++ -std=c++17
|
|
else
|
|
CXX=clang++ -std=gnu++11
|
|
endif
|
|
endif # clang
|
|
|
|
# If you want to override the compiler detection just carried out
|
|
# uncomment one of the following pairs. Note, however, that
|
|
# doing this after the detection above will likely result in
|
|
# mismatched variable values for CCISCLANG, GCCGTEQ, CLANGPPGTEQ9 etc.
|
|
#
|
|
#CC= gcc
|
|
#CXX= g++ -std-gnu++11
|
|
#
|
|
#CC= clang
|
|
#CXX=clang++ -std=gnu++11
|
|
|
|
CFLAGS=$(CCFLAGS) -I../include -DNOTPARMDECL
|
|
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers \
|
|
-Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings
|
|
CFLAGS+=-pedantic
|
|
CFLAGS+=-Wmissing-declarations
|
|
CFLAGS+=-Wunreachable-code
|
|
#
|
|
# the following are not allowed in C++
|
|
CFLAGS+=-Wimplicit
|
|
CFLAGS+=-Wimplicit-function-declaration
|
|
CFLAGS+=-Wimplicit-int
|
|
CFLAGS+=-Wmissing-prototypes
|
|
CFLAGS+=-Wold-style-definition
|
|
CFLAGS+=-Wstrict-prototypes
|
|
|
|
CCXXFLAGS = -g -I../include -DNOTPARMDECL
|
|
CCXXFLAGS+=-Wall -Wextra -Wno-missing-field-initializers \
|
|
-Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings
|
|
CCXXFLAGS+=-pedantic
|
|
CCXXFLAGS+=-Wmissing-declarations
|
|
|
|
ifeq "$(CCISCLANG)" ""
|
|
# gcc-specific follows
|
|
CFLAGS+=-Wmissing-parameter-type
|
|
ifdef WANT_WIN_QT
|
|
CCXXFLAGS+= -Wno-deprecated-copy
|
|
endif # WANT_WIN_QT
|
|
# get the version of gcc
|
|
GCCGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9)
|
|
ifeq "$(GCCGTEQ9)" "1"
|
|
# flags present in gcc version greater than or equal to 9 can go here
|
|
CFLAGS+=-Wformat-overflow
|
|
endif #gcc version greater than or equal to 9
|
|
#still in gcc-specific section here
|
|
# get the version of g++
|
|
GPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
|
|
ifeq "$(GPPGTEQ9)" "1"
|
|
CCXXFLAGS+=-Wformat-overflow
|
|
ifdef WANT_WIN_QT
|
|
CCXXFLAGS+=-Wno-deprecated-copy
|
|
CCXXFLAGS+=-Wno-deprecated-declarations
|
|
endif # WANT_WIN_QT
|
|
endif # g++ version greater than or equal to 9
|
|
# end of gcc-specific
|
|
|
|
else # clang-specific follows
|
|
|
|
# get the version of clang++
|
|
CLANGPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
|
|
ifeq "$(CLANGPPGTEQ9)" "1"
|
|
ifdef WANT_WIN_QT
|
|
CCXXFLAGS+=-Wno-deprecated-copy
|
|
endif # WANT_WIN_QT
|
|
endif #clang++ greater than or equal to 9
|
|
|
|
ifdef WANT_WIN_QT
|
|
CCXXFLAGS+=-Wno-deprecated-declarations
|
|
endif # WANT_WIN_QT
|
|
endif # clang-specific ends here
|
|
|
|
# enable some optional code in various NetHack source files
|
|
CFLAGS+=-DGCC_WARN
|
|
CCXXFLAGS+=-DGCC_WARN
|
|
|
|
ifdef MAKEFILE_SRC
|
|
ifdef WANT_WIN_QT
|
|
# when switching from Qt5 to Qt6 or vice versa, any old .moc files will be
|
|
# incompatible; get rid of them in case user hasn't run 'make spotless';
|
|
# moc.qt5 and moc.qt6 are empty timestamp files and at most one should exist
|
|
ifdef WANT_WIN_QT6
|
|
# Qt 6 builds and runs (with a couple of warnings) but needs more testing
|
|
MOCSTAMP=moc.qt6
|
|
else
|
|
# Qt 5 is currently the default version for nethack 3.7.x's Qt interface
|
|
MOCSTAMP=moc.qt5
|
|
endif
|
|
# rule to build src/qt_foo.moc from win/Qt/qt_foo.h
|
|
%.moc : ../win/Qt/%.h $(MOCSTAMP)
|
|
$(MOCPATH) -o $@ $<
|
|
moc.qt5::
|
|
@if test ! -f moc.qt5; then ( rm -f *.moc moc.qt6; touch $@ ); fi;
|
|
moc.qt6::
|
|
@if test ! -f moc.qt6; then ( rm -f *.moc moc.qt5; touch $@ ); fi;
|
|
endif #WANT_WIN_QT
|
|
endif #MAKFILE_SRC
|
|
|
|
#end of compiler.370
|
|
#------------------------------------------------------------------------------
|