Makefile 1.8 KB

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