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