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