Makefile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. memcheck: test valgrind
  54. profile: build_parsers
  55. $(CC) \
  56. $(CFLAGS) -g -DTESTING \
  57. $(INCLUDE) \
  58. $(LIB) \
  59. $(SRC) profile.c \
  60. -o bin/profile
  61. py_test:
  62. pip3 install --user . && \
  63. python3 test/cpython_test.py
  64. # Build a visual dependency graph.
  65. # Requires cinclude2dot (https://www.flourish.org/cinclude2dot) and Graphviz.
  66. depgraph: src/* include/*
  67. cinclude2dot --merge=module --include=$(DEPS) \
  68. --exclude='test|ext' >| $(DOCS)/dev/deps.dot
  69. dot $(DOCS)/dev/deps.dot -Tpdf >| $(DOCS)/dev/deps.pdf
  70. build_parsers:; $(MAKE) -C $(CODEC_DIR)