5 | | |
6 | | |
| 10 | -# Matlab configuration |
| 11 | -# MATLABDIR = /usr/local/MATLAB/R2010b |
| 12 | -# comment the following line if you use MATLAB on 32-bit operating system |
| 13 | -MEX_OPTION += -largeArrayDims |
| 14 | - |
| 15 | -# Mingw crosscompiler: available at http://www.nongnu.org/mingw-cross-env/ |
| 16 | -CROSS = $(HOME)/src/mxe.github.schloegl/usr/bin/i686-w64-mingw32.static |
| 17 | -CROSS64 = $(HOME)/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32.static |
| 18 | -# include directory for Win32-Matlab include |
| 19 | -W32MAT_INC = -I$(HOME)/bin/win32/Matlab/R2010b/extern/include/ |
| 20 | -W64MAT_INC = -I$(HOME)/bin/win64/Matlab/R2010b/extern/include/ |
| 21 | -# path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ |
| 22 | -GNUMEX = $(HOME)/bin/win32/gnumex |
| 23 | -GNUMEX64 = $(HOME)/bin/win64/gnumex |
| 24 | -# building gnumex64 was difficult, these hints were quite useful: |
| 25 | -# http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinZvxgC9ezp2P3UCX_a7TAUYuVsp2U40MQUV6qr%40mail.gmail.com&forum_name=gnumex-users |
| 26 | -# Instead of building "mex shortpath.c" and "mex uigetpath.c", I used empty m-functions within argout=argin; |
| 27 | -#################################################### |
| 28 | -W32MAT_INC += -I$(subst /usr/bin/,/usr/,$(CROSS))/include/ |
| 29 | -W64MAT_INC += -I$(subst /usr/bin/,/usr/,$(CROSS64))/include/ |
| 30 | -LDLIBS_W32 = $(subst /usr/bin/,/usr/,$(CROSS))/lib/ |
| 31 | -LDLIBS_W64 = $(subst /usr/bin/,/usr/,$(CROSS64))/lib/ |
| 32 | -W32_LIBS = $(LDLIBS_W32)liblapack.a |
| 33 | -W64_LIBS = $(LDLIBS_W64)liblapack.a |
| 34 | -W32_LIBS += $(LDLIBS_W32)libblas.a |
| 35 | -W64_LIBS += $(LDLIBS_W64)libblas.a |
| 36 | - |
| 37 | - |
| 38 | - |
26 | | @@ -88,10 +93,10 @@ |
| 58 | ### per default only the mex-files for octave are built |
| 59 | -mex4o octave: $(PROGS) |
| 60 | - |
| 61 | +octave: $(PROGS) |
| 62 | |
| 63 | -### Matlab configuration - search for a matlab directory if not defined above |
| 64 | -ifndef MATLABDIR |
| 65 | - ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB)) |
| 66 | - # use oldest, typically mex-files a compatible with newer Matlab versions |
| 67 | - MATLABDIR=/usr/local/MATLAB/$(shell ls -1t /usr/local/MATLAB/ |grep "^R*" |head -1) |
| 68 | - # alternatively, use latest matlab version |
| 69 | - #MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1) |
| 70 | - endif |
| 71 | -endif |
| 72 | - |
| 73 | -### if the MATLABDIR has been found or defined |
| 74 | -ifneq (,MATLABDIR) |
| 75 | - ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext)) |
| 76 | - MEX_EXT=$(shell $(MATLABDIR)/bin/mexext) |
| 77 | - mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS)) |
| 78 | - endif |
| 79 | -endif |
| 80 | - |
| 81 | - |
| 82 | -mexw32 win32: $(patsubst %.mex, %.mexw32, $(PROGS)) |
| 83 | -mexw64 win64: $(patsubst %.mex, %.mexw64, $(PROGS)) |
| 84 | -all: octave win32 win64 mex4m |
| 85 | +all: octave |
| 86 | |
| 87 | clean: |
| 88 | -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex* |
| 89 | |
| 90 | - |
| 91 | ######################################################### |
| 92 | - |
34 | | - $(OCTMEX) "$<" -lgomp -llapack -lblas ## Octave |
35 | | + INCFLAGS="$(INCFLAGS) $(INC_CSTDLIB)" $(OCTMEX) $< $(FLIBS) -lgomp ## Octave |
36 | | %.$(MEX_EXT): %.cpp |
37 | | $(MATMEX) "$<" -lgomp -llapack -lblas ## Matlab |
38 | | |
| 100 | - $(OCTMEX) "$<" -lgomp -llapack -lblas |
| 101 | -%.$(MEX_EXT): %.cpp |
| 102 | - $(MATMEX) "$<" -lgomp -llapack -lblas |
| 103 | - |
| 104 | - |
| 105 | -######################################################### |
| 106 | -# MATLAB/WIN32 |
| 107 | -######################################################### |
| 108 | -%.obj: %.cpp |
| 109 | - $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
| 110 | -%.obj: %.c |
| 111 | - $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
| 112 | - |
| 113 | -%.mexw32: %.obj |
| 114 | - $(CROSS)-$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W32) -lblas -llapack |
| 115 | - |
| 116 | - |
| 117 | -######################################################### |
| 118 | -# MATLAB/WIN64 |
| 119 | -######################################################### |
| 120 | - |
| 121 | -## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash |
| 122 | -%.o64: %.cpp |
| 123 | - $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<" |
| 124 | -%.o64: %.c |
| 125 | - $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<" |
| 126 | - |
| 127 | -%.mexw64: %.o64 |
| 128 | - $(CROSS64)-$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W64) -lblas -llapack |
| 129 | - |
| 130 | - |
| 131 | - |
| 132 | + INCFLAGS="$(INCFLAGS) $(INC_CSTDLIB)" $(OCTMEX) $< $(FLIBS) $(LOCAL_FLAGS) |