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