aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 671d30dd87439bafe1becd4cfeda2afd453e5fd8 (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 oldtests 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. oldtests:
  23. make -C oldtests --quiet clean all
  24. test: spec.txt
  25. perl runtests.pl $< $(PROG)
  26. testjs: spec.txt
  27. node js/test.js
  28. # perl runtests.pl js/markdown $<
  29. benchjs:
  30. node js/bench.js ${BENCHINP}
  31. HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o
  32. STMD_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.c
  33. $(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(STMD_OBJ) $(SRCDIR)/main.c
  34. $(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(STMD_OBJ) $(SRCDIR)/main.c
  35. $(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
  36. re2c --case-insensitive -bis $< > $@ || (rm $@ && false)
  37. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  38. perl mkcasefold.pl < $< > $@
  39. $(SRCDIR)/html/html_unescape.h: $(SRCDIR)/html/html_unescape.gperf
  40. gperf -I -t -N find_entity -H hash_entity -K entity -C -l --null-strings -m5 $< > $@
  41. .PHONY: leakcheck clean fuzztest dingus upload
  42. dingus:
  43. cd js && echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  44. leakcheck: $(PROG)
  45. cat oldtests/*/*.markdown | 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