15 | | # Matlab configuration |
16 | | #MATLABDIR = /usr/local/MATLAB/R2010b |
17 | | # comment the following line if you use MATLAB on 32-bit operating system |
18 | | MEX_OPTION += -largeArrayDims |
19 | | |
20 | | # Mingw crosscompiler: available at http://www.nongnu.org/mingw-cross-env/ |
21 | | CROSS = $(HOME)/src/mxe/usr/bin/i686-w64-mingw32.static- |
22 | | CROSS64 = $(HOME)/src/mxe/usr/bin/x86_64-w64-mingw32.static- |
23 | | # include directory for Win32-Matlab include |
24 | | W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/ |
25 | | W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/ |
26 | | # path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ |
27 | | GNUMEX = $(HOME)/bin/win32/gnumex |
28 | | GNUMEX64 = $(HOME)/bin/win64/gnumex |
29 | | # building gnumex64 was difficult, these hints were quite useful: |
30 | | # http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinZvxgC9ezp2P3UCX_a7TAUYuVsp2U40MQUV6qr%40mail.gmail.com&forum_name=gnumex-users |
31 | | # Instead of building "mex shortpath.c" and "mex uigetpath.c", I used empty m-functions within argout=argin; |
32 | | #################################################### |
33 | | |
34 | | CC = gcc |
35 | | CXX = g++ |
| 15 | #CC = gcc |
| 16 | #CXX = g++ |
54 | | ### Matlab configuration - search for a matlab directory if not defined above |
55 | | ifndef MATLABDIR |
56 | | ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB)) |
57 | | # use oldest, typically mex-files a compatible with newer Matlab versions |
58 | | MATLABDIR=/usr/local/MATLAB/$(shell ls -1t /usr/local/MATLAB/ |grep "^R*" |head -1) |
59 | | # alternatively, use latest matlab version |
60 | | #MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1) |
61 | | endif |
62 | | endif |
63 | | |
64 | | ### if the MATLABDIR has been found or defined |
65 | | ifneq (,MATLABDIR) |
66 | | ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext)) |
67 | | MEX_EXT=$(shell $(MATLABDIR)/bin/mexext) |
68 | | mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS)) |
69 | | endif |
70 | | endif |
71 | | |
72 | | |
73 | | mexw32 win32: $(patsubst %.mex, %.mexw32, $(PROGS)) |
74 | | mexw64 win64: $(patsubst %.mex, %.mexw64, $(PROGS)) |
75 | | all: octave win32 win64 mex4m |
| 34 | all: octave mex4m |
120 | | |
121 | | ######################################################### |
122 | | # MATLAB/WIN32 |
123 | | ######################################################### |
124 | | %.obj: %.cpp |
125 | | $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
126 | | %.obj: %.c |
127 | | $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
128 | | |
129 | | train.mexw32 predict.mexw32: train.obj linear.obj linear_model_matlab.obj tron.obj |
130 | | $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" linear_model_matlab.obj linear.obj tron.obj -llibmx -llibmex -llibmat -lcholmod -lblas |
131 | | |
132 | | svmpredict_mex.mexw32 : svmpredict_mex.obj svm.obj svm_model_matlab.obj |
133 | | $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lcholmod |
134 | | svmtrain_mex.mexw32 : svmtrain_mex.obj svm.obj svm_model_matlab.obj |
135 | | $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lcholmod |
136 | | |
137 | | %.mexw32: %.obj |
138 | | $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread |
139 | | |
140 | | |
141 | | |
142 | | ######################################################### |
143 | | # MATLAB/WIN64 |
144 | | ######################################################### |
145 | | |
146 | | ## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash |
147 | | %.o64: %.cpp |
148 | | $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W64MAT_INC) -O2 "$<" |
149 | | %.o64: %.c |
150 | | $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W64MAT_INC) -O2 "$<" |
151 | | |
152 | | train.mexw64 predict.mexw64: train.o64 linear.o64 linear_model_matlab.o64 tron.o64 |
153 | | $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" linear_model_matlab.o64 linear.o64 tron.o64 -llibmx -llibmex -llibmat -lcholmod -lblas |
154 | | |
155 | | svmpredict_mex.mexw64 : svmpredict_mex.o64 svm.o64 svm_model_matlab.o64 |
156 | | $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lcholmod |
157 | | svmtrain_mex.mexw64 : svmtrain_mex.o64 svm.o64 svm_model_matlab.o64 |
158 | | $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lcholmod |
159 | | |
160 | | %.mexw64: %.o64 |
161 | | $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread |
162 | | |