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