aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: c2899ea5b46a3cc575fa1cd99ff3bd1a47bc8365 (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?=README.md
  6. PROG?=./cmark
  7. JSMODULES=$(wildcard js/lib/*.js)
  8. PREFIX?=/usr/local
  9. SPEC=spec.txt
  10. SPECVERSION=$(shell grep version: $(SPEC) | sed -e 's/version: *//')
  11. .PHONY: all spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs
  12. all: $(SRCDIR)/case_fold_switch.inc $(PROG) libcmark.so
  13. README.html: README.md template.html
  14. pandoc --template template.html -S -s -t html5 -o $@ $<
  15. spec: test spec.html
  16. spec.md: $(SPEC)
  17. perl spec2md.pl < $< > $@
  18. spec.html: spec.md template.html
  19. pandoc --no-highlight --number-sections --template template.html -s --toc -S $< > $@ # | perl -pe 's/␣/<span class="space"> <\/span>/g' > $@
  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)
  26. perl runtests.pl $< $(PROG)
  27. js/commonmark.js: js/lib/index.js ${JSMODULES}
  28. browserify --standalone commonmark $< -o $@
  29. testjs: $(SPEC)
  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. _site/spec.html: spec.redirect.in
  66. perl -pe 's/VERSION/$(SPECVERSION)/g' $< > $@
  67. _site/index.html: _site/spec.html
  68. cp $< $@
  69. _site/$(SPECVERSION)/index.html: spec.html
  70. mkdir -p _site/$(SPECVERSION)
  71. cp $< $@
  72. cd _site; git add $(SPECVERSION)/index.html; git commit -a -m "Added version $(SPECVERSION) of spec"; cd ..
  73. update-site: spec.html js/commonmark.js _site/index.html _site/$(SPECVERSION)/index.html _site/spec.html
  74. cp js/index.html _site/js/
  75. cp js/commonmark.js _site/js/
  76. cp js/LICENSE _site/js/
  77. (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..)
  78. clean:
  79. -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcmark.so
  80. -rm js/commonmark.js
  81. -rm -rf *.dSYM
  82. -rm -f README.html
  83. -rm -f spec.md fuzz.txt spec.html