# Uncomment the next two lines to use parallel processing (OpenMP)
PARALLEL_FLAGS = -DPARALLEL_SUPPORT -fopenmp
PARALLEL_LIB = -lgomp

CC = g++
LIBCDSPATH = libcds
CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ -O3 -DNDEBUG $(PARALLEL_FLAGS) 
LIBCDSA = $(LIBCDSPATH)/lib/libcds.a
LIBRLCSA = incbwt/rlcsa.a

FMIOBS = TextCollection.o TextCollectionBuilder.o TCImplementation.o Tools.o BitRank.o \
         EditDistance.o TextStorage.o

all: sfoverlap builder maxoverlaps

sfoverlap: ${LIBRLCSA} ${LIBCDSA} $(FMIOBS) sfoverlap.o
	$(CC) -o sfoverlap sfoverlap.o $(FMIOBS) ${LIBRLCSA} ${LIBCDSA} $(PARALLEL_LIB)

builder: ${LIBRLCSA} ${LIBCDSA} $(FMIOBS) builder.o
	$(CC) -o builder builder.o $(FMIOBS) ${LIBRLCSA} ${LIBCDSA} 

maxoverlaps: maxoverlaps.o
	$(CC) -o maxoverlaps maxoverlaps.o

incbwt/rlcsa.a:
	@make -C incbwt

$(LIBCDSA):
	@make -C $(LIBCDSPATH)

clean: shallow_clean
	@make clean -C incbwt
	@make clean -C libcds

shallow_clean:
	rm -f core *.o *~ sfoverlap builder maxoverlaps

depend:
	@make depend -C incbwt
	$(CC) -MM *.cpp > dependencies.mk

include dependencies.mk
