Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. CODEC_DIR = src/codec
  2. CC = gcc
  3. CFLAGS += -Wall -DLOG_USE_COLOR
  4. INCLUDE_BASE = . -Iinclude -Iext/xxHash -Iext/openldap/libraries/liblmdb \
  5. -Iext/tpl/src -Iext/uthash/src -Iext/log/src
  6. INCLUDE = -I$(INCLUDE_BASE)
  7. LIB = -luuid -lpthread
  8. SRC = ext/xxHash/xxhash.c ext/tpl/src/tpl.c \
  9. ext/openldap/libraries/liblmdb/mdb.c \
  10. ext/openldap/libraries/liblmdb/midl.c ext/log/src/log.c \
  11. src/*.c src/codec/*_grammar.c src/codec/*_parser.c
  12. DEPS := $(shell echo "${INCLUDE_BASE}" | sed -e 's/ -I/,/g')
  13. DOCS = docs
  14. .PHONY: build_parsers lint profile
  15. default: test
  16. build: build_parsers
  17. $(CC) \
  18. $(CFLAGS) -Werror
  19. $(INCLUDE) \
  20. $(LIB) \
  21. $(SRC) \
  22. -o bin/lsup_rdf.so
  23. lint:
  24. splint \
  25. $(INCLUDE) -Itest \
  26. -DUINT_MAX=0xFFFFFFFFUL \
  27. -nullpass \
  28. -posix-lib \
  29. test.c
  30. test: build_parsers
  31. $(CC) \
  32. $(CFLAGS) -g3 -DDEBUG \
  33. $(INCLUDE) -Itest \
  34. $(LIB) \
  35. $(SRC) test.c \
  36. -o bin/test
  37. test_lexer:
  38. cd src/codec && \
  39. lemon -T/usr/share/lemon/lempar.c nt_grammar.y && \
  40. re2c nt_lexer.re -o nt_codec.c -T --case-ranges && \
  41. cd ../../
  42. $(CC) \
  43. $(CFLAGS) -g3 -DDEBUG \
  44. $(INCLUDE) -I. \
  45. $(LIB) \
  46. $(SRC) src/codec/nt_codec.c src/codec/nt_grammar.c \
  47. -o bin/test_lexer
  48. valgrind:
  49. valgrind \
  50. --leak-check=full --show-leak-kinds=all --track-origins=yes \
  51. --log-file=/tmp/lsup_valgrind.log \
  52. ./bin/test && \
  53. echo "Memcheck complete. Valgrind log is at /tmp/lsup_valgrind.log"
  54. memcheck: test valgrind
  55. profile: build_parsers
  56. $(CC) \
  57. $(CFLAGS) -g -DTESTING \
  58. $(INCLUDE) \
  59. $(LIB) \
  60. $(SRC) profile.c \
  61. -o bin/profile
  62. py_test:
  63. pip3 install --user . && \
  64. python3 test/cpython_test.py
  65. # Build a visual dependency graph.
  66. # Requires cinclude2dot (https://www.flourish.org/cinclude2dot) and Graphviz.
  67. depgraph: src/* include/*
  68. cinclude2dot --merge=module --include=$(DEPS) \
  69. --exclude='test|ext' >| $(DOCS)/dev/deps.dot
  70. dot $(DOCS)/dev/deps.dot -Tpdf >| $(DOCS)/dev/deps.pdf
  71. build_parsers:; $(MAKE) -C $(CODEC_DIR)