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