#------------------------------------------------------------------------------ # NetHack 3.7 compiler.2020 $NHDT-Date: 1597332785 2020/08/13 15:33:05 $ $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. CCISCLANG := $(shell echo `$(CC) --version` | grep clang) ifeq "$(CCISCLANG)" "" CXX=g++ -std=gnu++11 else CXX=clang++ -std=gnu++11 endif # if you want to override the compiler detection just carried out # uncomment one of the following pairs as desired. #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+=-Wformat-nonliteral CFLAGS+=-DGCC_WARN # As of LLVM build 2336.1.00, this gives dozens of spurious messages, so # # leave it out by default. # #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 ifdef WANT_WIN_QT QTCXXFLAGS = -g -I../include -DNOTPARMDECL QTCXXFLAGS+=-Wall -Wextra -Wno-missing-field-initializers \ -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings QTCXXFLAGS+=-pedantic QTCXXFLAGS+=-Wmissing-declarations QTCXXFLAGS+=-Wformat-nonliteral QTCXXFLAGS+=-DGCC_WARN endif ifeq "$(CCISCLANG)" "" #gcc-specific here CFLAGS+=-Wmissing-parameter-type # 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+=-Wno-format-overflow endif #gcc version greater than or equal to 9 ifdef WANT_WIN_QT # get the version of g++ GPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9) ifeq "$(GPPGTEQ9)" "1" #QTCXXFLAGS+=-Wno-format-overflow endif #g++ version greater than or equal to 9 #QTCXXFLAGS+= -Wno-format-truncation QTCXXFLAGS+= -Wno-deprecated-copy endif #WANT_WIN_QT else # clang # clang-specific here endif # clang #end of compiler.2020 #------------------------------------------------------------------------------