Revert "removed tools/dmake and Makefile. Please use cmake from now on."
This reverts commit cfacd5fe10
.
This commit is contained in:
parent
fb10396cb3
commit
744c385097
|
@ -0,0 +1,235 @@
|
||||||
|
CXXFLAGS=-Wall -Wextra -pedantic -g
|
||||||
|
CXX=g++
|
||||||
|
BIN=${DESTDIR}/usr/bin
|
||||||
|
|
||||||
|
# For 'make man': sudo apt-get install xsltproc docbook-xsl docbook-xml
|
||||||
|
DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
|
||||||
|
XP=xsltproc -''-nonet -''-param man.charmap.use.subset "0"
|
||||||
|
MAN_SOURCE=man/cppcheck.1.xml
|
||||||
|
|
||||||
|
|
||||||
|
###### Object Files
|
||||||
|
|
||||||
|
LIBOBJ = lib/checkautovariables.o \
|
||||||
|
lib/checkbufferoverrun.o \
|
||||||
|
lib/checkclass.o \
|
||||||
|
lib/checkdangerousfunctions.o \
|
||||||
|
lib/checkexceptionsafety.o \
|
||||||
|
lib/checkheaders.o \
|
||||||
|
lib/checkmemoryleak.o \
|
||||||
|
lib/checkother.o \
|
||||||
|
lib/checkstl.o \
|
||||||
|
lib/checkunusedfunctions.o \
|
||||||
|
lib/cppcheck.o \
|
||||||
|
lib/errorlogger.o \
|
||||||
|
lib/executionpath.o \
|
||||||
|
lib/filelister.o \
|
||||||
|
lib/mathlib.o \
|
||||||
|
lib/preprocessor.o \
|
||||||
|
lib/settings.o \
|
||||||
|
lib/token.o \
|
||||||
|
lib/tokenize.o
|
||||||
|
|
||||||
|
CLIOBJ = cli/cppcheckexecutor.o \
|
||||||
|
cli/main.o \
|
||||||
|
cli/threadexecutor.o
|
||||||
|
|
||||||
|
TESTOBJ = test/testautovariables.o \
|
||||||
|
test/testbufferoverrun.o \
|
||||||
|
test/testcharvar.o \
|
||||||
|
test/testclass.o \
|
||||||
|
test/testconstructors.o \
|
||||||
|
test/testcppcheck.o \
|
||||||
|
test/testdangerousfunctions.o \
|
||||||
|
test/testdivision.o \
|
||||||
|
test/testexceptionsafety.o \
|
||||||
|
test/testfilelister.o \
|
||||||
|
test/testincompletestatement.o \
|
||||||
|
test/testmathlib.o \
|
||||||
|
test/testmemleak.o \
|
||||||
|
test/testother.o \
|
||||||
|
test/testpreprocessor.o \
|
||||||
|
test/testredundantif.o \
|
||||||
|
test/testrunner.o \
|
||||||
|
test/testsimplifytokens.o \
|
||||||
|
test/teststl.o \
|
||||||
|
test/testsuite.o \
|
||||||
|
test/testtoken.o \
|
||||||
|
test/testtokenize.o \
|
||||||
|
test/testunusedfunctions.o \
|
||||||
|
test/testunusedprivfunc.o \
|
||||||
|
test/testunusedvar.o
|
||||||
|
|
||||||
|
|
||||||
|
###### Targets
|
||||||
|
|
||||||
|
cppcheck: $(LIBOBJ) $(CLIOBJ)
|
||||||
|
$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(LDFLAGS)
|
||||||
|
|
||||||
|
all: cppcheck testrunner tools
|
||||||
|
|
||||||
|
testrunner: $(TESTOBJ) $(LIBOBJ)
|
||||||
|
$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(LDFLAGS)
|
||||||
|
|
||||||
|
test: all
|
||||||
|
./testrunner
|
||||||
|
|
||||||
|
tools: tools/dmake
|
||||||
|
|
||||||
|
tools/dmake: tools/dmake.cpp lib/filelister.cpp lib/filelister.h
|
||||||
|
$(CXX) $(CXXFLAGS) -o tools/dmake tools/dmake.cpp lib/filelister.cpp $(LDFLAGS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f lib/*.o cli/*.o test/*.o testrunner cppcheck tools/dmake
|
||||||
|
|
||||||
|
man: $(MAN_SOURCE)
|
||||||
|
$(XP) $(DB2MAN) $(MAN_SOURCE)
|
||||||
|
|
||||||
|
install: cppcheck
|
||||||
|
install -d ${BIN}
|
||||||
|
install cppcheck ${BIN}
|
||||||
|
|
||||||
|
|
||||||
|
###### Build
|
||||||
|
|
||||||
|
lib/checkautovariables.o: lib/checkautovariables.cpp lib/checkautovariables.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkautovariables.o lib/checkautovariables.cpp
|
||||||
|
|
||||||
|
lib/checkbufferoverrun.o: lib/checkbufferoverrun.cpp lib/checkbufferoverrun.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h lib/mathlib.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkbufferoverrun.o lib/checkbufferoverrun.cpp
|
||||||
|
|
||||||
|
lib/checkclass.o: lib/checkclass.cpp lib/checkclass.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkclass.o lib/checkclass.cpp
|
||||||
|
|
||||||
|
lib/checkdangerousfunctions.o: lib/checkdangerousfunctions.cpp lib/checkdangerousfunctions.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkdangerousfunctions.o lib/checkdangerousfunctions.cpp
|
||||||
|
|
||||||
|
lib/checkexceptionsafety.o: lib/checkexceptionsafety.cpp lib/checkexceptionsafety.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkexceptionsafety.o lib/checkexceptionsafety.cpp
|
||||||
|
|
||||||
|
lib/checkheaders.o: lib/checkheaders.cpp lib/checkheaders.h lib/tokenize.h lib/classinfo.h lib/token.h lib/errorlogger.h lib/settings.h lib/filelister.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkheaders.o lib/checkheaders.cpp
|
||||||
|
|
||||||
|
lib/checkmemoryleak.o: lib/checkmemoryleak.cpp lib/checkmemoryleak.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h lib/mathlib.h lib/executionpath.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkmemoryleak.o lib/checkmemoryleak.cpp
|
||||||
|
|
||||||
|
lib/checkother.o: lib/checkother.cpp lib/checkother.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h lib/mathlib.h lib/executionpath.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkother.o lib/checkother.cpp
|
||||||
|
|
||||||
|
lib/checkstl.o: lib/checkstl.cpp lib/checkstl.h lib/check.h lib/token.h lib/tokenize.h lib/classinfo.h lib/settings.h lib/errorlogger.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkstl.o lib/checkstl.cpp
|
||||||
|
|
||||||
|
lib/checkunusedfunctions.o: lib/checkunusedfunctions.cpp lib/checkunusedfunctions.h lib/tokenize.h lib/classinfo.h lib/token.h lib/errorlogger.h lib/settings.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/checkunusedfunctions.o lib/checkunusedfunctions.cpp
|
||||||
|
|
||||||
|
lib/cppcheck.o: lib/cppcheck.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/tokenize.h lib/classinfo.h lib/token.h lib/preprocessor.h lib/filelister.h lib/check.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/cppcheck.o lib/cppcheck.cpp
|
||||||
|
|
||||||
|
lib/errorlogger.o: lib/errorlogger.cpp lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/errorlogger.o lib/errorlogger.cpp
|
||||||
|
|
||||||
|
lib/executionpath.o: lib/executionpath.cpp lib/executionpath.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/executionpath.o lib/executionpath.cpp
|
||||||
|
|
||||||
|
lib/filelister.o: lib/filelister.cpp lib/filelister.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/filelister.o lib/filelister.cpp
|
||||||
|
|
||||||
|
lib/mathlib.o: lib/mathlib.cpp lib/mathlib.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/mathlib.o lib/mathlib.cpp
|
||||||
|
|
||||||
|
lib/preprocessor.o: lib/preprocessor.cpp lib/preprocessor.h lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h lib/filelister.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/preprocessor.o lib/preprocessor.cpp
|
||||||
|
|
||||||
|
lib/settings.o: lib/settings.cpp lib/settings.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/settings.o lib/settings.cpp
|
||||||
|
|
||||||
|
lib/token.o: lib/token.cpp lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/token.o lib/token.cpp
|
||||||
|
|
||||||
|
lib/tokenize.o: lib/tokenize.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/filelister.h lib/mathlib.h lib/settings.h lib/errorlogger.h lib/check.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/tokenize.o lib/tokenize.cpp
|
||||||
|
|
||||||
|
cli/cppcheckexecutor.o: cli/cppcheckexecutor.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h lib/cppcheck.h lib/checkunusedfunctions.h lib/tokenize.h lib/classinfo.h lib/token.h cli/threadexecutor.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o cli/cppcheckexecutor.o cli/cppcheckexecutor.cpp
|
||||||
|
|
||||||
|
cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o cli/main.o cli/main.cpp
|
||||||
|
|
||||||
|
cli/threadexecutor.o: cli/threadexecutor.cpp cli/threadexecutor.h lib/settings.h lib/errorlogger.h lib/cppcheck.h lib/checkunusedfunctions.h lib/tokenize.h lib/classinfo.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o cli/threadexecutor.o cli/threadexecutor.cpp
|
||||||
|
|
||||||
|
test/testautovariables.o: test/testautovariables.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkautovariables.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testautovariables.o test/testautovariables.cpp
|
||||||
|
|
||||||
|
test/testbufferoverrun.o: test/testbufferoverrun.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkbufferoverrun.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testbufferoverrun.o test/testbufferoverrun.cpp
|
||||||
|
|
||||||
|
test/testcharvar.o: test/testcharvar.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkother.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testcharvar.o test/testcharvar.cpp
|
||||||
|
|
||||||
|
test/testclass.o: test/testclass.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkclass.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testclass.o test/testclass.cpp
|
||||||
|
|
||||||
|
test/testconstructors.o: test/testconstructors.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkclass.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testconstructors.o test/testconstructors.cpp
|
||||||
|
|
||||||
|
test/testcppcheck.o: test/testcppcheck.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/tokenize.h lib/classinfo.h lib/token.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testcppcheck.o test/testcppcheck.cpp
|
||||||
|
|
||||||
|
test/testdangerousfunctions.o: test/testdangerousfunctions.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkdangerousfunctions.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testdangerousfunctions.o test/testdangerousfunctions.cpp
|
||||||
|
|
||||||
|
test/testdivision.o: test/testdivision.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkother.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testdivision.o test/testdivision.cpp
|
||||||
|
|
||||||
|
test/testexceptionsafety.o: test/testexceptionsafety.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkexceptionsafety.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testexceptionsafety.o test/testexceptionsafety.cpp
|
||||||
|
|
||||||
|
test/testfilelister.o: test/testfilelister.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/filelister.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testfilelister.o test/testfilelister.cpp
|
||||||
|
|
||||||
|
test/testincompletestatement.o: test/testincompletestatement.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h lib/checkother.h lib/check.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testincompletestatement.o test/testincompletestatement.cpp
|
||||||
|
|
||||||
|
test/testmathlib.o: test/testmathlib.cpp lib/mathlib.h lib/token.h test/testsuite.h lib/errorlogger.h lib/settings.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testmathlib.o test/testmathlib.cpp
|
||||||
|
|
||||||
|
test/testmemleak.o: test/testmemleak.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkmemoryleak.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testmemleak.o test/testmemleak.cpp
|
||||||
|
|
||||||
|
test/testother.o: test/testother.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkother.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testother.o test/testother.cpp
|
||||||
|
|
||||||
|
test/testpreprocessor.o: test/testpreprocessor.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/preprocessor.h lib/tokenize.h lib/classinfo.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testpreprocessor.o test/testpreprocessor.cpp
|
||||||
|
|
||||||
|
test/testredundantif.o: test/testredundantif.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkother.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testredundantif.o test/testredundantif.cpp
|
||||||
|
|
||||||
|
test/testrunner.o: test/testrunner.cpp test/testsuite.h lib/errorlogger.h lib/settings.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testrunner.o test/testrunner.cpp
|
||||||
|
|
||||||
|
test/testsimplifytokens.o: test/testsimplifytokens.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testsimplifytokens.o test/testsimplifytokens.cpp
|
||||||
|
|
||||||
|
test/teststl.o: test/teststl.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkstl.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/teststl.o test/teststl.cpp
|
||||||
|
|
||||||
|
test/testsuite.o: test/testsuite.cpp test/testsuite.h lib/errorlogger.h lib/settings.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testsuite.o test/testsuite.cpp
|
||||||
|
|
||||||
|
test/testtoken.o: test/testtoken.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testtoken.o test/testtoken.cpp
|
||||||
|
|
||||||
|
test/testtokenize.o: test/testtokenize.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testtokenize.o test/testtokenize.cpp
|
||||||
|
|
||||||
|
test/testunusedfunctions.o: test/testunusedfunctions.cpp lib/tokenize.h lib/classinfo.h lib/token.h test/testsuite.h lib/errorlogger.h lib/settings.h lib/checkunusedfunctions.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testunusedfunctions.o test/testunusedfunctions.cpp
|
||||||
|
|
||||||
|
test/testunusedprivfunc.o: test/testunusedprivfunc.cpp lib/tokenize.h lib/classinfo.h lib/token.h lib/checkclass.h lib/check.h lib/settings.h lib/errorlogger.h test/testsuite.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testunusedprivfunc.o test/testunusedprivfunc.cpp
|
||||||
|
|
||||||
|
test/testunusedvar.o: test/testunusedvar.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h lib/checkother.h lib/check.h
|
||||||
|
$(CXX) $(CXXFLAGS) -Ilib -c -o test/testunusedvar.o test/testunusedvar.cpp
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
* Cppcheck - A tool for static C/C++ code analysis
|
||||||
|
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Generate Makefile for cppcheck
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "../lib/filelister.h"
|
||||||
|
|
||||||
|
std::string objfile(std::string cppfile)
|
||||||
|
{
|
||||||
|
cppfile.erase(cppfile.rfind("."));
|
||||||
|
return cppfile + ".o";
|
||||||
|
}
|
||||||
|
|
||||||
|
void getDeps(const std::string &filename, std::vector<std::string> &depfiles)
|
||||||
|
{
|
||||||
|
// Is the dependency already included?
|
||||||
|
if (std::find(depfiles.begin(), depfiles.end(), filename) != depfiles.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::ifstream f(filename.c_str());
|
||||||
|
if (! f.is_open())
|
||||||
|
{
|
||||||
|
if (filename.compare(0, 4, "cli/") == 0 || filename.compare(0, 5, "test/") == 0)
|
||||||
|
getDeps("lib" + filename.substr(filename.find("/")), depfiles);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (filename.find(".c") == std::string::npos)
|
||||||
|
depfiles.push_back(filename);
|
||||||
|
|
||||||
|
std::string path(filename);
|
||||||
|
if (path.find("/") != std::string::npos)
|
||||||
|
path.erase(1 + path.rfind("/"));
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(f, line))
|
||||||
|
{
|
||||||
|
std::string::size_type pos1 = line.find("#include \"");
|
||||||
|
if (pos1 == std::string::npos)
|
||||||
|
continue;
|
||||||
|
pos1 += 10;
|
||||||
|
|
||||||
|
std::string::size_type pos2 = line.find("\"", pos1);
|
||||||
|
std::string hfile(path + line.substr(pos1, pos2 - pos1));
|
||||||
|
if (hfile.find("/../") != std::string::npos) // TODO: Ugly fix
|
||||||
|
hfile.erase(0, 4 + hfile.find("/../"));
|
||||||
|
getDeps(hfile, depfiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void compilefiles(std::ostream &fout, const std::vector<std::string> &files)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < files.size(); ++i)
|
||||||
|
{
|
||||||
|
fout << objfile(files[i]) << ": " << files[i];
|
||||||
|
std::vector<std::string> depfiles;
|
||||||
|
getDeps(files[i], depfiles);
|
||||||
|
for (unsigned int dep = 0; dep < depfiles.size(); ++dep)
|
||||||
|
fout << " " << depfiles[dep];
|
||||||
|
fout << "\n\t$(CXX) $(CXXFLAGS) -Ilib -c -o " << objfile(files[i]) << " " << files[i] << "\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Get files..
|
||||||
|
std::vector<std::string> libfiles;
|
||||||
|
FileLister::recursiveAddFiles(libfiles, "lib/", true);
|
||||||
|
|
||||||
|
std::vector<std::string> clifiles;
|
||||||
|
FileLister::recursiveAddFiles(clifiles, "cli/", true);
|
||||||
|
|
||||||
|
std::vector<std::string> testfiles;
|
||||||
|
FileLister::recursiveAddFiles(testfiles, "test/", true);
|
||||||
|
|
||||||
|
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]);
|
||||||
|
for (unsigned int i = 1; i < libfiles.size(); ++i)
|
||||||
|
fout << " \\" << std::endl << std::string(14, ' ') << objfile(libfiles[i]);
|
||||||
|
fout << "\n\n";
|
||||||
|
fout << "CLIOBJ = " << objfile(clifiles[0]);
|
||||||
|
for (unsigned int i = 1; i < clifiles.size(); ++i)
|
||||||
|
fout << " \\" << std::endl << std::string(14, ' ') << objfile(clifiles[i]);
|
||||||
|
fout << "\n\n";
|
||||||
|
fout << "TESTOBJ = " << objfile(testfiles[0]);
|
||||||
|
for (unsigned int i = 1; i < testfiles.size(); ++i)
|
||||||
|
fout << " \\" << std::endl << std::string(14, ' ') << objfile(testfiles[i]);
|
||||||
|
fout << "\n\n";
|
||||||
|
|
||||||
|
|
||||||
|
fout << "\n###### Targets\n\n";
|
||||||
|
fout << "cppcheck:\t$(LIBOBJ)\t$(CLIOBJ)\n";
|
||||||
|
fout << "\t$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(LDFLAGS)\n\n";
|
||||||
|
fout << "all:\tcppcheck\ttestrunner\ttools\n\n";
|
||||||
|
fout << "testrunner:\t$(TESTOBJ)\t$(LIBOBJ)\n";
|
||||||
|
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";
|
||||||
|
|
||||||
|
fout << "\n###### Build\n\n";
|
||||||
|
|
||||||
|
compilefiles(fout, libfiles);
|
||||||
|
compilefiles(fout, clifiles);
|
||||||
|
compilefiles(fout, testfiles);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue