cmark

My personal build of CMark ✏️

Commit
e1c590d3de3e519ef38d5abf48cef069e07a72a2
Parent
d6c615f2680e79bbb76cc85a056aadfe3524513f
Author
John MacFarlane <jgm@berkeley.edu>
Date

Merge pull request #297 from nwellnhof/makefile_fixes

Makefile fixes

Diffstat

2 files changed, 20 insertions, 13 deletions

Status File Name N° Changes Insertions Deletions
Modified Makefile 28 16 12
Modified README.md 5 4 1
diff --git 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,27 +13,31 @@ 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)
 RELEASE?=CommonMark-$(VERSION)
+INSTALL_PREFIX?=/usr/local
 
-.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
-	@echo "Binaries can be found in $(BUILDDIR)/src"
+all: cmake_build man/man3/cmark.3
+
+$(PROG): cmake_build
 
-$(PROG): $(BUILDDIR)
+cmake_build: $(BUILDDIR)
 	@make -j2 -C $(BUILDDIR)
+	@echo "Binaries can be found in $(BUILDDIR)/src"
 
-check:
+$(BUILDDIR):
 	@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)
+	cmake .. \
+		-G "$(GENERATOR)" \
+		-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
+		-DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX)
 
 install: $(BUILDDIR)
 	make -C $(BUILDDIR) install
@@ -76,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
diff --git 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,