Compile R and CUDA on Linux

This is a simplified makefile I made out of the gputools package for generating dlls for R. More details can be found in the source code of this package placed at

http://cran.r-project.org/web/packages/gputools/index.html


# directories
CUDA_HOME = /usr/local/cuda
R_HOME = /usr/lib/R

# compiler, objects, targets, etc.
CC = $(CUDA_HOME)/bin/nvcc -gencode arch=compute_13,code=sm_13
EXT = cu
OBJS = rinterface.o correlation.o cuseful.o
TARGET = gputools.so

# compiler/preprocessor options
INCS = -I$(CUDA_HOME)/include
PARAMS = -Xcompiler "-I$(R_HOME)/include `"$(R_HOME)/bin/R" CMD config CPICFLAGS`"

# linker options
LD_PARAMS = -Xlinker "-L$(R_HOME)/lib -lR"
LIBS = -L$(CUDA_HOME)/lib -lcufft -lcublas -lcuda

# make rules
$(TARGET): $(OBJS)
$(CC) -shared $(LD_PARAMS) $(LIBS) $(OBJS) -o $@

$(OBJS): %.o: %.$(EXT)
$(CC) -c $(INCS) $(PARAMS) $(SRCS) $^ -o $@

clean:
rm -f *.o *.linkinfo *~