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