include ft/tests/make.include

FT_BINS = $(patsubst %,ft/%$(BINSUF),$(BINS_RAW))

TEST_FT = ft/brt-test-helpers.$(OEXT)

# This version runs logformat twice.  There is something screwing in make that if you have a pattern form with two outputs
# then it runs the thing only once, but if it has no % symbols it runs it twice.
## log_header.h log_code.c: logformat$(BINSUF)
##	./logformat
# So we do it this way
ft/log_print.c ft/log_header.h ft/log_code.c: ft/logformat$(BINSUF)
	ft/logformat$(BINSUF) ft
.PRECIOUS: ft/log_print.c ft/log_header.h ft/log_code.c

FT_A        = ft/ft.$(AEXT)

FT_SOURCES = \
  block_allocator \
  block_table \
  bread \
  brt-serialize \
  brt-verify \
  brt \
  ft_msg \
  brt-test-helpers \
  cachetable \
  checkpoint \
  fifo \
  fingerprint \
  key \
  leafentry \
  leaflock \
  logfilemgr \
  logger \
  log_code \
  log_print \
  logcursor \
  memarena \
  mempool \
  minicron \
  omt \
  recover \
  roll \
  rollback \
  ule \
  threadpool \
  toku_worker \
  trace_mem \
  txn \
  x1764 \
  xids \
  ybt \
# keep this line so I can have a \ on the previous line

FT_C_FILES = $(patsubst %,ft/%.c,$(FT_SOURCES))
FT_O_FILES = $(patsubst %,ft/%.$(OEXT),$(FT_SOURCES))

$(TEST_FT): ft/log_header.h
$(TEST_FT) $(FT_O_FILES) ft/ft.$(OEXT): CPPFLAGS_DIRECTORY = -Ift -Iinclude
ft/ft.$(OEXT): $(FT_C_FILES) $(DEPEND_COMPILE)
	$(CC) -c $(FT_C_FILES) $(COMBINE_C) $(CPPFLAGS) $(CPPFLAGS_DIRECTORY) $(CFLAGS) $(CFLAGS_DIRECTORY) $(OOUTPUT)$@

ifneq ($(CYGWIN),)
FT_O_FILES = $(FT_O_FILES)
else ifeq ($(CC),icc)
FT_O_FILES = $(FT_O_FILES)
else ifeq ($(COMBINE),0)
FT_O_FILES = $(FT_O_FILES)
else
FT_O_FILES = ft/ft.o
endif

FT_O_FILES += ft/ft_loader.o

$(FT_O_FILES): VISIBILITY=-fvisibility=default
$(FT_O_FILES): CPPFLAGS_DIRECTORY=-Iinclude -Itoku_include -I$(OS)
$(FT_O_FILES): SHADOW=
$(FT_A): $(FT_O_FILES)
ft/libft.$(SOEXT): $(FT_O_FILES)
ft/libft.$(SOEXT): VISIBILITY=-fvisibility=default
ft/libft.$(SOEXT): LOADLIBES_DIRECTORY=-lz -Llib -ltokuportability
ft/libft.$(SOEXT): CFLAGS_DIRECTORY=-lpthread
ft/ft_loader.$(OEXT): CPPFLAGS_DIRECTORY=-Iinclude
ft/logformat$(BINSUF): CPPFLAGS_DIRECTORY=-Iinclude -Itoku_include -I$(OS)

ft/build: ft/bins ft/libs $(TEST_FT) ft/tests/build
ft/check: ft/tests/check
ft/bins: $(FT_BINS)
ft/libs: $(FT_A)
.PHONY: ft/build ft/bins ft/libs
