some Makefile and hints tinkering

1. remove all window interface bits from compiler.370, and have
   the preceding include files set some variables to control
   the behavior of compiler.370 when it comes to c++.
2. some more common Makefile lines into sys/unix/hints/include/multiw-3.370.
3. make it so you can pass cppregex=1 on the Make command line to build with
   sys/share/cppregex.cpp instead of posixregex.c
4. fix sys/share/cppregex.cpp so that it will build with clang compiler
   (required an additional header include). I don't know if it would have
   worked with g++ without that change. The include can be placed into an #ifdef
   block if there's an issue with the change on other compilers.
5. Anything that needs to compile using c++ (Qt, sys/share/cppregex.cpp) can
   just ensure that CPLUSPLUS_NEEDED Makefile variable is set above the lines
   in compiler.370 to ensure that things get set up for c++. It no longer
   checks specifically for Qt. That is what sys/unix/hints/include/multiw-2.370
   does now.
This commit is contained in:
nhmall
2022-11-13 22:25:07 -05:00
parent d957d70d15
commit 3f93d54b66
8 changed files with 211 additions and 166 deletions

View File

@@ -22,22 +22,13 @@ CCFLAGS = -g
#
#CC= clang
#CXX=clang++ -std=gnu++11
#
# If these are set on entry, preparation for C++ compiles is affected.
# CPLUSPLUS_NEEDED = 1 C++ compile bits included
# CPLUSPLUS_NEED17 = 1 C++ -std=c++17 (at least)
# CPLUSPLUS_NEED_DEPSUPPRESS = 1 C++ -Wno-deprecated-copy,
# -Wno-deprecated-declarations
#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
@@ -55,8 +46,11 @@ CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers \
-Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings
CFLAGS+=-pedantic
CFLAGS+=-Wmissing-declarations
CFLAGS+=-Wunreachable-code
# these are left out of the C++ flags
CFLAGS+=-Wformat-nonliteral
CFLAGS+=-Wunreachable-code
#
# the following are not allowed in C++
CFLAGS+=-Wimplicit
@@ -66,18 +60,11 @@ 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
#detection of clang vs gcc
CCISCLANG := $(shell echo `$(CC) --version` | grep clang)
ifeq "$(CCISCLANG)" ""
# gcc-specific follows
CFLAGS+=-Wmissing-parameter-type
ifdef WANT_WIN_QT
CCXXFLAGS+= -Wno-deprecated-copy
endif # WANT_WIN_QT
CXX=g++ -std=gnu++11
# get the version of gcc
GCCGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9)
GCCGTEQ11 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 11)
@@ -85,53 +72,86 @@ GCCGTEQ12 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 12)
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
CFLAGS+=-Wmissing-parameter-type
endif # GCC greater than or equal to 9
#ifeq "$(GCCGTEQ11)" "1"
#endif
#ifeq "$(GCCGTEQ12)" "1"
#endif
# end of gcc-specific
else # gcc or clang?
CXX=clang++ -std=gnu++11
# clang-specific follows
# none
endif # clang-specific ends here
ifdef MAKEFILE_SRC
ifdef CPLUSPLUS_NEEDED
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
#detection of clang++ vs g++
CXXISCLANG := $(shell echo `$(CXX) --version` | grep clang)
ifeq "$(CXXISCLANG)" ""
# g++-specific
CCXX=g++ -std=gnu++11
# get the version of g++
GPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
GPPGTEQ11 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 11)
GPPGTEQ12 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 12)
GPPGTEQ11 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 11)
GPPGTEQ12 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 12)
ifeq "$(GPPGTEQ9)" "1"
CCXXFLAGS+=-Wformat-overflow
ifdef WANT_WIN_QT
ifdef CPLUSPLUS_NEED_DEPSUPPRESS
CCXXFLAGS+=-Wno-deprecated-copy
CCXXFLAGS+=-Wno-deprecated-declarations
endif # WANT_WIN_QT
endif # CPLUSPLUS_NEED_DEPSUPPRESS
endif # g++ version greater than or equal to 9
ifeq "$(GPPGTEQ11)" "1"
#the g++ linker will have trouble linker if the following isn't included
#when compiling the C files.
ifdef WANT_WIN_QT
# the g++ linker will have trouble linking if the following isn't included
# when compiling the C files.
CFLAGS+=-fPIC
endif # WANT_WIN_QT
endif # g++ version greater than or equal to 11
ifdef CPLUSPLUS_NEED17
ifeq "$(GPPGTEQ12)" "1"
ifdef WANT_WIN_QT6
CXX=g++ -std=c++20
endif # WANT_WIN_QT6
CCXX=g++ -std=c++20
else # g++ version greater than or equal to 12? (no follows)
CCXX=g++ -std=c++17
endif # g++ version greater than or equal to 12
# end of gcc-specific
endif # CPLUSPLUS_NEED17
else # clang-specific follows
else # g++ or clang++ ?
# clang++-specific
CCXX=clang++ -std=c++11
# get the version of clang++
CLANGPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
CLANGPPGTEQ14 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 14)
ifeq "$(CLANGPPGTEQ9)" "1"
ifdef WANT_WIN_QT
#CCXXFLAGS+=-Wformat-overflow
CCXXFLAGS+=-Wno-deprecated-copy
endif # WANT_WIN_QT
endif #clang++ greater than or equal to 9
ifdef WANT_WIN_QT
endif # clang++ greater than or equal to 9
ifeq "$(CLANGPPGTEQ14)" "1"
# The clang++ linker seems to have trouble linker if the following isn't
CCXXFLAGS+=-Wno-deprecated-declarations
endif # clang++ greater than or equal to 14
# The clang++ linker seems to have trouble linking if the following isn't
# included when compiling the C files by clang..
CFLAGS+=-fPIC
ifdef CPLUSPLUS_NEED17
ifeq "$(CLANGPPGTEQ14)" "1"
$(info greaterthanorequalto14)
CCXX=clang++ -std=c++20
else
$(info not greaterthanorequalto14)
CCXX=clang++ -std=c++17
endif # clang++ greater than or equal to 14
CCXXFLAGS+=-Wno-deprecated-declarations
endif # WANT_WIN_QT
endif # clang-specific ends here
endif # CPLUSPLUS_NEED17
endif # end of clang++-specific section
endif # CPLUSPLUS_NEEDED
CXX=$(CCXX)
endif # MAKEFILE_SRC
#end of compiler.370
#------------------------------------------------------------------------------

