aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 7007dffc349066f323c834157afcc45cf80c5173 (plain)
  1. SRCDIR?=src
  2. DATADIR?=data
  3. BENCHINP?=README.md
  4. JSMODULES=$(wildcard js/lib/*.js)
  5. SPEC=spec.txt
  6. SITE=_site
  7. BUILDDIR=build
  8. FUZZCHARS?=2000000 # for fuzztest
  9. PROG?=$(BUILDDIR)/src/cmark
  10. .PHONY: all spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site check
  11. all: check
  12. mkdir -p $(BUILDDIR); cd build; cmake .. -DCMAKE_BUILD_TYPE=Release; make
  13. debug: check
  14. mkdir -p $(BUILDDIR); cd build; cmake .. -DCMAKE_BUILD_TYPE=Debug; make
  15. install: check man/man1/cmark.1
  16. mkdir -p $(BUILDDIR); cd build; cmake .. -DCMAKE_BUILD_TYPE=Release; make install
  17. clean:
  18. rm -rf $(BUILDDIR)
  19. check:
  20. @cmake --version >/dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1)
  21. $(PROG): all
  22. man/man1/cmark.1: man/cmark.1.md
  23. pandoc $< -o $@ -s -t man
  24. README.html: README.md template.html
  25. pandoc --template template.html -S -s -t html5 -o $@ $<
  26. spec: test spec.html
  27. spec.md: $(SPEC)
  28. perl spec2md.pl < $< > $@
  29. spec.html: spec.md template.html
  30. pandoc --no-highlight --number-sections --template template.html -s --toc -S $< | \
  31. perl -pe 's/a href="@([^"]*)"/a id="\1" href="#\1" class="definition"/g' | \
  32. perl -pe 's/␣/<span class="space"> <\/span>/g' \
  33. > $@
  34. spec.pdf: spec.md template.tex specfilter.hs
  35. pandoc -s $< --template template.tex \
  36. --filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \
  37. --number-sections -V documentclass=report -V tocdepth=2 \
  38. -V classoption=twosides
  39. test: $(SPEC)
  40. perl runtests.pl $< $(PROG)
  41. js/commonmark.js: js/lib/index.js ${JSMODULES}
  42. browserify --standalone commonmark $< -o $@
  43. testjs: $(SPEC)
  44. node js/test.js
  45. jshint:
  46. jshint ${JSMODULES}
  47. benchjs:
  48. node js/bench.js ${BENCHINP}
  49. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  50. perl mkcasefold.pl < $< > $@
  51. dingus: js/commonmark.js
  52. echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  53. leakcheck: $(PROG)
  54. cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG)
  55. operf: $(PROG)
  56. operf $(PROG) <$(BENCHINP) >/dev/null
  57. fuzztest:
  58. { for i in `seq 1 10`; do \
  59. cat /dev/urandom | head -c $(FUZZCHARS) | iconv -f latin1 -t utf-8 | tee fuzz-$$i.txt | \
  60. /usr/bin/env time -p $(PROG) >/dev/null && rm fuzz-$$i.txt ; \
  61. done } 2>&1 | grep 'user\|abnormally'
  62. update-site: spec.html js/commonmark.js
  63. make -C $(SITE) update
  64. upload-site: spec.html
  65. make -C $(SITE) upload
  66. distclean: clean
  67. -rm -f js/commonmark.js
  68. -rm -rf *.dSYM
  69. -rm -f README.html
  70. -rm -f spec.md fuzz.txt spec.html