# Makefile

#PROG := sample
PROG := libgpu_evd.so

CC := g++ 
#CC := gcc
NVCC=nvcc -ccbin g++ -m64 
CFLAGS := -O3 -Wall
#CFLAGS := -g -Wall

#NVFLAGS=-gencode arch=compute_61,code=sm_61 --relocatable-device-code=true --compile --ptxas-options=-v
#NVFLAGS=-Xcompiler -fPIC -gencode arch=compute_61,code=sm_61 --relocatable-device-code=true --compile
#NVFLAGS=-Xcompiler -fPIC -gencode arch=compute_20,code=sm_20 -gencode arch=compute_61,code=sm_61 --relocatable-device-code=true
NVFLAGS=-Xcompiler -fPIC -gencode arch=compute_20,code=sm_20 -gencode arch=compute_60,code=sm_60 --relocatable-device-code=true
#NVFLAGS=-gencode arch=compute_61,code=sm_61 --compile
#NVFLAGS= -O0 -g -G -gencode arch=compute_52,code=sm_52

INCLUDE := -I/usr/local/cuda-8.0/include
#INCLUDE := -I/home/ulsi/sugisaki/LAPACK/CLAPACK-3.2.1/INCLUDE
#INCLUDE := -I/home/ulsi/sugisaki/LAPACK/clapack-3.2.1-CMAKE/INCLUDE
#INCLUDE := -I/usr/local/cuda-7.5/include -I/usr/local/cuda-7.5/samples/common/inc
#INCLUDE := -I/usr/include -I/home/ulsi/opencv/opencv-2.4.11/include 
#INCLUDE := -I/home/ulsi/opencv/include
#NVINCLUDE=-I/usr/local/cuda-7.5/include
NVINCLUDE := -I/usr/local/cuda-8.0/include

#LDFLAGS := -L/home/ulsi/sugisaki/LAPACK/clapack-3.2.1-CMAKE/SRC -llapack
#LDFLAGS += -L/home/ulsi/sugisaki/LAPACK/clapack-3.2.1-CMAKE/BLAS/SRC -lblas
#LDFLAGS += -L/home/ulsi/sugisaki/LAPACK/clapack-3.2.1-CMAKE/F2CLIBS/libf2c -lf2c
#LDFLAGS += -lm

#LDFLAGS := -lm
#LDFLAGS := -L/home/ulsi/sugisaki/LAPACK/CLAPACK-3.2.1/lib -llapack -lblas -lf2c -lm

#CMAKE Ver.
#LDFLAGS := -lopencv_core -lopencv_superres -lopencv_highgui -lopencv_imgproc
#LDFLAGS := -lopencv_core -lopencv_highgui -lopencv_imgproc
#LDFLAGS := -L/home/ulsi/opencv/lib -lopencv_core -lopencv_highgui -lopencv_calib3d -lopencv_imgproc
#LDFLAGS := -L/home/ulsi/opencv-2.4.11/build/lib -lopencv_core -lopencv_highgui -lopencv_calib3d -lopencv_imgproc
#NVLDFLAGS=
#NVLDFLAGS=-L/usr/local/cuda-8.0/lib64 -lcudart -lnvrtc -lnvrtc-builtins
#NVLDFLAGS=-L/usr/local/cuda-8.0/lib64 -lcudart -lcudadevrt
NVLDFLAGS := -shared -L/usr/local/cuda-8.0/lib64 -lcudart

#	tstiee.c ilaenv_
#       slamch.c slamch_
#	lsame.c \
#	xerbla.c \
#	clanhe.c
#	clatrd.c
#	cher2k.c
#	wsfe.c 
#	slascl.c 

SRCS :=
#SRCS := main.c \
#	cheevd.c \
#	lsame.c \
#	xerbla.c \
#	clanhe.c \
#	chetrd.c \
#	c_abs.c \
#	cabs.c \
#	chetd2.c \
#	clarfg.c \
#	chemv.c \
#	cdotc.c \
#	caxpy.c \
#	cher2.c \
#	scnrm2.c \
#	r_imag.c \
#	slapy3.c \
#	r_sign.c \
#	cladiv.c \
#	cscal.c \
#	r_cnjg.c \
#	scabs1.c \
#	sladiv.c \
#	s_copy.c \
#	s_cmp.c \
#	tstiee.c \
#	csteqr.c \
#	slanst.c \
#	slassq.c \
#	slapy2.c \
#	slartg.c \
#	pow_ri.c \
#	pow_ii.c \
#	slaev2.c \
#	clasr.c \
#	slae2.c \
#	sisnan.c \
#	slaisnan.c \
#	claset.c \
#	cswap.c \
#	slasrt.c \
#	cunmtr.c \
#	s_cat.c \
#	f77_aloc.c \
#	exit_.c \
#	cunmqr.c \
#	cunm2r.c \
#	clarf.c \
#	ilaclc.c \
#	cgemv.c \
#	cgerc.c \
#	clacpy.c \
#	cstedc.c 


#	tstiee.cu 
#	f77_aloc.cu 
#	exit_.cu 
#NVSRCS :=
NVSRCS := cheevd.cu \
	lsame.cu \
	xerbla.cu \
	clanhe.cu \
	chetrd.cu \
	c_abs.cu \
	cabs.cu \
	chetd2.cu \
	clarfg.cu \
	chemv.cu \
	cdotc.cu \
	caxpy.cu \
	cher2.cu \
	scnrm2.cu \
	r_imag.cu \
	slapy3.cu \
	r_sign.cu \
	cladiv.cu \
	cscal.cu \
	r_cnjg.cu \
	scabs1.cu \
	sladiv.cu \
	s_copy.cu \
	s_cmp.cu \
	csteqr.cu \
	slanst.cu \
	slassq.cu \
	slapy2.cu \
	slartg.cu \
	pow_ri.cu \
	pow_ii.cu \
	slaev2.cu \
	clasr.cu \
	slae2.cu \
	sisnan.cu \
	slaisnan.cu \
	claset.cu \
	cswap.cu \
	slasrt.cu \
	cunmtr.cu \
	s_cat.cu \
	cunmqr.cu \
	cunm2r.cu \
	clarf.cu \
	ilaclc.cu \
	cgemv.cu \
	cgerc.cu \
	clacpy.cu \
	cstedc.cu 
	
OBJS := $(SRCS:%.cpp=%.o)
#OBJS := $(SRCS:%.c=%.o)
NVOBJS := $(NVSRCS:%.cu=%.o)

#	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(NVLDFLAGS)
$(PROG): $(OBJS) $(NVOBJS)
	$(NVCC) -Wno-deprecated-gpu-targets -o $@ $^ $(LDFLAGS) $(NVLDFLAGS)

#	$(NVCC) $(NVFLAGS) $(NVINCLUDE) $(INCLUDE) $(NVLDFLAGS) -c $<
%.o:%.cu
	$(NVCC) $(NVFLAGS) $(NVINCLUDE) $(INCLUDE) -c $<

#	$(NVCC) -Wno-deprecated-gpu-targets -o $@ $^ $(LDFLAGS) $(NVLDFLAGS)
#	$(NVCC) $(CFLAGS) $(INCLUDE) -c $<
%.o: %.cpp
	$(NVCC) $(NVFLAGS) $(NVINCLUDE) $(INCLUDE) -c $<

all: clean $(PROG)

clean:
	rm -f $(PROG) $(OBJS) $(NVOBJS)

