# Define installation location for CUDA and compilation flags compatible
# with the CUDA include files.
CUDAHOME    = /usr/local/cuda
INCLUDEDIR  = -I$(CUDAHOME)/include
INCLUDELIB  = -L$(CUDAHOME)/lib64 -lcufft -Wl,-rpath,$(CUDAHOME)/lib64 -lcuda -lcublas -lcudart
CFLAGS      = -fPIC -D_GNU_SOURCE -pthread -fexceptions -g
COPTIMFLAGS = -O3 -funroll-loops -msse2

# Things that have nothing to do with nvmex
NVCC=nvcc
DEFINES=-D'EPSILON=.0001' -D'PROJECTBASE=./' -D'__TEST_DRIVER__'
LIBRARIES=-lcunit -lcuda -lcublas

# Define installation location for MATLAB.
export MATLAB = /exp/lovelace/matlab/r2009a
#export MATLAB = /Applications/MATLAB_R2007b
MEX           = $(MATLAB)/bin/mex
MEXEXT        = .$(shell $(MATLAB)/bin/mexext)

# nvmex is a modified mex script that knows how to handle CUDA .cu files.
NVMEX = /usr/local/bin/nvmex
NVOPTS = /usr/local/share/nvopts.sh

# List the mex files to be built.  The .mex extension will be replaced with the
# appropriate extension for this installation of MATLAB, e.g. .mexglx or
# .mexa64.
MEXFILES = cuda_value.mex

all: $(MEXFILES:.mex=$(MEXEXT))

clean:
	rm -f $(MEXFILES:.mex=$(MEXEXT)) && \


.SUFFIXES: .cu .cu_o .mexglx .mexa64 .mexmaci

.c.mexglx:
	$(MEX) CFLAGS='$(CFLAGS)' COPTIMFLAGS='$(COPTIMFLAGS)' $< \
        $(INCLUDEDIR) $(INCLUDELIB)

.cu.mexglx:
	$(NVMEX) -f $(NVOPTS) $< $(INCLUDEDIR) $(INCLUDELIB)

.c.mexa64:
	$(MEX) CFLAGS='$(CFLAGS)' COPTIMFLAGS='$(COPTIMFLAGS)' $< \
        $(INCLUDEDIR) $(INCLUDELIB)

.cu.mexa64:
	$(NVMEX) -f $(NVOPTS) $< $(INCLUDEDIR) $(INCLUDELIB)

.c.mexmaci:
	$(MEX) CFLAGS='$(CFLAGS)' COPTIMFLAGS='$(COPTIMFLAGS)' $< \
        $(INCLUDEDIR) $(INCLUDELIB)

.cu.mexmaci:
	$(NVMEX) -f $(NVOPTS) $< $(INCLUDEDIR) $(INCLUDELIB)



# Copyright 2009,2010 Augustus Lidaka, Shitanshu Aggarwal, Jerod Weinman
#
# This file is part of CUDAMAXENT.
#
#   CUDAMAXENT is free software: you can redistribute it and/or modify it
#   under the terms of the GNU General Public License as published by the
#   Free Software Foundation, either version 3 of the License, or (at your
#   option) any later version.
#
#   CUDAMAXENT is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License along
#   with CUDAMAXENT.  If not, see <http://www.gnu.org/licenses/>.
