Makefile: added option for compiling with/without rules
This commit is contained in:
parent
a9d8f456ee
commit
712e285bd6
16
Makefile
16
Makefile
|
@ -1,7 +1,17 @@
|
|||
# This file is generated by tools/dmake, do not edit.
|
||||
|
||||
# To compile without rules, use 'make HAVE_RULES=no'
|
||||
HAVE_RULES = yes
|
||||
|
||||
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
|
||||
|
||||
ifndef CXX
|
||||
|
@ -116,12 +126,12 @@ EXTOBJ += $(TINYXML)
|
|||
###### Targets
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
./testrunner
|
||||
|
|
|
@ -51,7 +51,7 @@ Compiling
|
|||
make
|
||||
|
||||
To build Cppcheck without rules (no dependencies):
|
||||
make CXXFLAGS="-O2"
|
||||
make HAVE_RULES=no
|
||||
|
||||
g++ (for experts)
|
||||
=================
|
||||
|
|
|
@ -217,11 +217,13 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
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..
|
||||
if (release)
|
||||
{
|
||||
makeConditionalVariable(fout, "CXXFLAGS", "-O2 -DNDEBUG -DHAVE_RULES -Wall");
|
||||
makeConditionalVariable(fout, "CXXFLAGS", "-O2 -DNDEBUG -Wall");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -232,7 +234,6 @@ int main(int argc, char **argv)
|
|||
|
||||
// The _GLIBCXX_DEBUG doesn't work in cygwin
|
||||
makeConditionalVariable(fout, "CXXFLAGS",
|
||||
"-DHAVE_RULES "
|
||||
"-Wall "
|
||||
"-Wextra "
|
||||
"-Wshadow "
|
||||
|
@ -244,6 +245,14 @@ int main(int argc, char **argv)
|
|||
// "-Wconversion "
|
||||
"-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, "PREFIX", "/usr");
|
||||
makeConditionalVariable(fout, "INCLUDE_FOR_LIB", "-Ilib");
|
||||
|
@ -274,10 +283,10 @@ int main(int argc, char **argv)
|
|||
|
||||
fout << "\n###### Targets\n\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 << "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 << "\t./testrunner\n\n";
|
||||
fout << "check:\tall\n";
|
||||
|
|
Loading…
Reference in New Issue