reduce and dmake now use existing object files as dependencies whenever possible. Fix compilation for reduce on cygwin.

This commit is contained in:
amai 2014-05-03 18:54:48 +02:00
parent ed1d63ffc0
commit 3bdfad0b73
2 changed files with 21 additions and 11 deletions

View File

@ -238,12 +238,12 @@ test: all
check: all check: all
./testrunner -g -q ./testrunner -g -q
dmake: tools/dmake.cpp dmake: tools/dmake.o
$(CXX) -std=c++0x -o dmake tools/dmake.cpp cli/filelister.cpp lib/path.cpp -Ilib $(LDFLAGS) $(CXX) -std=c++0x -o dmake tools/dmake.o cli/filelister.o lib/path.o -Ilib $(LDFLAGS)
./dmake ./dmake
reduce: tools/reduce.cpp $(LIBOBJ) reduce: tools/reduce.o externals/tinyxml/tinyxml2.o $(LIBOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -std=c++0x -g -o reduce tools/reduce.cpp -Ilib -Iexternals/tinyxml $(LIBOBJ) $(LIBS) externals/tinyxml/tinyxml2.cpp $(LDFLAGS) $(RDYNAMIC) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -std=c++0x -g -o reduce tools/reduce.o -Ilib -Iexternals/tinyxml $(LIBOBJ) $(LIBS) externals/tinyxml/tinyxml2.o $(LDFLAGS) $(RDYNAMIC)
clean: clean:
rm -f build/*.o lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner reduce cppcheck cppcheck.1 rm -f build/*.o lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner reduce cppcheck cppcheck.1
@ -553,3 +553,9 @@ test/testvalueflow.o: test/testvalueflow.cpp lib/cxx11emu.h test/testsuite.h lib
externals/tinyxml/tinyxml2.o: externals/tinyxml/tinyxml2.cpp lib/cxx11emu.h externals/tinyxml/tinyxml2.h externals/tinyxml/tinyxml2.o: externals/tinyxml/tinyxml2.cpp lib/cxx11emu.h externals/tinyxml/tinyxml2.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -std=c++0x -c -o externals/tinyxml/tinyxml2.o externals/tinyxml/tinyxml2.cpp $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -std=c++0x -c -o externals/tinyxml/tinyxml2.o externals/tinyxml/tinyxml2.cpp
tools/dmake.o: tools/dmake.cpp lib/cxx11emu.h cli/filelister.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -std=c++0x -c -o tools/dmake.o tools/dmake.cpp
tools/reduce.o: tools/reduce.cpp lib/cxx11emu.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -std=c++0x -c -o tools/reduce.o tools/reduce.cpp

View File

@ -161,6 +161,9 @@ int main(int argc, char **argv)
std::vector<std::string> testfiles; std::vector<std::string> testfiles;
getCppFiles(testfiles, "test/"); getCppFiles(testfiles, "test/");
std::vector<std::string> toolsfiles;
getCppFiles(toolsfiles, "tools/");
if (libfiles.empty() && clifiles.empty() && testfiles.empty()) { if (libfiles.empty() && clifiles.empty() && testfiles.empty()) {
std::cerr << "No files found. Are you in the correct directory?" << std::endl; std::cerr << "No files found. Are you in the correct directory?" << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
@ -363,15 +366,15 @@ int main(int argc, char **argv)
fout << "\n###### Object Files\n\n"; fout << "\n###### Object Files\n\n";
fout << "LIBOBJ = " << objfile(libfiles[0]); fout << "LIBOBJ = " << objfile(libfiles[0]);
for (unsigned int i = 1; i < libfiles.size(); ++i) for (size_t i = 1; i < libfiles.size(); ++i)
fout << " \\\n" << std::string(14, ' ') << objfile(libfiles[i]); fout << " \\\n" << std::string(14, ' ') << objfile(libfiles[i]);
fout << "\n\n"; fout << "\n\n";
fout << "CLIOBJ = " << objfile(clifiles[0]); fout << "CLIOBJ = " << objfile(clifiles[0]);
for (unsigned int i = 1; i < clifiles.size(); ++i) for (size_t i = 1; i < clifiles.size(); ++i)
fout << " \\\n" << std::string(14, ' ') << objfile(clifiles[i]); fout << " \\\n" << std::string(14, ' ') << objfile(clifiles[i]);
fout << "\n\n"; fout << "\n\n";
fout << "TESTOBJ = " << objfile(testfiles[0]); fout << "TESTOBJ = " << objfile(testfiles[0]);
for (unsigned int i = 1; i < testfiles.size(); ++i) for (size_t i = 1; i < testfiles.size(); ++i)
fout << " \\\n" << std::string(14, ' ') << objfile(testfiles[i]); fout << " \\\n" << std::string(14, ' ') << objfile(testfiles[i]);
fout << "\n\n"; fout << "\n\n";
@ -388,11 +391,11 @@ int main(int argc, char **argv)
fout << "\t./testrunner\n\n"; fout << "\t./testrunner\n\n";
fout << "check:\tall\n"; fout << "check:\tall\n";
fout << "\t./testrunner -g -q\n\n"; fout << "\t./testrunner -g -q\n\n";
fout << "dmake:\ttools/dmake.cpp\n"; fout << "dmake:\ttools/dmake.o\n";
fout << "\t$(CXX) -std=c++0x -o dmake tools/dmake.cpp cli/filelister.cpp lib/path.cpp -Ilib $(LDFLAGS)\n"; fout << "\t$(CXX) -std=c++0x -o dmake tools/dmake.o cli/filelister.o lib/path.o -Ilib $(LDFLAGS)\n";
fout << "\t./dmake\n\n"; fout << "\t./dmake\n\n";
fout << "reduce:\ttools/reduce.cpp $(LIBOBJ)\n"; fout << "reduce:\ttools/reduce.o externals/tinyxml/tinyxml2.o $(LIBOBJ)\n";
fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -std=c++0x -g -o reduce tools/reduce.cpp -Ilib -Iexternals/tinyxml $(LIBOBJ) $(LIBS) externals/tinyxml/tinyxml2.cpp $(LDFLAGS) $(RDYNAMIC)\n\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -std=c++0x -g -o reduce tools/reduce.o -Ilib -Iexternals/tinyxml $(LIBOBJ) $(LIBS) externals/tinyxml/tinyxml2.o $(LDFLAGS) $(RDYNAMIC)\n\n";
fout << "clean:\n"; fout << "clean:\n";
fout << "\trm -f build/*.o lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner reduce cppcheck cppcheck.1\n\n"; fout << "\trm -f build/*.o lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner reduce cppcheck cppcheck.1\n\n";
fout << "man:\tman/cppcheck.1\n\n"; fout << "man:\tman/cppcheck.1\n\n";
@ -411,6 +414,7 @@ int main(int argc, char **argv)
compilefiles(fout, clifiles, "${INCLUDE_FOR_CLI}"); compilefiles(fout, clifiles, "${INCLUDE_FOR_CLI}");
compilefiles(fout, testfiles, "${INCLUDE_FOR_TEST}"); compilefiles(fout, testfiles, "${INCLUDE_FOR_TEST}");
compilefiles(fout, externalfiles, "${INCLUDE_FOR_LIB}"); compilefiles(fout, externalfiles, "${INCLUDE_FOR_LIB}");
compilefiles(fout, toolsfiles, "${INCLUDE_FOR_LIB}");
return 0; return 0;
} }