CC=gcc
CFLAGS+= -Wall -std=c99 -D_XOPEN_SOURCE=500
INCLUDE=-Iinclude -Iext/xxHash -Iext/openldap/libraries/liblmdb -Iext/uthash/src
LIB=-luuid -lpthread
SRC=ext/xxHash/xxhash.c ext/openldap/libraries/liblmdb/mdb.c \
	ext/openldap/libraries/liblmdb/midl.c src/*.c

.PHONY: build test lint profile

default: test

build:
	$(CC) \
		$(CFLAGS) -Werror
		$(INCLUDE) \
		$(LIB) \
		$(SRC) \
		-o bin/lsup_rdf.so

lint:
	splint \
		$(INCLUDE) -Itest \
		-DUINT_MAX=0xFFFFFFFFUL \
		-nullpass \
		-posix-lib \
		test.c

test:
	$(CC) \
		$(CFLAGS) -g3 -DDEBUG \
		$(INCLUDE) -Itest \
		$(LIB) \
		$(SRC) test.c \
		-o bin/test


valgrind:
	valgrind \
	--leak-check=full --show-leak-kinds=all --track-origins=yes \
	./bin/test


memcheck: test valgrind


profile:
	$(CC) \
		$(CFLAGS) \
		$(INCLUDE) \
		$(LIB) \
		$(SRC) profile.c \
		-o bin/profile