aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 0e14161b7149381ad6279af7138aaba13979ba26 (plain)
  1. CFLAGS?=--O3 -Wall -Wextra -std=c99 -Isrc -Wno-missing-field-initializers $(OPTFLAGS)
  2. LDFLAGS?=-g -O3 -Wall -Werror
  3. SRCDIR?=src
  4. DATADIR?=data
  5. BENCHINP?=bench.md
  6. PROG?=./cmark
  7. JSMODULES=$(wildcard js/lib/*.js)
  8. .PHONY: all test spec benchjs testjs
  9. all: $(SRCDIR)/case_fold_switch.inc $(PROG)
  10. README.html: README.md template.html
  11. pandoc --template template.html -S -s -t html5 -o $@ $<
  12. spec: test spec.html
  13. spec.md: spec.txt
  14. perl spec2md.pl < $< > $@
  15. spec.html: spec.md template.html
  16. pandoc --no-highlight --number-sections --template template.html -s --toc -S $< > $@ # | perl -pe 's/␣/<span class="space"> <\/span>/g' > $@
  17. narrative.html: narrative.md template.html
  18. pandoc --template template.html -s -S $< -o $@
  19. spec.pdf: spec.md template.tex specfilter.hs
  20. pandoc -s $< --template template.tex \
  21. --filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \
  22. --number-sections -V documentclass=report -V tocdepth=2 \
  23. -V classoption=twosides
  24. test: spec.txt
  25. perl runtests.pl $< $(PROG)
  26. js/stmd.js: js/lib/index.js ${JSMODULES}
  27. browserify --standalone stmd $< -o $@
  28. testjs: spec.txt
  29. node js/test.js
  30. jshint:
  31. jshint ${JSMODULES}
  32. benchjs:
  33. node js/bench.js ${BENCHINP}
  34. HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o
  35. CMARK_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.c
  36. $(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
  37. $(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
  38. $(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
  39. re2c --case-insensitive -bis $< > $@ || (rm $@ && false)
  40. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  41. perl mkcasefold.pl < $< > $@
  42. $(SRCDIR)/html/html_unescape.h: $(SRCDIR)/html/html_unescape.gperf
  43. gperf -I -t -N find_entity -H hash_entity -K entity -C -l --null-strings -m5 $< > $@
  44. .PHONY: leakcheck clean fuzztest dingus upload jshint test testjs benchjs
  45. dingus: js/stmd.js
  46. cd js && echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  47. leakcheck: $(PROG)
  48. cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG)
  49. operf: $(PROG)
  50. operf $(PROG) <bench.md >/dev/null
  51. fuzztest:
  52. for i in `seq 1 10`; do \
  53. time cat /dev/urandom | head -c 100000 | iconv -f latin1 -t utf-8 | $(PROG) >/dev/null; done
  54. update-site: spec.html narrative.html js/stmd.js
  55. cp spec.html _site/
  56. cp narrative.html _site/index.html
  57. cp -r js/* _site/js/
  58. (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, narrative, js" ; git push; cd ..)
  59. clean:
  60. -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o
  61. -rm js/stmd.js
  62. -rm -rf *.dSYM
  63. -rm -f README.html
  64. -rm -f spec.md fuzz.txt spec.html