forked from pcarbo/lbfgsb-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (93 loc) · 3.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# NOTES:
#
# - For 'make nomex', define variables MEX_SUFFIX and MATLAB_LIB.
# - For 'make mex', define variable MEX, and setup mex.
# - For 'make oct', define variables OCT and OCTAVE_INCLUDE.
#
# CHOOSE MATLAB CONFIGURATION
# This should be the path to your Matlab installation
# you can find it by the commands 'locate matlab' or 'find / -name "matlab"'
MATLAB_HOME = /usr/local/share/matlabR2008b
# For 32-bit Linux, uncomment these 3 lines.
# MEX = $(MATLAB_HOME)/bin/mex
# MEX_SUFFIX = mexglx
# MATLAB_LIB = -L$(MATLAB_HOME)/bin/glnx86 -lmex
# For 64-bit Linux, uncomment these 3 lines.
MEX = $(MATLAB_HOME)/bin/mex
MEX_SUFFIX = mexa64
MATLAB_LIB = -L$(MATLAB_HOME)/bin/glnxa64 -lmex
# For Mac OS X, uncomment these 3 lines.
# MEX = /Applications/MATLAB7/bin/mex
# MEX_SUFFIX = mexmac
# MATLAB_LIB = -L$(MATLAB_HOME)/bin/maci -lmex
# CHOOSE OCTAVE CONFIGURATION
OCTAVE_INCLUDE = /usr/local/include/octave-3.2.4/octave
OCT = mkoctfile
# CHOOSE L-BFGS-B CONFIGURATION
# Uncomment these 2 lines for LBFGSB 2.4.
# LBFGSB_OBJS = solver24.o
# LIBS =
# Uncomment these 2 lines for LFBGSB 3.0 with the BLAS code included along
# with the rest of the code in this repository.
LBFGSB_OBJS = solver30.o linpack.o timer.o blas.o
LIBS =
# Uncomment the following 2 lines for LFBGSB 3.0 with your locally
# installed BLAS library.
# LBFGSB_OBJS = solver30.o linpack.o timer.o
# LIBS = -lblas
# CHOOSE FORTRAN COMPILER
FFLAGS = -O3 -fPIC -fexceptions -Wall -g -Wno-uninitialized
# If f77 is your Fortran compiler, uncomment these 2 lines.
# F77 = f77
# FORTRAN_LIB = g2c
# If gfortran is your Fortran compiler, uncomment the following two lines.
F77 = gfortran
FORTRAN_LIB = gfortran
# CONFIGURE C++ COMPILER.
CXX = g++
CFLAGS = -O3 -fPIC -pthread -Wall -Werror -ansi -ffast-math \
-fomit-frame-pointer -std=c++11
# If you need to specify extra directories where to look for libraries,
# write the paths of the directories, separated by a white space.
#LIBDIRS = /usr/lib/gcc/x86_64-linux-gnu/4.8/
LIBDIRS =
# Choose your installation directory relative to the src directory.
INSTALLDIR = ../lib
######################################################################
### Do not edit below ################################################
######################################################################
TARGET = lbfgsb
OBJS = $(LBFGSB_OBJS) matlabexception.o matlabscalar.o matlabstring.o \
matlabmatrix.o arrayofmatrices.o program.o matlabprogram.o \
lbfgsb.o
%.o: %.cpp
$(CXX) $(CFLAGS) -I$(OCTAVE_INCLUDE) \
-I$(MATLAB_HOME)/extern/include -o $@ -c $^
%.o: %.f
$(F77) $(FFLAGS) -o $@ -c $^
all: nomex
mex: $(TARGET)_mex tidy
nomex: $(TARGET)_nomex tidy
octave: $(TARGET)_octave tidy
oct: octave
$(TARGET)_mex: $(OBJS)
$(MEX) -cxx CXX=$(CXX) CC=$(CXX) FC=$(FCC) LD=$(CXX) \
-l$(FORTRAN_LIB) -lm -O -output $@ $^
$(TARGET)_nomex: $(OBJS)
$(CXX) $^ -shared -o $(TARGET).$(MEX_SUFFIX) $(MATLAB_LIB) \
$(addprefix -L,$(LIBDIRS)) -l$(FORTRAN_LIB) -lm
$(TARGET)_octave: $(OBJS)
$(OCT) --mex -o $(TARGET).mex $^ $(LIBS)$
create-install-dir:
@if [ ! -e $(INSTALLDIR) ]; then \
mkdir $(INSTALLDIR); \
fi
cp *.m $(INSTALLDIR)
install: create-install-dir
mv $(TARGET).mex* $(INSTALLDIR)
tidy:
rm -f *.o *.so
clean: tidy
rm -f $(TARGET).mex* $(INSTALLDIR)/$(TARGET).mex*
deep-clean: clean
rm -f $(INSTALLDIR) -R