@@ -351,23 +351,29 @@ static void write_ossfuzz_makefile(std::vector<std::string> libfiles_prio, std::
351351
352352 fout << " # This file is generated by dmake, do not edit.\n " ;
353353 fout << ' \n ' ;
354- fout << " # make CXX=clang++ MATCHCOMPILER=yes CXXFLAGS =\" -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - fsanitize=address -fsanitize-address-use-after-scope -DHAVE_BOOST\" LIB_FUZZING_ENGINE=\" -fsanitize=fuzzer\" oss-fuzz-client\n " ;
354+ fout << " # make CXX=clang++ MATCHCOMPILER=yes CXXOPTS =\" -O1 -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fsanitize-address-use-after-scope\" CPPOPTS= \" -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -DHAVE_BOOST\" LIB_FUZZING_ENGINE=\" -fsanitize=fuzzer\" oss-fuzz-client\n " ;
355355 fout << ' \n ' ;
356356 fout << " MATCHCOMPILER=yes\n " ; // always need to enable the matchcompiler so the library files are being copied
357357 makeMatchcompiler (fout, " ../" , " --read-dir ../lib" );
358358
359359 fout << " INCS=-I../lib -isystem../externals/simplecpp -isystem../externals/tinyxml2 -isystem../externals/picojson\n " ;
360- fout << " CPPFLAGS=-std=c++11 -g -w $(INCS)\n " ;
360+ fout << ' \n ' ;
361+ fout << " override CXXFLAGS+=-std=c++11 -g -w\n " ;
362+ fout << " override CPPFLAGS+=$(INCS)\n " ;
363+ fout << ' \n ' ;
364+ fout << " override CXXFLAGS += $(CXXOPTS)\n " ;
365+ fout << " override CPPFLAGS += $(CPPOPTS)\n " ;
366+ fout << " override LDFLAGS += $(LDOPTS)\n " ;
361367 fout << ' \n ' ;
362368 fout << " LIBOBJ = " << objfiles (libfiles_prio) << " \n " ;
363369 fout << ' \n ' ;
364370 fout << " EXTOBJ = " << objfiles (extfiles) << " \n " ;
365371 fout << ' \n ' ;
366372 fout << " oss-fuzz-client: $(EXTOBJ) $(LIBOBJ) main.o type2.o\n " ;
367- fout << " \t ${CXX} $(CPPFLAGS) $ {CXXFLAGS} -o $@ $^ ${LIB_FUZZING_ENGINE}\n " ;
373+ fout << " \t ${CXX} ${CXXFLAGS} -o $@ $^ ${LIB_FUZZING_ENGINE}\n " ;
368374 fout << ' \n ' ;
369375 fout << " no-fuzz: $(EXTOBJ) $(LIBOBJ) main_nofuzz.o type2.o\n " ;
370- fout << " \t ${CXX} $(CPPFLAGS) $ {CXXFLAGS} -o $@ $^\n " ;
376+ fout << " \t ${CXX} ${CXXFLAGS} -o $@ $^\n " ;
371377 fout << ' \n ' ;
372378 fout << " translate: translate.o type2.o\n " ;
373379 fout << " \t ${CXX} -std=c++11 -g ${CXXFLAGS} -o $@ type2.cpp translate.cpp\n " ;
@@ -708,7 +714,8 @@ int main(int argc, char **argv)
708714
709715 // Makefile settings..
710716 if (release) {
711- makeConditionalVariable (fout, " CXXFLAGS" , " -O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-multichar" );
717+ makeConditionalVariable (fout, " CXXFLAGS" , " -O2 -Wall -Wno-sign-compare -Wno-multichar" );
718+ fout << " override CPPFLAGS += -DNDEBUG\n\n " ;
712719 } else {
713720 makeConditionalVariable (fout, " CXXFLAGS" ,
714721 " -pedantic "
@@ -725,8 +732,8 @@ int main(int argc, char **argv)
725732 " -Wno-sign-compare "
726733 " -Wno-multichar "
727734 " -Woverloaded-virtual "
728- // "$(CPPCHK_GLIBCXX_DEBUG) " // TODO: when using CXXOPTS this would always be set - need to handle this differently
729735 " -g" );
736+ // fout << "override CPPFLAGS += $(CPPCHK_GLIBCXX_DEBUG)\n\n"; // TODO: when using CXXOPTS this would always be set - need to handle this differently
730737 }
731738
732739 fout << " ifeq (g++, $(findstring g++,$(CXX)))\n "
@@ -740,7 +747,8 @@ int main(int argc, char **argv)
740747 << " ifeq ($(PCRE_CONFIG),)\n "
741748 << " $(error Did not find pcre-config)\n "
742749 << " endif\n "
743- << " override CXXFLAGS += -DHAVE_RULES $(shell $(PCRE_CONFIG) --cflags)\n "
750+ << " override CXXFLAGS += $(shell $(PCRE_CONFIG) --cflags)\n "
751+ << " override CPPFLAGS += -DHAVE_RULES\n "
744752 << " ifdef LIBS\n "
745753 << " LIBS += $(shell $(PCRE_CONFIG) --libs)\n "
746754 << " else\n "
@@ -751,6 +759,7 @@ int main(int argc, char **argv)
751759 << " endif\n\n " ;
752760
753761 fout << " override CXXFLAGS += $(CXXOPTS)\n " ;
762+ fout << " override CPPFLAGS += $(CPPOPTS)\n " ;
754763 fout << " override LDFLAGS += $(LDOPTS)\n\n " ;
755764
756765 makeConditionalVariable (fout, " PREFIX" , " /usr" );
@@ -775,7 +784,7 @@ int main(int argc, char **argv)
775784 fout << " .PHONY: run-dmake tags\n\n " ;
776785 fout << " \n ###### Targets\n\n " ;
777786 fout << " cppcheck: $(EXTOBJ) $(LIBOBJ) $(FEOBJ) $(CLIOBJ)\n " ;
778- fout << " \t $(CXX) $(CPPFLAGS) $( CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n " ;
787+ fout << " \t $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n " ;
779788 fout << " all:\t cppcheck testrunner\n\n " ;
780789 std::string testrunner_clifiles_o;
781790 for (const std::string &clifile: clifiles) {
@@ -786,7 +795,7 @@ int main(int argc, char **argv)
786795 testrunner_clifiles_o += o;
787796 }
788797 fout << " testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ) $(FEOBJ)" << testrunner_clifiles_o << " \n " ;
789- fout << " \t $(CXX) $(CPPFLAGS) $( CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n " ;
798+ fout << " \t $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n " ;
790799 fout << " test:\t all\n " ;
791800 fout << " \t ./testrunner\n\n " ;
792801 fout << " check:\t all\n " ;
0 commit comments