aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 02c869cdadb5114738eb809d20c197058fcc15d2 (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 man/man1/cmark.1
  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. man/man1/cmark.1: man/cmark.1.md
  24. pandoc $< -o $@ -s -t man
  25. README.html: README.md template.html
  26. pandoc --template template.html -S -s -t html5 -o $@ $<
  27. spec: test spec.html
  28. spec.md: $(SPEC)
  29. perl spec2md.pl < $< > $@
  30. spec.html: spec.md template.html
  31. pandoc --no-highlight --number-sections --template template.html -s --toc -S $< > $@ # | perl -pe 's/␣/<span class="space"> <\/span>/g' > $@
  32. spec.pdf: spec.md template.tex specfilter.hs
  33. pandoc -s $< --template template.tex \
  34. --filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \
  35. --number-sections -V documentclass=report -V tocdepth=2 \
  36. -V classoption=twosides
  37. test: $(SPEC)
  38. perl runtests.pl $< $(PROG)
  39. js/commonmark.js: js/lib/index.js ${JSMODULES}
  40. browserify --standalone commonmark $< -o $@
  41. testjs: $(SPEC)
  42. node js/test.js
  43. jshint:
  44. jshint ${JSMODULES}
  45. benchjs:
  46. node js/bench.js ${BENCHINP}
  47. #HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o
  48. #
  49. #CMARK_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.o
  50. #
  51. #CMARK_HDR = $(SRCDIR)/cmark.h $(SRCDIR)/buffer.h $(SRCDIR)/references.h \
  52. # $(SRCDIR)/chunk.h $(SRCDIR)/debug.h $(SRCDIR)/utf8.h \
  53. # $(SRCDIR)/scanners.h $(SRCDIR)/inlines.h
  54. #
  55. #HTML_HDR = $(SRCDIR)/html/html_unescape.h $(SRCDIR)/html/houdini.h
  56. #
  57. #$(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
  58. # $(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
  59. #
  60. #$(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
  61. # re2c --case-insensitive -bis $< > $@ || (rm $@ && false)
  62. $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
  63. perl mkcasefold.pl < $< > $@
  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. #CMARK_HDR = $(SRCDIR)/cmark.h $(SRCDIR)/buffer.h $(SRCDIR)/references.h \
  77. # $(SRCDIR)/chunk.h $(SRCDIR)/debug.h $(SRCDIR)/utf8.h \
  78. # $(SRCDIR)/scanners.h $(SRCDIR)/inlines.h
  79. #
  80. #HTML_HDR = $(SRCDIR)/html/html_unescape.h $(SRCDIR)/html/houdini.h
  81. dingus: js/commonmark.js
  82. echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
  83. leakcheck: $(PROG)
  84. cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG)
  85. operf: $(PROG)
  86. operf $(PROG) <$(BENCHINP) >/dev/null
  87. fuzztest:
  88. for i in `seq 1 10`; do \
  89. time cat /dev/urandom | head -c 500000 | iconv -f latin1 -t utf-8 | tee fuzz-$$i.txt | $(PROG) > /dev/null && rm fuzz-$$i.txt ; done
  90. $(SITE)/index.html: spec.txt
  91. ./make_site_index.sh $(SPECVERSION) | \
  92. pandoc --template template.html -S -s -t html5 -o $@
  93. $(SITE)/$(SPECVERSION)/index.html: spec.html
  94. mkdir -p $(SITE)/$(SPECVERSION)
  95. cp $< $@
  96. cd $(SITE); git add $(SPECVERSION)/index.html; git commit -a -m "Added version $(SPECVERSION) of spec"; cd ..
  97. $(SITE)/%: %
  98. cp $< $@
  99. update-site: $(SITE)/dingus.html $(SITE)/js/commonmark.js $(SITE)/index.html $(SITE)/$(SPECVERSION)/index.html $(SITE)/js/LICENSE
  100. upload-site:
  101. cd $(SITE) ; git pull; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..
  102. distclean: clean
  103. -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcommonmark.so
  104. -rm -f js/commonmark.js
  105. -rm -rf *.dSYM
  106. -rm -f README.html
  107. -rm -f spec.md fuzz.txt spec.html