Mercurial > forge
annotate extra/NaN/src/Makefile @ 8066:8d8da31799c0 octave-forge
add support for building mexw64
author | schloegl |
---|---|
date | Fri, 06 May 2011 19:53:34 +0000 |
parents | 6a419bec96bb |
children | 6c6cb24503b9 |
rev | line source |
---|---|
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
1 #################################################### |
7899 | 2 # Copyright 2010, 2011 Alois Schloegl |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
3 # This is part of the NaN-toolbox - a statistics and machine learning toolbox for data with and without missing values. |
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
4 # http://pub.ist.ac.at/~schloegl/matlab/NaN/ |
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
5 #################################################### |
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
6 |
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
7 ### modify directories according to your needs |
7993 | 8 |
9 # Octave - global install (e.g. from debian package) | |
10 OCTAVE_VERSION = | |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
11 INCOCTAVE = -I /usr/include/octave |
8066 | 12 # Octave - local install (e.g. compiled from sources): I recomend to compile with --enable-openmp |
13 #OCTAVE_VERSION = -3.4.0 | |
14 #INCOCTAVE = -I /usr/local/include/octave$(OCTAVE_VERSION)/octave | |
7993 | 15 |
16 # Matlab configuration | |
17 MATLABDIR = /usr/local/MATLAB/R2010b | |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
18 # comment the following line if you use MATLAB on 32-bit operating system |
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
19 MEX_OPTION += -largeArrayDims |
7993 | 20 |
7912 | 21 # Mingw crosscompiler: available at http://www.nongnu.org/mingw-cross-env/ |
22 CROSS = $(HOME)/src/mingw-cross-env/usr/bin/i686-pc-mingw32- | |
8066 | 23 CROSS64 = $(HOME)/src/mce-w64/usr/bin/x86_64-w64-mingw32- |
7899 | 24 # include directory for Win32-Matlab include |
8066 | 25 W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/ |
26 W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/ | |
7912 | 27 # path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ |
8066 | 28 GNUMEX = $(HOME)/bin/win32/gnumex |
29 GNUMEX64 = $(HOME)/bin/win64/gnumex | |
30 # building gnumex64 was difficult, these hints were quite useful: | |
31 # http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinZvxgC9ezp2P3UCX_a7TAUYuVsp2U40MQUV6qr%40mail.gmail.com&forum_name=gnumex-users | |
32 # Instead of building "mex shortpath.c" and "mex uigetpath.c", I used empty m-functions within argout=argin; | |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
33 #################################################### |
6547 | 34 |
35 CC = gcc | |
36 CXX = g++ | |
8037 | 37 CFLAGS = -fopenmp -Wall -Wconversion -O2 -fPIC |
7993 | 38 OCTMEX = mkoctfile$(OCTAVE_VERSION) --mex |
7912 | 39 RM = rm |
3901 | 40 |
8037 | 41 MEX_OPTION += -lz -lgomp CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS)" CXXFLAGS\#"$(CFLAGS)" |
7912 | 42 MATMEX = $(MATLABDIR)/bin/mex $(MEX_OPTION) |
6560 | 43 |
7899 | 44 PROGS = histo_mex.mex covm_mex.mex kth_element.mex sumskipnan_mex.mex str2array.mex train.mex svmtrain_mex.mex svmpredict_mex.mex xptopen.mex |
6547 | 45 |
6560 | 46 MEX_EXT = $(shell $(MATLABDIR)/bin/mexext) |
8066 | 47 mex4o octave: $(PROGS) |
48 mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS)) | |
7912 | 49 mexw32 win32: $(patsubst %.mex, %.mexw32, $(PROGS)) |
8066 | 50 mexw64 win64: $(patsubst %.mex, %.mexw64, $(PROGS)) |
51 all: octave matlab win32 win64 | |
52 | |
53 clean: | |
54 -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex* | |
3901 | 55 |
56 $(PROGS): Makefile | |
2414 | 57 |
7899 | 58 ######################################################### |
59 # Octave, MATLAB on Linux | |
60 ######################################################### | |
2414 | 61 %.oct: %.cc |
7993 | 62 mkoctfile$(OCTAVE_VERSION) $< |
2968
e49fc39e8ee0
Add "clean" rules to makefiles and discard exit status
goffioul
parents:
2414
diff
changeset
|
63 |
6549 | 64 %.mex: %.cpp |
8032 | 65 $(OCTMEX) $< -lz -lgomp ## Octave |
6549 | 66 %.$(MEX_EXT): %.cpp |
8032 | 67 $(MATMEX) $< -lz -lgomp ## Matlab |
6547 | 68 |
6562 | 69 svmtrain_mex.mex svmpredict_mex.mex: svmtrain_mex.cpp svm.h svm.cpp svm_model_matlab.c |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
70 $(CXX) $(CFLAGS) $(INCOCTAVE) -c svm.cpp |
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
71 $(CC) $(CFLAGS) $(INCOCTAVE) -c svm_model_matlab.c |
6549 | 72 env CC=$(CXX) $(OCTMEX) svmtrain_mex.cpp svm.o svm_model_matlab.o |
6554 | 73 env CC=$(CXX) $(OCTMEX) svmpredict_mex.cpp svm.o svm_model_matlab.o |
6549 | 74 |
6562 | 75 svmtrain_mex.$(MEX_EXT) svmpredict_mex.$(MEX_EXT): svmtrain_mex.cpp svm.h svm.cpp svm_model_matlab.c |
6555 | 76 $(CXX) $(CFLAGS) -I $(MATLABDIR)/extern/include -c svm.cpp |
6586 | 77 $(CC) $(CFLAGS) -I $(MATLABDIR)/extern/include -c svm_model_matlab.c |
6552
37ebea0d2428
build for octave must be the default, matlab build is optional
schloegl
parents:
6549
diff
changeset
|
78 $(MATMEX) svmtrain_mex.cpp svm.o svm_model_matlab.o |
6554 | 79 $(MATMEX) svmpredict_mex.cpp svm.o svm_model_matlab.o |
6547 | 80 |
6588 | 81 train.$(MEX_EXT) predict.$(MEX_EXT): train.c linear.h tron.o linear.o linear_model_matlab.c |
6563 | 82 $(CC) $(CFLAGS) -I $(MATLABDIR)/extern/include -c linear_model_matlab.c |
6588 | 83 $(MATMEX) -lblas train.c tron.o linear.o linear_model_matlab.o |
6563 | 84 #$(MATMEX) -lblas predict.c tron.o linear.o linear_model_matlab.o |
6560 | 85 |
6588 | 86 train.mex predict.mex: train.c linear.h tron.o linear.o linear_model_matlab.c |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
87 $(CC) $(CFLAGS) $(INCOCTAVE) -c linear_model_matlab.c |
6588 | 88 env CC=$(CXX) $(OCTMEX) -lblas train.c tron.o linear.o linear_model_matlab.o |
6563 | 89 #env CC=$(CXX) $(OCTMEX) -lblas predict.c tron.o linear.o linear_model_matlab.o |
6560 | 90 |
91 linear.o: linear.cpp linear.h | |
92 $(CXX) $(CFLAGS) -c linear.cpp | |
93 | |
94 tron.o: tron.cpp tron.h | |
95 $(CXX) $(CFLAGS) -c tron.cpp | |
96 | |
97 | |
7899 | 98 ######################################################### |
99 # MATLAB/WIN32 | |
100 ######################################################### | |
101 %.obj: %.cpp | |
8037 | 102 $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 $< |
7899 | 103 %.obj: %.c |
8037 | 104 $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 $< |
7899 | 105 |
106 train.mexw32 predict.mexw32: train.obj linear.obj linear_model_matlab.obj tron.obj | |
107 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o $@ -L$(GNUMEX) -s $< linear_model_matlab.obj linear.obj tron.obj -llibmx -llibmex -llibmat -lz -lcholmod -lblas | |
108 | |
7912 | 109 svmpredict_mex.mexw32 : svmpredict_mex.obj svm.obj svm_model_matlab.obj |
7899 | 110 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o $@ -L$(GNUMEX) -s $< svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lz -lcholmod |
111 svmtrain_mex.mexw32 : svmtrain_mex.obj svm.obj svm_model_matlab.obj | |
112 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o $@ -L$(GNUMEX) -s $< svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lz -lcholmod | |
113 | |
7912 | 114 %.mexw32: %.obj |
8037 | 115 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o $@ -L$(GNUMEX) -s $< -llibmx -llibmex -llibmat -lz -lcholmod -lgomp -lpthread |
7899 | 116 |
117 | |
118 | |
8066 | 119 ######################################################### |
120 # MATLAB/WIN64 | |
121 ######################################################### | |
7899 | 122 |
8066 | 123 ## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash |
124 %.o64: %.cpp | |
125 $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W64MAT_INC) -O2 $< | |
126 %.o64: %.c | |
127 $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W64MAT_INC) -O2 $< | |
128 | |
129 train.mexw64 predict.mexw64: train.o64 linear.o64 linear_model_matlab.o64 tron.o64 | |
130 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o $@ -L$(GNUMEX64) -s $< linear_model_matlab.o64 linear.o64 tron.o64 -llibmx -llibmex -llibmat -lz -lcholmod -lblas | |
131 | |
132 svmpredict_mex.mexw64 : svmpredict_mex.o64 svm.o64 svm_model_matlab.o64 | |
133 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o $@ -L$(GNUMEX64) -s $< svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lz -lcholmod | |
134 svmtrain_mex.mexw64 : svmtrain_mex.o64 svm.o64 svm_model_matlab.o64 | |
135 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o $@ -L$(GNUMEX64) -s $< svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lz -lcholmod | |
136 | |
137 %.mexw64: %.o64 | |
138 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o $@ -L$(GNUMEX64) -s $< -llibmx -llibmex -llibmat -lz -lcholmod -lgomp -lpthread | |
139 |