From a19dd1d73ece5384c87c42477eb36265f127015d Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 24 Jan 2015 16:08:13 +0100 Subject: Rework Makefile targets Since $(BUILDDIR) depended on the phony target "check", it was always considered out-of-date. So it was always rebuilt resulting in running the "cmake" command again even if it was already run. Add a new phony target "cmake_build" that always triggers the cmake build and make $(PROG) depend on it. Running "make" a second time now doesn't run cmake again. --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f9e0625..5c39be8 100644 --- a/Makefile +++ b/Makefile @@ -19,18 +19,18 @@ JSMODULES=$(wildcard js/lib/*.js) VERSION?=$(SPECVERSION) RELEASE?=CommonMark-$(VERSION) -.PHONY: all spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site check npm debug mingw archive tarball ziparchive testtarball testziparchive testlib bench astyle +.PHONY: all cmake_build spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site npm debug mingw archive tarball ziparchive testtarball testziparchive testlib bench astyle -all: $(PROG) man/man3/cmark.3 +all: cmake_build man/man3/cmark.3 @echo "Binaries can be found in $(BUILDDIR)/src" -$(PROG): $(BUILDDIR) +$(PROG): cmake_build + +cmake_build: $(BUILDDIR) @make -j2 -C $(BUILDDIR) -check: +$(BUILDDIR): $(SRCDIR)/html_unescape.h $(SRCDIR)/case_fold_switch.inc @cmake --version > /dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1) - -$(BUILDDIR): check $(SRCDIR)/html_unescape.h $(SRCDIR)/case_fold_switch.inc mkdir -p $(BUILDDIR); \ cd $(BUILDDIR); \ cmake .. -G "$(GENERATOR)" -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -- cgit v1.2.3 From 7df57aa10b1d31fd90887c238cfeeedaff700552 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 24 Jan 2015 16:21:19 +0100 Subject: Move message from "all" to "cmake_build" target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5c39be8..baa6859 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,12 @@ RELEASE?=CommonMark-$(VERSION) .PHONY: all cmake_build spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site npm debug mingw archive tarball ziparchive testtarball testziparchive testlib bench astyle all: cmake_build man/man3/cmark.3 - @echo "Binaries can be found in $(BUILDDIR)/src" $(PROG): cmake_build cmake_build: $(BUILDDIR) @make -j2 -C $(BUILDDIR) + @echo "Binaries can be found in $(BUILDDIR)/src" $(BUILDDIR): $(SRCDIR)/html_unescape.h $(SRCDIR)/case_fold_switch.inc @cmake --version > /dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1) -- cgit v1.2.3 From 10fc979567d23480f5a3e1fb8437d1a0fdd53c0b Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 24 Jan 2015 16:24:16 +0100 Subject: Pass INSTALL_PREFIX to cmake This allows to install to a location other than /usr/local without invoking cmake manually. --- Makefile | 6 +++++- README.md | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index baa6859..6f2af0c 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ BENCHINP?=README.md JSMODULES=$(wildcard js/lib/*.js) VERSION?=$(SPECVERSION) RELEASE?=CommonMark-$(VERSION) +INSTALL_PREFIX?=/usr/local .PHONY: all cmake_build spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site npm debug mingw archive tarball ziparchive testtarball testziparchive testlib bench astyle @@ -33,7 +34,10 @@ $(BUILDDIR): $(SRCDIR)/html_unescape.h $(SRCDIR)/case_fold_switch.inc @cmake --version > /dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1) mkdir -p $(BUILDDIR); \ cd $(BUILDDIR); \ - cmake .. -G "$(GENERATOR)" -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) + cmake .. \ + -G "$(GENERATOR)" \ + -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \ + -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX) install: $(BUILDDIR) make -C $(BUILDDIR) install diff --git a/README.md b/README.md index ca8246e..776d886 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,10 @@ the repository to reduce build dependencies. If you have GNU make, you can simply `make`, `make test`, and `make install`. This calls [cmake] to create a `Makefile` in the `build` directory, then uses that `Makefile` to create the executable and -library. The binaries can be found in `build/src`. +library. The binaries can be found in `build/src`. The default +installation prefix is `/usr/local`. To change the installation +prefix, pass the `INSTALL_PREFIX` variable if you run `make` for the +first time: `make INSTALL_PREFIX=path`. For a more portable method, you can use [cmake] manually. [cmake] knows how to create build environments for many build systems. For example, -- cgit v1.2.3 From 02a27877d3d388540ba7b6f24da5df908fad8934 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 24 Jan 2015 16:34:34 +0100 Subject: Make "test" target depend on "cmake_build" cmake doesn't (re)build the project if the tests are run. This change allows to run "make test" without having to run "make" before, for example after modifying source files or from a clean tree. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6f2af0c..c9f9021 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt $(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re re2c --case-insensitive -b -i --no-generation-date -o $@ $< -test: $(SPEC) $(BUILDDIR) +test: $(SPEC) cmake_build make -C $(BUILDDIR) test || (cat $(BUILDDIR)/Testing/Temporary/LastTest.log && exit 1) $(ALLTESTS): spec.txt -- cgit v1.2.3 From 0373cb433cdc80b55a43f097d2fd16b08056f638 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 24 Jan 2015 16:55:41 +0100 Subject: Remove dependencies from $(BUILDDIR) target There's no need to reconfigure if html_unescape.h or case_fold_switch.inc were changed. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c9f9021..758d61e 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ cmake_build: $(BUILDDIR) @make -j2 -C $(BUILDDIR) @echo "Binaries can be found in $(BUILDDIR)/src" -$(BUILDDIR): $(SRCDIR)/html_unescape.h $(SRCDIR)/case_fold_switch.inc +$(BUILDDIR): @cmake --version > /dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1) mkdir -p $(BUILDDIR); \ cd $(BUILDDIR); \ -- cgit v1.2.3 From a6018fad143774e5976b86b78e83afe055bd9879 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 24 Jan 2015 17:00:14 +0100 Subject: Prohibit overriding of some Makefile vars SRCDIR, DATADIR, and PROG should not be overridable. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 758d61e..59d55a9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -SRCDIR?=src -DATADIR?=data +SRCDIR=src +DATADIR=data BUILDDIR?=build GENERATOR?=Unix Makefiles MINGW_BUILDDIR?=build-mingw @@ -13,7 +13,7 @@ BENCHDIR=bench BENCHFILE=$(BENCHDIR)/benchinput.md ALLTESTS=alltests.md NUMRUNS?=10 -PROG?=$(BUILDDIR)/src/cmark +PROG=$(BUILDDIR)/src/cmark BENCHINP?=README.md JSMODULES=$(wildcard js/lib/*.js) VERSION?=$(SPECVERSION) -- cgit v1.2.3