Makefile: added option for compiling with/without rules

This commit is contained in:
Daniel Marjamäki 2011-04-19 20:53:40 +02:00
parent a9d8f456ee
commit 712e285bd6
3 changed files with 27 additions and 8 deletions

View File

@ -1,7 +1,17 @@
# This file is generated by tools/dmake, do not edit. # This file is generated by tools/dmake, do not edit.
# To compile without rules, use 'make HAVE_RULES=no'
HAVE_RULES = yes
ifndef CXXFLAGS ifndef CXXFLAGS
CXXFLAGS=-DHAVE_RULES -Wall -Wextra -Wshadow -pedantic -Wno-long-long -Wfloat-equal -Wcast-qual -g CXXFLAGS=-Wall -Wextra -Wshadow -pedantic -Wno-long-long -Wfloat-equal -Wcast-qual -g
endif
ifeq ($(HAVE_RULES),yes)
CXXFLAGS += -DHAVE_RULES
ifndef LDFLAGS
LDFLAGS=-lpcre
endif
endif endif
ifndef CXX ifndef CXX
@ -116,12 +126,12 @@ EXTOBJ += $(TINYXML)
###### Targets ###### Targets
cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ) cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre $(LDFLAGS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) $(LDFLAGS)
all: cppcheck testrunner all: cppcheck testrunner
testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS)
test: all test: all
./testrunner ./testrunner

View File

@ -51,7 +51,7 @@ Compiling
make make
To build Cppcheck without rules (no dependencies): To build Cppcheck without rules (no dependencies):
make CXXFLAGS="-O2" make HAVE_RULES=no
g++ (for experts) g++ (for experts)
================= =================

View File

@ -217,11 +217,13 @@ int main(int argc, char **argv)
} }
fout << "# This file is generated by tools/dmake, do not edit.\n\n"; fout << "# This file is generated by tools/dmake, do not edit.\n\n";
fout << "# To compile without rules, use 'make HAVE_RULES=no'\n"
<< "HAVE_RULES = yes\n\n";
// Makefile settings.. // Makefile settings..
if (release) if (release)
{ {
makeConditionalVariable(fout, "CXXFLAGS", "-O2 -DNDEBUG -DHAVE_RULES -Wall"); makeConditionalVariable(fout, "CXXFLAGS", "-O2 -DNDEBUG -Wall");
} }
else else
{ {
@ -232,7 +234,6 @@ int main(int argc, char **argv)
// The _GLIBCXX_DEBUG doesn't work in cygwin // The _GLIBCXX_DEBUG doesn't work in cygwin
makeConditionalVariable(fout, "CXXFLAGS", makeConditionalVariable(fout, "CXXFLAGS",
"-DHAVE_RULES "
"-Wall " "-Wall "
"-Wextra " "-Wextra "
"-Wshadow " "-Wshadow "
@ -244,6 +245,14 @@ int main(int argc, char **argv)
// "-Wconversion " // "-Wconversion "
"-g"); "-g");
} }
fout << "ifeq ($(HAVE_RULES),yes)\n"
<< " CXXFLAGS += -DHAVE_RULES\n"
<< " ifndef LDFLAGS\n"
<< " LDFLAGS=-lpcre\n"
<< " endif\n"
<< "endif\n\n";
makeConditionalVariable(fout, "CXX", "g++"); makeConditionalVariable(fout, "CXX", "g++");
makeConditionalVariable(fout, "PREFIX", "/usr"); makeConditionalVariable(fout, "PREFIX", "/usr");
makeConditionalVariable(fout, "INCLUDE_FOR_LIB", "-Ilib"); makeConditionalVariable(fout, "INCLUDE_FOR_LIB", "-Ilib");
@ -274,10 +283,10 @@ int main(int argc, char **argv)
fout << "\n###### Targets\n\n"; fout << "\n###### Targets\n\n";
fout << "cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)\n"; fout << "cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)\n";
fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre $(LDFLAGS)\n\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) $(LDFLAGS)\n\n";
fout << "all:\tcppcheck testrunner\n\n"; fout << "all:\tcppcheck testrunner\n\n";
fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o\n"; fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o\n";
fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS)\n\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS)\n\n";
fout << "test:\tall\n"; fout << "test:\tall\n";
fout << "\t./testrunner\n\n"; fout << "\t./testrunner\n\n";
fout << "check:\tall\n"; fout << "check:\tall\n";