aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 5f9cb34d2cfb6eac7cc36de083e02c9d48af1070 (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. spec.pdf: spec.md template.tex specfilter.hs
  32. pandoc -s $< --template template.tex \
  33. --filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \
  34. --number-sections -V documentclass=report -V tocdepth=2 \
  35. -V classoption=twosides
  36. test: $(SPEC)
  37. perl runtests.pl $< $(PROG)
  38. js/commonmark.js: js/lib/index.js ${JSMODULES}
  39. browserify --standalone commonmark $< -o $@
  40. testjs: $(SPEC)
  41. node js/test.js
  42. jshint:
  43. jshint ${JSMODULES}
  44. benchjs:
  45. node js/bench.js ${BENCHINP}
  46. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  47. perl mkcasefold.pl < $< > $@
  48. dingus: js/commonmark.js
  49. echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  50. leakcheck: $(PROG)
  51. cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG)
  52. operf: $(PROG)
  53. operf $(PROG) <$(BENCHINP) >/dev/null
  54. fuzztest:
  55. { for i in `seq 1 10`; do \
  56. cat /dev/urandom | head -c $(FUZZCHARS) | iconv -f latin1 -t utf-8 | tee fuzz-$$i.txt | \
  57. /usr/bin/env time -p $(PROG) >/dev/null && rm fuzz-$$i.txt ; \
  58. done } 2>&1 | grep user
  59. update-site: spec.html
  60. make -C $(SITE) update
  61. upload-site: spec.html
  62. make -C $(SITE) upload
  63. distclean: clean
  64. -rm -f js/commonmark.js
  65. -rm -rf *.dSYM
  66. -rm -f README.html
  67. -rm -f spec.md fuzz.txt spec.html