aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 0fe777e238378f54db518bdc4624a6750a9aef60 (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. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  38. perl mkcasefold.pl < $< > $@
  39. man/man1/cmark.1: man/cmark.1.md
  40. pandoc $< -o $@ -s -t man
  41. README.html: README.md template.html
  42. pandoc --template template.html -S -s -t html5 -o $@ $<
  43. spec: test spec.html
  44. spec.md: $(SPEC)
  45. perl spec2md.pl < $< > $@
  46. spec.html: spec.md template.html
  47. pandoc --no-highlight --number-sections --template template.html -s --toc -S $< | \
  48. perl -pe 's/a href="@([^"]*)"/a id="\1" href="#\1" class="definition"/g' | \
  49. perl -pe 's/␣/<span class="space"> <\/span>/g' \
  50. > $@
  51. spec.pdf: spec.md template.tex specfilter.hs
  52. pandoc -s $< --template template.tex \
  53. --filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \
  54. --number-sections -V documentclass=report -V tocdepth=2 \
  55. -V classoption=twosides
  56. test: $(SPEC)
  57. perl runtests.pl $< $(PROG)
  58. testlib: $(SPEC)
  59. perl runtests.pl $< ./wrapper.py
  60. leakcheck: $(PROG)
  61. cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG)
  62. fuzztest:
  63. { for i in `seq 1 10`; do \
  64. cat /dev/urandom | head -c $(FUZZCHARS) | iconv -f latin1 -t utf-8 | tee fuzz-$$i.txt | \
  65. /usr/bin/env time -p $(PROG) >/dev/null && rm fuzz-$$i.txt ; \
  66. done } 2>&1 | grep 'user\|abnormally'
  67. operf: $(PROG)
  68. operf $(PROG) <$(BENCHINP) >/dev/null
  69. distclean: clean
  70. -rm -f js/commonmark.js
  71. -rm -rf *.dSYM
  72. -rm -f README.html
  73. -rm -f spec.md fuzz.txt spec.html
  74. ### JavaScript ###
  75. js/commonmark.js: js/lib/index.js ${JSMODULES}
  76. browserify --standalone commonmark $< -o $@
  77. testjs: $(SPEC)
  78. node js/test.js
  79. jshint:
  80. jshint ${JSMODULES}
  81. benchjs:
  82. node js/bench.js ${BENCHINP}
  83. npm:
  84. cd js; npm publish
  85. dingus: js/commonmark.js
  86. echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  87. ### Website ###
  88. update-site: spec.html js/commonmark.js
  89. make -C $(SITE) update
  90. upload-site: spec.html
  91. make -C $(SITE) upload