CODEC_DIR = src/codec CC = gcc CFLAGS += -Wall -DLOG_USE_COLOR INCLUDE_BASE = . -Iinclude -Iext/xxHash -Iext/openldap/libraries/liblmdb \ -Iext/tpl/src -Iext/uthash/src -Iext/log/src INCLUDE = -I$(INCLUDE_BASE) LIB = -luuid -lpthread SRC = ext/xxHash/xxhash.c ext/tpl/src/tpl.c \ ext/openldap/libraries/liblmdb/mdb.c \ ext/openldap/libraries/liblmdb/midl.c ext/log/src/log.c \ src/*.c src/codec/*_grammar.c src/codec/*_parser.c DEPS := $(shell echo "${INCLUDE_BASE}" | sed -e 's/ -I/,/g') DOCS = docs .PHONY: build_parsers lint profile default: test build: build_parsers $(CC) \ $(CFLAGS) -Werror $(INCLUDE) \ $(LIB) \ $(SRC) \ -o bin/lsup_rdf.so lint: splint \ $(INCLUDE) -Itest \ -DUINT_MAX=0xFFFFFFFFUL \ -nullpass \ -posix-lib \ test.c test: build_parsers $(CC) \ $(CFLAGS) -g3 -DDEBUG \ $(INCLUDE) -Itest \ $(LIB) \ $(SRC) test.c \ -o bin/test test_lexer: cd src/codec && \ lemon -T/usr/share/lemon/lempar.c nt_grammar.y && \ re2c nt_lexer.re -o nt_codec.c -T --case-ranges && \ cd ../../ $(CC) \ $(CFLAGS) -g3 -DDEBUG \ $(INCLUDE) -I. \ $(LIB) \ $(SRC) src/codec/nt_codec.c src/codec/nt_grammar.c \ -o bin/test_lexer valgrind: valgrind \ --leak-check=full --show-leak-kinds=all --track-origins=yes \ --log-file=/tmp/lsup_valgrind.log \ ./bin/test && \ echo "Memcheck complete. Valgrind log is at /tmp/lsup_valgrind.log" memcheck: test valgrind profile: build_parsers $(CC) \ $(CFLAGS) -g -DTESTING \ $(INCLUDE) \ $(LIB) \ $(SRC) profile.c \ -o bin/profile py_test: pip3 install --user . && \ python3 test/cpython_test.py # Build a visual dependency graph. # Requires cinclude2dot (https://www.flourish.org/cinclude2dot) and Graphviz. depgraph: src/* include/* cinclude2dot --merge=module --include=$(DEPS) \ --exclude='test|ext' >| $(DOCS)/dev/deps.dot dot $(DOCS)/dev/deps.dot -Tpdf >| $(DOCS)/dev/deps.pdf build_parsers:; $(MAKE) -C $(CODEC_DIR)