Makefile: Added optional CFGDIR parameter that allows user to specify where Cppcheck will look for cfg files.

This commit is contained in:
Daniel Marjamäki 2013-12-26 18:41:51 +01:00
parent 367078e1bb
commit d3a848f2e6
5 changed files with 36 additions and 16 deletions

View File

@ -57,6 +57,10 @@ ifndef CXXFLAGS
CXXFLAGS=-pedantic -Wall -Wextra -Wabi -Wcast-qual -Wconversion -Wfloat-equal -Winline -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Woverloaded-virtual -Wpacked -Wredundant-decls -Wshadow -Wsign-promo $(CPPCHK_GLIBCXX_DEBUG) -g
endif
ifdef CFGDIR
CXXFLAGS += -DCFGDIR=\"$(CFGDIR)\"
endif
ifeq ($(HAVE_RULES),yes)
CXXFLAGS += -DHAVE_RULES -DTIXML_USE_STL $(shell pcre-config --cflags)
ifdef LIBS

View File

@ -58,8 +58,13 @@ bool Library::load(const char exename[], const char path[])
if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) {
// Try to locate the library configuration in the installation folder..
const std::string installfolder = Path::fromNativeSeparators(Path::getPathFromFilename(exename));
const std::string filename = installfolder + "cfg/" + fullfilename;
#ifdef CFGDIR
const std::string cfgfolder(CFGDIR);
#else
const std::string cfgfolder(Path::fromNativeSeparators(Path::getPathFromFilename(exename)) + "cfg");
#endif
const char *sep = (!cfgfolder.empty() && cfgfolder[cfgfolder.size()-1U]=='/' ? "" : "/");
const std::string filename(cfgfolder + sep + fullfilename);
error = doc.LoadFile(filename.c_str());
}
}

View File

@ -60,18 +60,23 @@ http://software-download.name/pcre-library-windows/
### gnu make
To build Cppcheck with rules (PCRE dependency):
```shell
make HAVE_RULES=yes
```
To build Cppcheck without rules (no dependencies):
Simple build (no dependencies):
```shell
make
```
The recommended release build is:
```shell
make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes
```
Flags:
SRCDIR=build : Python is used to optimise cppcheck
CFGDIR=cfg : Specify folder where .cfg files are found
HAVE_RULES=yes : Enable rules (pcre is required if this is used)
### g++ (for experts)
If you just want to build Cppcheck without dependencies then you can use this command:

View File

@ -54,15 +54,16 @@ Compiling
gnu make
========
To build Cppcheck with rules (pcre dependency):
make HAVE_RULES=yes
To build Cppcheck without rules (no dependencies):
Simple build (no dependencies):
make
If you have python it is recommended that you add "SRCDIR=build". When
that is used, the Makefile uses python to compile Cppcheck (but python
is not used at runtime). The advantage is that it makes Cppcheck faster.
The recommended release build is:
make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes
Flags:
SRCDIR=build : Python is used to optimise cppcheck
CFGDIR=cfg : Specify folder where .cfg files are found
HAVE_RULES=yes : Enable rules (pcre is required if this is used)
g++ (for experts)
=================

View File

@ -313,6 +313,11 @@ int main(int argc, char **argv)
"-g");
}
// explicit cfg dir..
fout << "ifdef CFGDIR\n"
<< " CXXFLAGS += -DCFGDIR=\\\"$(CFGDIR)\\\"\n"
<< "endif\n\n";
fout << "ifeq ($(HAVE_RULES),yes)\n"
<< " CXXFLAGS += -DHAVE_RULES -DTIXML_USE_STL $(shell pcre-config --cflags)\n"
<< " ifdef LIBS\n"