From a9bd7296b7c367c8cdb6f88d923c5a39299d78e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 19 Feb 2010 17:35:38 +0100 Subject: [PATCH] dmake: simplified a little --- tools/dmake.cpp | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/tools/dmake.cpp b/tools/dmake.cpp index 5b3ffe84b..6a857788a 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -80,28 +80,37 @@ static void compilefiles(std::ostream &fout, const std::vector &fil } } +static void getCppFiles(std::vector &files, const std::string &path) +{ + FileLister::recursiveAddFiles(files, path, true); + + // only get *.cpp files.. + for (std::vector::iterator it = files.begin(); it != files.end();) + { + if (it->find(".cpp") == std::string::npos) + it = files.erase(it); + else + ++it; + } +} + int main() { // Get files.. std::vector libfiles; - FileLister::recursiveAddFiles(libfiles, "lib/", true); + getCppFiles(libfiles, "lib/"); std::vector clifiles; - FileLister::recursiveAddFiles(clifiles, "cli/", true); + getCppFiles(clifiles, "cli/"); std::vector testfiles; - FileLister::recursiveAddFiles(testfiles, "test/", true); + getCppFiles(testfiles, "test/"); std::ofstream fout("Makefile"); // more warnings.. -Wfloat-equal -Wcast-qual -Wsign-conversion -Wlogical-op fout << "CXXFLAGS=-Wall -Wextra -pedantic -g\n"; fout << "CXX=g++\n"; - fout << "BIN=${DESTDIR}/usr/bin\n\n"; - fout << "# For 'make man': sudo apt-get install xsltproc docbook-xsl docbook-xml\n"; - fout << "DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl\n"; - fout << "XP=xsltproc -''-nonet -''-param man.charmap.use.subset \"0\"\n"; - fout << "MAN_SOURCE=man/cppcheck.1.xml\n\n"; fout << "\n###### Object Files\n\n"; fout << "LIBOBJ = " << objfile(libfiles[0]); @@ -126,16 +135,15 @@ int main() fout << "\t$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(LDFLAGS)\n\n"; fout << "test:\tall\n"; fout << "\t./testrunner\n\n"; - fout << "tools:\ttools/dmake\n\n"; - fout << "tools/dmake:\ttools/dmake.cpp\tlib/filelister.cpp\tlib/filelister.h\n"; - fout << "\t$(CXX) $(CXXFLAGS) -o tools/dmake tools/dmake.cpp lib/filelister.cpp $(LDFLAGS)\n\n"; fout << "clean:\n"; - fout << "\trm -f lib/*.o cli/*.o test/*.o testrunner cppcheck tools/dmake\n\n"; - fout << "man:\t$(MAN_SOURCE)\n"; - fout << "\t$(XP) $(DB2MAN) $(MAN_SOURCE)\n\n"; - fout << "install:\tcppcheck\n"; - fout << "\tinstall -d ${BIN}\n"; - fout << "\tinstall cppcheck ${BIN}\n\n"; +#ifdef _WIN32 + fout << "\tdel lib\*.o\n" + << "\tdel cli\*.o\n" + << "\tdel test\*.o\n" + << "\tdel *.exe\n"; +#else + fout << "\trm -f lib/*.o cli/*.o test/*.o testrunner cppcheck\n\n"; +#endif fout << "\n###### Build\n\n";