diff --git a/src/Makefile b/src/Makefile index 0c9fc1472..d61e3db08 100644 --- a/src/Makefile +++ b/src/Makefile @@ -274,10 +274,11 @@ opts+=$(debug_opts) opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v))) -opts+=$(WFLAGS) $(CPPFLAGS) $(CFLAGS) -cxxopts:=$(opts) $(CXXFLAGS) +CXXFLAGS+=-std=c++17 # force c17 for c++ since most vpss run older ubuntu versions with old compilers -cxxopts+=-std=c++17 # force c17 for c++ since most vpss run older ubuntu versions with old compilers +opts+=$(WFLAGS) $(CFLAGS) +cxxopts:=$(opts) $(CXXFLAGS) +opts+=$(CWFLAGS) # warning flags that shouldnt be passed to c++ compiler libs+=$(LDFLAGS) -lstdc++ -lpthread asflags:=$(ASFLAGS) -x assembler-with-cpp @@ -393,9 +394,23 @@ endif endef $(eval $(call _recipe,c)) -$(eval $(call _recipe,cpp)) $(eval $(call _recipe,s,$(asflags))) +# c++ dependency recipe template +# 1: source file suffix +# 2: extra flags to gcc +define _recipe = +$(depdir)/%.d : %.$(1) | $$$$(@D)/ +ifndef WINDOWSHELL +ifdef Echo_name + @printf '%-20.20s\r' $$< +endif +endif + $(.)$(cxx) -MM -MF $$@ -MT $(objdir)/$$*.o $(2) $$< +endef + +$(eval $(call _recipe,cpp)) + # compiling recipe template # 1: target file suffix # 2: source file suffix diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index a6ff90d82..3e577c897 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -41,7 +41,8 @@ ifdef GCC41 WFLAGS+=-Wshadow endif #WFLAGS+=-Wlarger-than-%len% - WFLAGS+=-Wpointer-arith -Wbad-function-cast + WFLAGS+=-Wpointer-arith + CWFLAGS+=-Wbad-function-cast ifdef GCC45 #WFLAGS+=-Wc++-compat endif @@ -71,9 +72,10 @@ endif endif #WFLAGS+=-Wstrict-prototypes ifdef GCC40 - WFLAGS+=-Wold-style-definition + CWFLAGS+=-Wold-style-definition endif - WFLAGS+=-Wmissing-prototypes -Wmissing-declarations + WFLAGS+=-Wmissing-declarations + CWFLAGS+=-Wmissing-prototypes ifdef GCC40 WFLAGS+=-Wmissing-field-initializers endif @@ -84,7 +86,7 @@ endif #WFLAGS+=-Wpacked #WFLAGS+=-Wpadded #WFLAGS+=-Wredundant-decls - WFLAGS+=-Wnested-externs + CWFLAGS+=-Wnested-externs #WFLAGS+=-Wunreachable-code WFLAGS+=-Winline ifdef DEBUGMODE