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