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 = -I$(HOME)/bin/win32/Matlab/R2010b/extern/include/ |
25 | | W64MAT_INC = -I$(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 | | W32MAT_INC += -I$(subst /usr/bin/,/usr/,$(CROSS))/include/ |
34 | | W64MAT_INC += -I$(subst /usr/bin/,/usr/,$(CROSS64))/include/ |
35 | | LDLIBS_W32 = $(subst /usr/bin/,/usr/,$(CROSS))/lib/ |
36 | | LDLIBS_W64 = $(subst /usr/bin/,/usr/,$(CROSS64))/lib/ |
37 | | W32_LIBS = $(LDLIBS_W32)liblapack.a |
38 | | W64_LIBS = $(LDLIBS_W64)liblapack.a |
39 | | W32_LIBS += $(LDLIBS_W32)libblas.a |
40 | | W64_LIBS += $(LDLIBS_W64)libblas.a |
41 | | |
42 | | CC = gcc |
43 | | CXX = g++ |
| 15 | #CC = gcc |
| 16 | #CXX = g++ |
61 | | |
62 | | ### Matlab configuration - search for a matlab directory if not defined above |
63 | | ifndef MATLABDIR |
64 | | ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB)) |
65 | | # use oldest, typically mex-files a compatible with newer Matlab versions |
66 | | MATLABDIR=/usr/local/MATLAB/$(shell ls -1t /usr/local/MATLAB/ |grep "^R*" |head -1) |
67 | | # alternatively, use latest matlab version |
68 | | #MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1) |
69 | | endif |
70 | | endif |
71 | | |
72 | | ### if the MATLABDIR has been found or defined |
73 | | ifneq (,MATLABDIR) |
74 | | ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext)) |
75 | | MEX_EXT=$(shell $(MATLABDIR)/bin/mexext) |
76 | | mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS)) |
77 | | endif |
78 | | endif |
79 | | |
80 | | |
81 | | mexw32 win32: $(patsubst %.mex, %.mexw32, $(PROGS)) |
82 | | mexw64 win64: $(patsubst %.mex, %.mexw64, $(PROGS)) |
83 | | all: octave win32 win64 mex4m |
| 33 | all: octave mex4m |
98 | | %.$(MEX_EXT): %.cpp |
99 | | $(MATMEX) "$<" -llapack -lblas |
100 | | |
101 | | |
102 | | ######################################################### |
103 | | # MATLAB/WIN32 |
104 | | ######################################################### |
105 | | %.obj: %.cpp |
106 | | $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
107 | | %.obj: %.c |
108 | | $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
109 | | |
110 | | %.mexw32: %.obj |
111 | | $(CROSS)-$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W32) -lblas -llapack |
112 | | |
113 | | |
114 | | ######################################################### |
115 | | # MATLAB/WIN64 |
116 | | ######################################################### |
117 | | |
118 | | ## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash |
119 | | %.o64: %.cpp |
120 | | $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<" |
121 | | %.o64: %.c |
122 | | $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<" |
123 | | |
124 | | %.mexw64: %.o64 |
125 | | $(CROSS64)-$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W64) -lblas -llapack |