# Jeff Hagen # jeff.hagen@oracle.com # # A simple makefile for CUDA projects. # # This is much shorter then the default makefile, and is so by making the following assumptions: # 1) The CUDA SDK is installed to ~/NVIDIA_CUDA_SDK # 2) CUDA is installed to /usr/local/CUDA # 3) The project does not use openGL/DirectX # 4) You are on linux. # # Add source files here EXECUTABLE := bugbug # Cuda source files (compiled with cudacc) CUFILES := bugbug.cu # C/C++ source files (compiled with gcc / c++) CCFILES := CCOFILES := ################################################################################ # Rules and targets CUDA_INSTALL_PATH := /usr/local/cuda # Basic directory setup for SDK # (override directories only if they are not already defined) SRCDIR ?= ROOTDIR ?= $(HOME)/NVIDIA_CUDA_SDK ROOTBINDIR ?= $(ROOTDIR)/bin BINDIR ?= $(ROOTBINDIR)/linux ROOTOBJDIR ?= obj LIBDIR := $(ROOTDIR)/lib COMMONDIR := $(ROOTDIR)/common CUDA_FLAGS ?= # Compilers NVCC := nvcc CXX := g++ CC := gcc LINK := g++ -fPIC # Includes INCLUDES += -I. -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc # Libs LIB := -L/usr/local/cuda/lib -L../../lib -L../../common/lib -L$(ROOTDIR)/lib/ DOLINK := -lcuda -lcudart -lGL -lGLU -lcutil default: $(CCOFILES) nvcc -o $(EXECUTABLE) $(CUFILES) $(CCOFILES) $(INCLUDES) $(LIB) $(DOLINK) $(CUDA_FLAGS) -DUNIX emulate: $(CCOFILES) nvcc -o $(EXECUTABLE) $(CUFILES) $(CCOFILES) $(INCLUDES) $(LIB) $(DOLINK) -deviceemu $(CUDA_FLAGS) -DUNIX cubin: $(CCOFILES) nvcc -cubin $(CUFILES) $(CCOFILES) $(INCLUDES) $(LIB) $(DOLINK) -deviceemu $(CUDA_FLAGS) -DUNIX %.o: %.c g++ -fPIC -c $? $(INCLUDES) $(LIB) -DUNIX clean: rm -f $(CCOFILES) $(EXECUTABLE) links: #for emacs syntax highlighting! (assumes bash!) for X in *.cu; do ln -s $$X $$X.c; done; moreclean: clean rm -f *.cu.c