View File

@@ -102,12 +102,71 @@ XTRASRC += tile.c
XTRAOBJ += $(TARGETPFX)tile.o
endif
ifndef WANT_WIN_QT
ifdef WANT_WIN_ALL
WANT_WIN_QT=1
endif
ifdef WANT_WIN_QT5
ifndef WANT_WIN_QT
WANT_WIN_QT=1
endif # not WANT_WIN_QT
endif # WANT_WIN_QT5
ifdef WANT_WIN_QT6
ifndef WANT_WIN_QT
WANT_WIN_QT=1
endif # not WANT_WIN_QT
endif # WANT_WIN_QT6
endif # not def WANT_WIN_QT
ifdef WANT_WIN_QT
# WANT_WIN_QT5 is the default
ifndef WANT_WIN_QT5
ifndef WANT_WIN_QT6
WANT_WIN_QT5=1
endif # not WANT_WIN_QT6
endif # not WANT_WIN_QT5
endif # WANT_WIN_QT
ifdef WANT_WIN_QT
WINCFLAGS += -DQT_GRAPHICS
WINSRC += $(WINQTSRC)
WINOBJ0 += $(WINQTOBJ)
XTRASRC += tile.c
XTRAOBJ += $(TARGETPFX)tile.o
#
ifndef CPLUSPLUS_NEEDED
CPLUSPLUS_NEEDED = 1
endif # CPLUSPLUS_NEEDED
ifdef WANT_WIN_QT6
CPLUSPLUS_NEED17 = 1
CPLUSPLUS_NEED_DEPSUPPRESS = 1
endif # WANT_WIN_QT6
endif # WANT_WIN_QT
ifeq "$(GIT)" "1"
ifndef GITSUBMODULES
GITSUBMODULES=1
endif
endif
ifeq "$(git)" "1"
ifndef GITSUBMODULES
GITSUBMODULES=1
endif
endif
ifeq "$(CPPREGEX)" "1"
REGEXOBJ=$(TARGETPFX)cppregex.o
ifndef CPLUSPLUS_NEEDED
CPLUSPLUS_NEEDED = 1
endif
endif
ifeq "$(cppregex)" "1"
REGEXOBJ=$(TARGETPFX)cppregex.o
ifndef CPLUSPLUS_NEEDED
CPLUSPLUS_NEEDED = 1
endif
endif
#end of hints/include/multiw-2.370

View File

@@ -39,6 +39,32 @@ USE_CURSESLIB=1
endif
endif
ifeq "$(GIT)" "1"
ifndef GITSUBMODULES
GITSUBMODULES=1
endif
endif
ifeq "$(git)" "1"
ifndef GITSUBMODULES
GITSUBMODULES=1
endif
endif
ifeq "$(CPPREGEX)" "1"
REGEXOBJ=$(TARGETPFX)cppregex.o
ifndef CPLUSPLUS_NEEDED
CPLUSPLUS_NEEDED = 1
endif
endif
ifeq "$(cppregex)" "1"
REGEXOBJ=$(TARGETPFX)cppregex.o
ifndef CPLUSPLUS_NEEDED
CPLUSPLUS_NEEDED = 1
endif
endif
#end of hints/include/multiw-3.370
#------------------------------------------------------------------------------