diff --git a/src/Makefile.am b/src/Makefile.am
index c3f5568a7c8a70fe82848bec70ddc13e11d383bd..030d1c18ede64f32de4e6df73ea9c274076614a4 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,8 +1,14 @@
 
 LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB)
 
+if BUILDCUDA
+ CUDA_SOURCES=memory/CudaMemory.cu
+else
+ CUDA_SOURCES=
+endif
+
 bin_PROGRAMS = mem
-mem_SOURCES = main.cpp memory/HeapMemory.cpp memory/CudaMemory.cu
+mem_SOURCES = main.cpp memory/HeapMemory.cpp $(CUDA_SOURCES)
 mem_CXXFLAGS = $(INCLUDES_PATH) -I/usr/local/include
 mem_CFLAGS = 
 mem_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/