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