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