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