diff --git a/Makefile b/Makefile index 5b4ee5b57..517b22f5b 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/lib/library.cpp b/lib/library.cpp index d8d32c5ca..550f6568f 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -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()); } } diff --git a/readme.md b/readme.md index 5d2dfffba..69838a53a 100644 --- a/readme.md +++ b/readme.md @@ -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: diff --git a/readme.txt b/readme.txt index 0df9c3eca..f1ccc1b3b 100644 --- a/readme.txt +++ b/readme.txt @@ -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) ================= diff --git a/tools/dmake.cpp b/tools/dmake.cpp index c0d2ca40f..a16a4de2a 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -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"