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