SRC_HERE = $(ROOT)src

include $(ROOT)src/lock_tree/Makefile.include
include $(ROOT)src/range_tree/Makefile.include
include $(ROOT)src/tests/Makefile.include

OFILES += $(SRC_HERE)/lock_and_range_tree.o

$(SRC_HERE)/lock_and_range_tree.o: CPPFLAGS += -I$(LOCKTREE_HERE) -I$(LOCKTREE_HERE)/.. -I$(LOCKTREE_HERE)/../range_tree -I$(LOCKTREE_HERE)/../../include -I$(LOCKTREE_HERE)/../../newbrt
$(SRC_HERE)/lock_and_range_tree.o: $(patsubst %,$(LOCKTREE_HERE)/%.c,$(LOCKTREE_FILES))  $(patsubst %,$(RANGETREE_HERE)/%.c,$(RANGETREE_FILES))
	$(CC) -combine $(CFLAGS) $(CPPFLAGS) $^ -c -o $@

SRC_FILES = ydb errors elocks lock_and_range_tree
SRC_OFILES = $(patsubst %, $(SRC_HERE)/%.o, $(SRC_FILES)) $(ROOT)newbrt/newbrt.o

LIBS += $(ROOT)lib/libtokudb.so $(ROOT)lib/libtokudb.a

$(ROOT)src/%.o: CPPFLAGS += -I$(ROOT)include -I$(ROOT)newbrt -I$(ROOT)src/lock_tree -I$(ROOT)src/range_tree

$(ROOT)lib/libtokudb.a: $(SRC_OFILES)
	$(AR) rv $@ $^

$(ROOT)lib/libtokudb.$(LIBEXT): $(SRC_OFILES)
	cc $^ $(SHARED) -o $@ $(CFLAGS) $(RPATHNAME)
