######################################################################################################
#  kissreads                                                                                         #
#  January 2012                                                                                      #
######################################################################################################
# Developper:                                                                                        #
#  Pierre PETERLONGO               pierre.peterlongo@inria.fr                                        #
######################################################################################################

# POSSIBILITIES:
# * make: compiled for generic usage. By default: kmer_spanning (a position is considered as covered if the kmer starting at this position is fully covered by a read)
# * make MYFLAGS=-DREAD2INV : output only motifs where au-vb is specific to one datasets and av'-u'b is specific to the other
# * make MYFLAGS=-DCLASSICAL_SPANNING : compiled without kmer (a position is considered as covered as soon as a read maps this position)
# * make MYFLAGS=-DINPUT_FROM_KISSPLICE : compiled for dealing with kissplice output and to count separately junctions and central portions
# Note that this is compatible: make CFLAGS="-DCLASSICAL_SPANNING -DINPUT_FROM_KISSPLICE" is possible


ALL		= kissreads
CC		=gcc

# optimized flags

#CFLAGS=-Wall -O3 -L/../thirdparty/zlib/build/ -lz
CFLAGS= -O3 -L../thirdparty/zlib/build/ -lz
CFLAGS+=$(MYFLAGS)

#LDFLAGS+=-Wall -lm -O3 -L../thirdparty/zlib/build/ -lz
LDFLAGS+= -lm -O3 -L../thirdparty/zlib/build/ -lz

## debug flags
#CFLAGS		+=-Wall -g -lz -fopenmp
#LDFLAGS	+=-Wall -lm -g -lz -fopenmp


#openmp is incompatiblre with clang 
ifeq ($(CC), gcc)
 CFLAGS += -fopenmp -DOMP
 LDFLAGS+= -fopenmp -DOMP
endif


SRCDIR		= ./src/
INCLDIR		= ./include/
IFLAGS		= -I$(INCLDIR)


SRC	= $(SRCDIR)coherent_algorithm.c $(SRCDIR)commons.c $(SRCDIR)couple.c $(SRCDIR)extension_algorithm.c $(SRCDIR)fragment_index.c $(SRCDIR)kissReads.c $(SRCDIR)list.c $(SRCDIR)outputs.c $(SRCDIR)interface_libchash.c $(SRCDIR)libchash.c $(SRCDIR)tree.c 
OBJ	= $(SRC:.c=.o)



all: $(ALL)
	@echo "#################"
	@echo "# Compilation OK#"
	@echo "#################"

kissreads: $(OBJ) 
	$(CC)  -o $@ $^ $(LDFLAGS)


kissReads.o: $(INCLDIR)coherence_algorithm.h  $(INCLDIR)couple.h $(INCLDIR)extension_algorithm.h $(INCLDIR)fragment_info.h  $(INCLDIR)libchash.h  $(INCLDIR)outputs.h $(INCLDIR)commons.h $(INCLDIR)extending_fragment.h $(INCLDIR)fragment_index.h $(INCLDIR)hash.h $(INCLDIR)list.h $(INCLDIR)tree.h

%.o: %.c
	$(CC)  -o $@ -c $< $(CFLAGS) $(IFLAGS)

.PHONY: clean mrproper

clean:
	rm -rf $(SRCDIR)*.o $(ALL)

mrproper: clean
	rm -rf $(ALL)

