123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- CC = gcc
- AR = ar
- LEXER = re2c
- PARSER = lemon
- PREFIX = /usr/local
- bindir = $(PREFIX)/bin
- libdir = $(PREFIX)/lib
- includedir = $(PREFIX)/include/lsup_rdf
- INCLUDE_BASE = . -Iinclude -Iext/xxHash -Iext/openldap/libraries/liblmdb \
- -Iext/tpl/src -Iext/uthash/src -Iext/log/src
- INCLUDE = -I$(INCLUDE_BASE)
- CFLAGS += -Wall -fPIC -MMD -DLOG_USE_COLOR $(INCLUDE)
- LDFLAGS = -Lext/openldap/libraries/liblmdb -Lext/xxHash \
- -llmdb -lxxhash -luuid -pthread
- CODEC_DIR = src/codec
- CODEC_SRC = $(wildcard src/codec/*_grammar.c) \
- $(wildcard src/codec/*_parser.c)
- CODEC_OBJ = $(CODEC_SRC:.c=.o)
- EXT_SRC = $(wildcard ext/log/src/*.c) \
- $(wildcard ext/tpl/src/*.c)
- SRC = $(EXT_SRC) $(wildcard src/*.c)
- OBJ = $(SRC:.c=.o) $(CODEC_OBJ)
- TEST_SRC = $(wildcard test/*.c) test.c
- DEPLIBS = libxxhash liblmdb
- LIBS = liblsuprdf.a liblsuprdf.so
- DEPS := $(shell echo "${INCLUDE_BASE}" | sed -e 's/ -I/,/g')
- DOCS = docs
- all: $(DEPLIBS) $(LIBS)
- liblsuprdf.a: $(OBJ)
- $(AR) rs $@ $^
- liblsuprdf.so: $(OBJ)
- $(CC) -shared $(LDFLAGS) -o $@ $^
- $(CODEC_OBJ): $(CODEC_SRC)
- %_parser.c: %_lexer.re %_grammar.c
- $(LEXER) $< -o $@ -T --case-ranges
- %_grammar.c: %_grammar.y
- $(PARSER) $< -q -m -T$(CODEC_DIR)/lempar.c -d$(CODEC_DIR)
- core.o: core.c $(EXT_SRC) \
- $(wildcard ext/tpl/*.c) $(wildcard ext/tpl/*.h)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
- .PHONY: libxxhash
- libxxhash:
- $(MAKE) -C ext/xxHash
-
- .PHONY: liblmdb
- liblmdb:
- $(MAKE) -C ext/openldap/libraries/liblmdb
- install: all
- mkdir -p $(DESTDIR)$(libdir)
- mkdir -p $(DESTDIR)$(includedir)
- cp liblsuprdf.* $(DESTDIR)$(libdir) && \
- cp include/*.h $(DESTDIR)$(includedir)
-
- .PHONY: clean
- clean:
- rm -rf src/*.[aod] ./*[aod] src/codec/*[aod]
- .PHONY: uninstall
- uninstall:
- rm -f $(DESTDIR)$(libdir)/liblsuprdf.*
- rm -rf $(DESTDIR)$(includedir)
- .PHONY: test
- test: all $(TEST_SRC)
- $(CC) \
- $(CFLAGS) -g3 -DDEBUG \
- $(INCLUDE) -Itest \
- test.c -L. $(LDFLAGS) -llsuprdf \
- -o bin/test
- lint:
- splint \
- $(INCLUDE) -Itest \
- -DUINT_MAX=0xFFFFFFFFUL \
- -nullpass \
- -posix-lib \
- test.c
- .PHONY: memcheck
- memcheck:
- 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"
- memtest: test memcheck
- profile: build_parsers
- $(CC) \
- $(CFLAGS) -g -DTESTING \
- $(INCLUDE) \
- $(SRC) profile.c \
- -o bin/profile
- py_test:
- pip3 install --user . && \
- python3 test/cpython_test.py
- 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
|