CUDA ,C and Autotools

Hello guys,
I have read a lot of forums in this area. But I couldn’t find what I want.
I have lots of .c and .h files and an existing make file which works perfectly. The makefile is written using autotools(automake,autoconf and libtool). I want to accelerate one function from the large .c files using CUDA and I have got problem of editing the existing makefile. The concepts what I have got from different forums is how to use cuda in autotools but not explain how to modify the existing makefile and integrate it or how to use together cuda code and existing c code. I read this forum and has good explanation how to use cuda with autotools. The order of compilation of files using gcc and nvcc also matters if I am not mistaken. So, how to modify the existing Makefile by adding cuda code and where to put these commands to integrate with the existing c makefile(means at the top, middle, at the end or some where…) I think the order matters. Any one who has experience in this area please share your experience(How to use cuda code and c code together in makefile with an existing makefile generated by autotools). This makes me crazy.

I am using Ubuntu and if it helps I can upload the make file. I am going to edit and

hey guys. is the question not clear? No one answer me… When I tried to modify and I got undefined reference error.
here is cuda code part of and

the cuda compiler

NVCC = nvcc

# root path of cuda toolkits 
CUDA_ROOT_DIR = /usr/local/cuda-6.5

# the preprocessing flags passed to the compiler

# compiling flags
NVCC_CXXFLAGS = -O2 -g -G -dc \
                -gencode arch=compute_21,code=sm_21

# the linking flags
NVCC_LINKFLAGS = -gencode arch=compute_21,code=sm_21 \
                 -L/usr/local/cuda-6.5/lib64 -lcudart

bin_PROGRAMS = main
main_SOURCES =

# the rule that can recognize *.cu files
# and compile the *.cu files to *.o files
.cu.o : ; $(NVCC) $(NVCC_CPPFLAGS) $(NVCC_CXXFLAGS) -c -o $@ $<


I think undefined reference error is due to linking problem.
how to link gcc and nvcc in this case? is the above has linking problem?