aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: be45867dd42db5aa82f4f8617f3aa6d2677df0e0 (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. PKGDIR=cmark-$(SPECVERSION)
  8. BUILDDIR=build
  9. FUZZCHARS?=2000000 # for fuzztest
  10. PROG?=$(BUILDDIR)/src/cmark
  11. SPECVERSION=$(shell grep version: $(SPEC) | sed -e 's/version: *//')
  12. .PHONY: all spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site check npm debug tarball
  13. all: $(BUILDDIR)
  14. @make -C $(BUILDDIR)
  15. check:
  16. @cmake --version > /dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1)
  17. $(BUILDDIR): check
  18. mkdir -p $(BUILDDIR); \
  19. cd $(BUILDDIR); \
  20. cmake .. -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
  21. install: $(BUILDDIR) man/man1/cmark.1
  22. make -p $(BUILDDIR) --target install
  23. debug:
  24. mkdir -p $(BUILDDIR); \
  25. cd $(BUILDDIR); \
  26. cmake .. -DCMAKE_BUILD_TYPE=Debug; \
  27. make
  28. tarball: spec.html
  29. rm -rf $(PKGDIR); \
  30. mkdir -p $(PKGDIR)/man/man1; \
  31. cp -r src $(PKGDIR)/; \
  32. cp spec.html $(PKGDIR); \
  33. cp CMakeLists.txt $(PKGDIR); \
  34. perl -ne '$$p++ if /^### JavaScript/; print if (!$$p)' Makefile > $(PKGDIR)/Makefile; \
  35. cp man/man1/cmark.1 $(PKGDIR)/man/man1/; \
  36. cp README.md LICENSE spec.txt runtests.pl $(PKGDIR)/; \
  37. tar czf cmark-$(SPECVERSION).tar.gz $(PKGDIR); \
  38. rm -rf $(PKGDIR)
  39. clean:
  40. rm -rf $(BUILDDIR)
  41. $(PROG): all
  42. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  43. perl mkcasefold.pl < $< > $@
  44. man/man1/cmark.1: man/cmark.1.md
  45. pandoc $< -o $@ -s -t man
  46. test: $(SPEC)
  47. perl runtests.pl $< $(PROG)
  48. testlib: $(SPEC)
  49. perl runtests.pl $< ./wrapper.py
  50. leakcheck: $(PROG)
  51. cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG)
  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\|abnormally'
  57. operf: $(PROG)
  58. operf $(PROG) <$(BENCHINP) >/dev/null
  59. distclean: clean
  60. -rm -f js/commonmark.js
  61. -rm -rf *.dSYM
  62. -rm -f README.html
  63. -rm -f spec.md fuzz.txt spec.html
  64. ### JavaScript ###
  65. js/commonmark.js: js/lib/index.js ${JSMODULES}
  66. browserify --standalone commonmark $< -o $@
  67. testjs: $(SPEC)
  68. node js/test.js
  69. jshint:
  70. jshint ${JSMODULES}
  71. benchjs:
  72. node js/bench.js ${BENCHINP}
  73. npm:
  74. cd js; npm publish
  75. dingus: js/commonmark.js
  76. echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  77. ### Spec ###
  78. spec.md: $(SPEC)
  79. perl spec2md.pl < $< > $@
  80. spec.html: spec.md template.html
  81. pandoc --no-highlight --number-sections --template template.html -s --toc -S $< | \
  82. perl -pe 's/a href="@([^"]*)"/a id="\1" href="#\1" class="definition"/g' | \
  83. perl -pe 's/␣/<span class="space"> <\/span>/g' \
  84. > $@
  85. spec.pdf: spec.md template.tex specfilter.hs
  86. pandoc -s $< --template template.tex \
  87. --filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \
  88. --number-sections -V documentclass=report -V tocdepth=2 \
  89. -V classoption=twosides
  90. ### Website ###
  91. update-site: spec.html js/commonmark.js
  92. make -C $(SITE) update
  93. upload-site: spec.html
  94. make -C $(SITE) upload