
OS := $(shell uname)

CXX = g++
CC = gcc
COLLECTL_CODE="collectl-4.1.0"
PARAFLY_CODE="ParaFly"
TRIMMOMATIC_CODE=Trimmomatic-0.36



trinity_essentials: seqtk_target parafly_target trimmomatic_target bamsifter_target

no_bamsifter: seqtk_target parafly_target trimmomatic_target


trimmomatic_target:
	ln -sf ${TRIMMOMATIC_CODE} Trimmomatic


seqtk_target:
	cd seqtk-trinity && $(MAKE) CXX=$(CXX) CC=$(CC) CFLAGS="$(CFLAGS)"
	mv seqtk-trinity/seqtk-trinity ./BIN/.

parafly_target:
	cd ${PARAFLY_CODE} && $(MAKE) install prefix=`pwd` INSTALL="install -c" MKDIR_P="mkdir -p" mkdir_p="mkdir -p" CXX=$(CXX) CC=$(CC) CFLAGS="$(CFLAGS) -fopenmp" CXXFLAGS="$(CXXFLAGS) -fopenmp" && \
	cp bin/ParaFly ../BIN/


bamsifter_target:
	cd bamsifter && $(MAKE) CXX=$(CXX) CC=$(CC) CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)"

##################################
### Needed for downstream analyses
##################################

plugins: slclust_target collectl_target
	@echo "\n\n** Done building plugins **\n\n"


slclust_target:
	cd slclust && $(MAKE) CXX=$(CXX) CC=$(CC) CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" install

collectl_target:
	cd COLLECTL && tar xvf ${COLLECTL_CODE}.src.tar.gz && ln -sf ${COLLECTL_CODE} collectl

clean:
	cd seqtk-trinity && $(MAKE) clean
	cd scaffold_iworm_contigs && $(MAKE) clean
	cd ${PARAFLY_CODE} && $(MAKE) clean
	rm -f ./Trimmomatic # rm symlink
	cd slclust && $(MAKE) clean
	cd COLLECTL && rm -rf ${COLLECTL_CODE} && rm -f collectl
	cd htslib && make clean
	cd bamsifter && make clean
	rm -f ./htslib.ok
	@echo "\n\n** Done cleaning plugins area **"


###################################################################


