aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 9ff52b1077267a17496d2eb2fb8919a103494a11 (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. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  61. perl mkcasefold.pl < $< > $@
  62. #$(SRCDIR)/html/html_unescape.h: $(SRCDIR)/html/html_unescape.gperf
  63. # gperf -I -t -N find_entity -H hash_entity -K entity -C -l
  64. # --null-strings -m5 $< > $@
  65. #
  66. #libcommonmark.so: $(HTML_OBJ) $(CMARK_OBJ)
  67. # $(CC) $(LDFLAGS) -shared -o $@ $^
  68. #
  69. #install: libcommonmark.so $(cmark_HDR) $(HTML_HDR)
  70. # install -d $(PREFIX)/lib $(PREFIX)/include/cmark/html
  71. # install libcommonmark.so $(PREFIX)/lib/
  72. # install $(cmark_HDR) $(PREFIX)/include/cmark/
  73. # install $(HTML_HDR) $(PREFIX)/include/cmark/html/
  74. #CMARK_HDR = $(SRCDIR)/cmark.h $(SRCDIR)/buffer.h $(SRCDIR)/references.h \
  75. # $(SRCDIR)/chunk.h $(SRCDIR)/debug.h $(SRCDIR)/utf8.h \
  76. # $(SRCDIR)/scanners.h $(SRCDIR)/inlines.h
  77. #
  78. #HTML_HDR = $(SRCDIR)/html/html_unescape.h $(SRCDIR)/html/houdini.h
  79. dingus: js/commonmark.js
  80. echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  81. leakcheck: $(PROG)
  82. cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG)
  83. operf: $(PROG)
  84. operf $(PROG) <$(BENCHINP) >/dev/null
  85. fuzztest:
  86. for i in `seq 1 10`; do \
  87. time cat /dev/urandom | head -c 100000 | iconv -f latin1 -t utf-8 | $(PROG) >/dev/null; done
  88. $(SITE)/index.html: spec.txt
  89. ./make_site_index.sh $(SPECVERSION) | \
  90. pandoc --template template.html -S -s -t html5 -o $@
  91. $(SITE)/$(SPECVERSION)/index.html: spec.html
  92. mkdir -p $(SITE)/$(SPECVERSION)
  93. cp $< $@
  94. cd $(SITE); git add $(SPECVERSION)/index.html; git commit -a -m "Added version $(SPECVERSION) of spec"; cd ..
  95. $(SITE)/%: %
  96. cp $< $@
  97. update-site: $(SITE)/dingus.html $(SITE)/js/commonmark.js $(SITE)/index.html $(SITE)/$(SPECVERSION)/index.html $(SITE)/js/LICENSE
  98. upload-site:
  99. cd $(SITE) ; git pull; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..
  100. distclean: clean
  101. -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcommonmark.so
  102. -rm -f js/commonmark.js
  103. -rm -rf *.dSYM
  104. -rm -f README.html
  105. -rm -f spec.md fuzz.txt spec.html