#etykieta: pliki ktorych zmiana na spowodowac rekompilacje
#	polecenie (np. do kompilacji)

all:		main.out \
		directories

directories:	results

main.out:	sequences.o \
		main.o \
		exceptions.o \
		substitution_matrix.o \
		needleman_wunsch_global.o \
		similarity_algorithm_cpu.o \
		needleman_wunsch_semiglobal.o \
		smith_waterman_local.o \
		main_cu.o \
		thread.o \
		sem.o \
		mutex.o \
		thread_manager.o \
		hi_res_timer.o \
		matches_manager.o \
		arguments_manager.o
	
		
	nvcc	sequences.o \
		main.o \
		exceptions.o \
		substitution_matrix.o \
		needleman_wunsch_global.o \
		similarity_algorithm_cpu.o \
		needleman_wunsch_semiglobal.o \
		smith_waterman_local.o \
		main_cu.o \
		thread.o \
		sem.o \
		mutex.o \
		thread_manager.o \
		hi_res_timer.o \
		matches_manager.o \
		arguments_manager.o \
		-o main.out

#------------------------------ DIRECTORIES ------------------------------------

results:
		mkdir -p results

#------------------------------ CU ---------------------------------------------

main_cu.o:	main_cu.cu \
		main_cu.h \
		data_management.cuh \
		data_management.cu  \
		alignment_score_gpu.cuh \
		needleman_wunsch_global_score_gpu.cu \
		needleman_wunsch_semiglobal_score_gpu.cu \
		smith_waterman_score_gpu.cu \
		alignment_match_gpu.cuh \
		needleman_wunsch_global_match_gpu.cu \
		needleman_wunsch_semiglobal_match_gpu.cu \
		smith_waterman_match_gpu.cu \
		exceptions.h \
		sequences.h \
		hi_res_timer.h \
		matches_manager.h \
		cuda_declarations.h

	nvcc -c main_cu.cu \
		-o main_cu.o

#------------------------------ CPP --------------------------------------------
main.o:		main.cpp \
		sequences.h \
		substitution_matrix.h \
		needleman_wunsch_global.h \
		needleman_wunsch_semiglobal.h \
		smith_waterman_local.h \
		main_cu.h \
		thread_manager.h

	nvcc -c main.cpp -o main.o

needleman_wunsch_global.o:	needleman_wunsch_global.cpp \
				needleman_wunsch_global.h \
				sequences.h \
				substitution_matrix.h \
				back_up_struct.h \
				similarity_algorithm_cpu.h

	g++ -c needleman_wunsch_global.cpp -o needleman_wunsch_global.o

needleman_wunsch_semiglobal.o:	needleman_wunsch_semiglobal.cpp \
				needleman_wunsch_semiglobal.h \
				needleman_wunsch_global.h \
				sequences.h \
				substitution_matrix.h \
				back_up_struct.h \
				similarity_algorithm_cpu.h

	g++ -c needleman_wunsch_semiglobal.cpp -o needleman_wunsch_semiglobal.o


smith_waterman_local.o:		smith_waterman_local.cpp \
				smith_waterman_local.h \
				sequences.h \
				substitution_matrix.h \
				back_up_struct.h \
				similarity_algorithm_cpu.h

	g++ -c smith_waterman_local.cpp -o smith_waterman_local.o

similarity_algorithm_cpu.o:	back_up_struct.h \
				sequences.h \
				substitution_matrix.h \
				similarity_algorithm_cpu.h \
				similarity_algorithm_cpu.cpp \
				matches_manager.h \
				hi_res_timer.h
	
	g++ -c similarity_algorithm_cpu.cpp -o similarity_algorithm_cpu.o

sequences.o:	sequences.cpp \
		sequences.h \
		exceptions.h
	
	g++ -c sequences.cpp -o sequences.o

substitution_matrix.o:	substitution_matrix.cpp \
			substitution_matrix.h
	
	g++ -c substitution_matrix.cpp -o substitution_matrix.o

matches_manager.o:	matches_manager.cpp \
			matches_manager.h

	g++ -c matches_manager.cpp -o matches_manager.o



#------------------------------ HELPERS ----------------------------------------

hi_res_timer.o:	hi_res_timer.cpp \
		hi_res_timer.h

	g++ -c hi_res_timer.cpp -o hi_res_timer.o


thread.o:	thread.cpp \
		thread.h

	g++ -c thread.cpp -o thread.o

sem.o:	sem.cpp \
		sem.h

	g++ -c sem.cpp -o sem.o

mutex.o:	mutex.cpp \
		mutex.h

	g++ -c mutex.cpp -o mutex.o

thread_manager.o:	thread_manager.cpp \
			thread_manager.h \
			thread.h \
			exceptions.h \
			sem.h \
			mutex.h

	nvcc -c thread_manager.cpp -o thread_manager.o

arguments_manager.o:	arguments_manager.cpp \
			arguments_manager.h

	g++ -c arguments_manager.cpp -o arguments_manager.o

#------------------------------ EXCEPTIONS -------------------------------------

exceptions.o:	exceptions.cpp \
		exceptions.h
	
	g++ -c exceptions.cpp -o exceptions.o

clean:
	rm -rf *.o *.out

show_ptxinfo:
	echo `nvcc -c main_cu.cu --ptxas-options=-v`
