Mercurial > forge
annotate extra/NaN/src/Makefile @ 12384:5d1eadad45d4 octave-forge
tsa, nan: fix built for mex4m
author | schloegl |
---|---|
date | Wed, 26 Feb 2014 17:53:16 +0000 |
parents | a06636a6401d |
children | 5fbbb9986f8e |
rev | line source |
---|---|
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
1 #################################################### |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
2 # Copyright 2010, 2011,2012 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 |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
9 # Define non-default octave-version |
7993 | 10 # Octave - global install (e.g. from debian package) |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
11 # OCTAVE_VERSION= |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
12 # Better alternative: define an OCTAVE_VERSION bash variable (or in .bashrc or .profile) |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
13 # OCTAVE_VERSION=-3.6.3 |
7993 | 14 |
15 # Matlab configuration | |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
16 #MATLABDIR = /usr/local/MATLAB/R2010b |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
17 # 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
|
18 MEX_OPTION += -largeArrayDims |
7993 | 19 |
7912 | 20 # Mingw crosscompiler: available at http://www.nongnu.org/mingw-cross-env/ |
21 CROSS = $(HOME)/src/mingw-cross-env/usr/bin/i686-pc-mingw32- | |
8066 | 22 CROSS64 = $(HOME)/src/mce-w64/usr/bin/x86_64-w64-mingw32- |
7899 | 23 # include directory for Win32-Matlab include |
8066 | 24 W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/ |
25 W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/ | |
7912 | 26 # path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ |
8066 | 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; | |
7802
03cd0c75b7ac
docu for ML72; highlight user-specific configuration in Makefile
schloegl
parents:
7376
diff
changeset
|
32 #################################################### |
6547 | 33 |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
34 CC = gcc |
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
35 CXX = g++ |
9421
8d2b4cc5c0a1
remove requirement of ZLIB; remove obsolete nan2conv.m
schloegl
parents:
8139
diff
changeset
|
36 CFLAGS = -fopenmp -Wall -Wextra -Wconversion -O2 -fPIC |
7993 | 37 OCTMEX = mkoctfile$(OCTAVE_VERSION) --mex |
7912 | 38 RM = rm |
3901 | 39 |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
40 MEX_OPTION += -lgomp CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS) " CXXFLAGS\#"$(CFLAGS) " |
7912 | 41 MATMEX = $(MATLABDIR)/bin/mex $(MEX_OPTION) |
6560 | 42 |
7899 | 43 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 | 44 |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
45 ### per default only the mex-files for octave are built |
8067 | 46 mex4o octave: $(PROGS) |
8068 | 47 |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
48 |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
49 ### Matlab configuration - search for a matlab directory if not defined above |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
50 ifndef MATLABDIR |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
51 ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB)) |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
52 # use oldest, typically mex-files a compatible with newer Matlab versions |
12384 | 53 MATLABDIR=/usr/local/MATLAB/$(shell ls -1t /usr/local/MATLAB/ |grep "^R*" |head -1) |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
54 # alternatively, use latest matlab version |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
55 #MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1) |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
56 endif |
8067 | 57 endif |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
58 |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
59 ### if the MATLABDIR has been found or defined |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
60 ifneq (,MATLABDIR) |
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
61 ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext)) |
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
62 MEX_EXT=$(shell $(MATLABDIR)/bin/mexext) |
11098
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
63 mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS)) |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
64 endif |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
65 endif |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
66 |
4becffbdb0ea
fix for (presumbably a newer version of ) gnu make; Matlab: search for default installation directory
schloegl
parents:
10621
diff
changeset
|
67 |
7912 | 68 mexw32 win32: $(patsubst %.mex, %.mexw32, $(PROGS)) |
8066 | 69 mexw64 win64: $(patsubst %.mex, %.mexw64, $(PROGS)) |
8068 | 70 all: octave win32 win64 mex4m |
8066 | 71 |
72 clean: | |
73 -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex* | |
3901 | 74 |
10621 | 75 #$(PROGS): Makefile |
8139
3fad4ff49e91
svmpredict_mex: remove command line output; some clean up
schloegl
parents:
8101
diff
changeset
|
76 |
7899 | 77 ######################################################### |
78 # Octave, MATLAB on Linux | |
79 ######################################################### | |
2414 | 80 %.oct: %.cc |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
81 mkoctfile$(OCTAVE_VERSION) "$<" |
2968
e49fc39e8ee0
Add "clean" rules to makefiles and discard exit status
goffioul
parents:
2414
diff
changeset
|
82 |
6549 | 83 %.mex: %.cpp |
12384 | 84 $(OCTMEX) "$<" -lgomp |
6549 | 85 %.$(MEX_EXT): %.cpp |
12384 | 86 $(MATMEX) "$<" -lgomp |
6547 | 87 |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
88 svmtrain_mex.mex svmpredict_mex.mex: svmtrain_mex.cpp svm.h svm.cpp svm_model_matlab.c svmpredict_mex.cpp |
8101
5dfc952387ba
workaround to avoid need for path to mex.h (INCOCTAVE)
schloegl
parents:
8068
diff
changeset
|
89 $(CXX) $(CFLAGS) -c svm.cpp |
5dfc952387ba
workaround to avoid need for path to mex.h (INCOCTAVE)
schloegl
parents:
8068
diff
changeset
|
90 #$(CC) $(CFLAGS) $(INCOCTAVE) -c svm_model_matlab.c |
5dfc952387ba
workaround to avoid need for path to mex.h (INCOCTAVE)
schloegl
parents:
8068
diff
changeset
|
91 env CC=$(CXX) $(OCTMEX) svmtrain_mex.cpp svm.o svm_model_matlab.c |
5dfc952387ba
workaround to avoid need for path to mex.h (INCOCTAVE)
schloegl
parents:
8068
diff
changeset
|
92 env CC=$(CXX) $(OCTMEX) svmpredict_mex.cpp svm.o svm_model_matlab.c |
6549 | 93 |
8139
3fad4ff49e91
svmpredict_mex: remove command line output; some clean up
schloegl
parents:
8101
diff
changeset
|
94 svmtrain_mex.$(MEX_EXT) svmpredict_mex.$(MEX_EXT): svmtrain_mex.cpp svm.h svm.cpp svm_model_matlab.c svmpredict_mex.cpp |
6555 | 95 $(CXX) $(CFLAGS) -I $(MATLABDIR)/extern/include -c svm.cpp |
6586 | 96 $(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
|
97 $(MATMEX) svmtrain_mex.cpp svm.o svm_model_matlab.o |
6554 | 98 $(MATMEX) svmpredict_mex.cpp svm.o svm_model_matlab.o |
6547 | 99 |
6588 | 100 train.$(MEX_EXT) predict.$(MEX_EXT): train.c linear.h tron.o linear.o linear_model_matlab.c |
6563 | 101 $(CC) $(CFLAGS) -I $(MATLABDIR)/extern/include -c linear_model_matlab.c |
6588 | 102 $(MATMEX) -lblas train.c tron.o linear.o linear_model_matlab.o |
6563 | 103 #$(MATMEX) -lblas predict.c tron.o linear.o linear_model_matlab.o |
6560 | 104 |
6588 | 105 train.mex predict.mex: train.c linear.h tron.o linear.o linear_model_matlab.c |
8101
5dfc952387ba
workaround to avoid need for path to mex.h (INCOCTAVE)
schloegl
parents:
8068
diff
changeset
|
106 env CC=$(CXX) $(OCTMEX) -lblas train.c tron.o linear.o linear_model_matlab.c |
6563 | 107 #env CC=$(CXX) $(OCTMEX) -lblas predict.c tron.o linear.o linear_model_matlab.o |
6560 | 108 |
109 linear.o: linear.cpp linear.h | |
110 $(CXX) $(CFLAGS) -c linear.cpp | |
111 | |
112 tron.o: tron.cpp tron.h | |
113 $(CXX) $(CFLAGS) -c tron.cpp | |
114 | |
115 | |
7899 | 116 ######################################################### |
117 # MATLAB/WIN32 | |
118 ######################################################### | |
119 %.obj: %.cpp | |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
120 $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
7899 | 121 %.obj: %.c |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
122 $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<" |
7899 | 123 |
124 train.mexw32 predict.mexw32: train.obj linear.obj linear_model_matlab.obj tron.obj | |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
125 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" linear_model_matlab.obj linear.obj tron.obj -llibmx -llibmex -llibmat -lcholmod -lblas |
7899 | 126 |
7912 | 127 svmpredict_mex.mexw32 : svmpredict_mex.obj svm.obj svm_model_matlab.obj |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
128 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lcholmod |
7899 | 129 svmtrain_mex.mexw32 : svmtrain_mex.obj svm.obj svm_model_matlab.obj |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
130 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lcholmod |
7899 | 131 |
7912 | 132 %.mexw32: %.obj |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
133 $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread |
7899 | 134 |
135 | |
136 | |
8066 | 137 ######################################################### |
138 # MATLAB/WIN64 | |
139 ######################################################### | |
7899 | 140 |
8066 | 141 ## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash |
142 %.o64: %.cpp | |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
143 $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W64MAT_INC) -O2 "$<" |
8066 | 144 %.o64: %.c |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
145 $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W64MAT_INC) -O2 "$<" |
8066 | 146 |
147 train.mexw64 predict.mexw64: train.o64 linear.o64 linear_model_matlab.o64 tron.o64 | |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
148 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" linear_model_matlab.o64 linear.o64 tron.o64 -llibmx -llibmex -llibmat -lcholmod -lblas |
8066 | 149 |
150 svmpredict_mex.mexw64 : svmpredict_mex.o64 svm.o64 svm_model_matlab.o64 | |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
151 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lcholmod |
8066 | 152 svmtrain_mex.mexw64 : svmtrain_mex.o64 svm.o64 svm_model_matlab.o64 |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
153 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lcholmod |
8066 | 154 |
155 %.mexw64: %.o64 | |
12383
a06636a6401d
nan: avoid spurios error messages when no Matlab is installed
schloegl
parents:
11098
diff
changeset
|
156 $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread |
8066 | 157 |