Hi all.
I have problem building my Makefile. I want it to automate generate dependencies for my source files. I know how to do it with cpp files. Is there any way to do similar thing with cu files?
My make:
CUDA_INSTALL_PATH = /opt/cuda
CUDA_SDK_PATH = /home/exm/NVIDIA_GPU_Computing_SDK/C
CXX := g++
CC := gcc
LINK := g++ -fPIC
NVCC := nvcc -ccbin /usr/bin
# Includes
INCLUDES = -I. -I$(CUDA_INSTALL_PATH)/include -I$(CUDA_SDK_PATH)/common/inc
# Common flags
COMMONFLAGS += $(INCLUDES)
NVCCFLAGS += $(COMMONFLAGS) -arch=sm_20 -m64
CXXFLAGS += $(COMMONFLAGS) -DNDEBUG -O3 -Wall -ffast-math -march=native -mtune=native
CFLAGS += $(COMMONFLAGS)
LIB_CUDA := -L$(CUDA_INSTALL_PATH)/lib64 -lcudart
SOURCE_CPP = \
ftr.cpp \
ftrcoher.cpp \
ftrcorr.cpp \
ftredge.cpp \
ftrhist.cpp \
ftrlbp.cpp \
jpegmat.cpp \
main.cpp \
pattern.cpp
SOURCE_CUDA = \
ftrcohergpu.cu \
ftrcorrgpu.cu \
ftredgegpu.cu \
ftrhistgpu.cu \
ftrlbpgpu.cu
OBJECT = $(SOURCE_CPP:.cpp=.o) $(SOURCE_CUDA:.cu=.o)
PROG_BIN = exmftr.x
LINKLINE = $(LINK) -o $(PROG_BIN) $(OBJECT) $(LIB_CUDA)
.PRECIOUS: $(PROG_BIN)
.SUFFIXES: .cpp .cu .o
all: $(PROG_BIN)
.dependcpp: dependcpp
dependcpp: $(SOURCE_CPP)
rm -f ./.dependcpp
$(CXX) $(CXXFLAGS) $(CXXINC) -MM $^ >> ./.dependcpp;
include ./.dependcpp
$(PROG_BIN): $(OBJECT) Makefile
$(LINKLINE)
%.o: %.cu
$(NVCC) $(NVCCFLAGS) -c $< -o $@
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -f *.o
rm -f $(PROG_BIN)
and ./dependcpp after calling make:
ftr.o: ftr.cpp ftr.h jpegmat.h
ftrcoher.o: ftrcoher.cpp ftrcoher.h pattern.h ftr.h jpegmat.h
ftrcorr.o: ftrcorr.cpp ftrcorr.h ../exmutil/mat.h pattern.h ftr.h \
jpegmat.h
ftredge.o: ftredge.cpp ftredge.h ../exmutil/mat.h ftr.h jpegmat.h
ftrhist.o: ftrhist.cpp ftrhist.h ftr.h jpegmat.h pattern.h
ftrlbp.o: ftrlbp.cpp ftrlbp.h ftr.h jpegmat.h pattern.h
jpegmat.o: jpegmat.cpp jpegmat.h
main.o: main.cpp jpegmat.h ftrcoher.h pattern.h ftr.h ftrcohergpu.h \
ftrcorr.h ../exmutil/mat.h ftrcorrgpu.h ftredge.h ftredgegpu.h \
ftrhist.h ftrhistgpu.h ftrlbp.h ftrlbpgpu.h
pattern.o: pattern.cpp pattern.h
Can nvcc make similar dependencies file, like g++ made for cpp files?
This will be very helpful, because it will give me autimatic recompile of files, when some of dependencies changed.