Skip to content

Commit

Permalink
Makefile: added option for compiling with/without rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Marjamäki committed Apr 19, 2011
1 parent a9d8f45 commit 712e285
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Compiling
make

To build Cppcheck without rules (no dependencies):
make CXXFLAGS="-O2"
make HAVE_RULES=no

g++ (for experts)
=================
Expand Down
17 changes: 13 additions & 4 deletions tools/dmake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 "
Expand All @@ -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");
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 712e285

Please sign in to comment.