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