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