-
Notifications
You must be signed in to change notification settings - Fork 7
/
configure.ac
executable file
·229 lines (206 loc) · 6.34 KB
/
configure.ac
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
AC_INIT([dwt], [0.1], [[email protected]])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall dist-bzip2])
AC_PROG_CXX
AC_PROG_RANLIB
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_FILES([
Makefile
include/Makefile
src/Makefile
matlab/Makefile
examples/Makefile
])
CFLAGS="${CFLAGS=}"
CXXFLAGS="${CXXFLAGS=}"
AC_SUBST([CFLAGS],["${CFLAGS} -Wall"])
AC_SUBST([CXXFLAGS],["${CXXFLAGS} -Wall"])
AC_ARG_VAR([OPTIM_FLAGS], [Optimization flags (i.e. -march=native, -msse3)])
OPTIM_FLAGS="${OPTIM_FLAGS=}"
AC_SUBST([CXXFLAGS],["${CXXFLAGS} ${OPTIM_FLAGS}"])
AC_SUBST([LDFLAGS],["${LDFLAGS} ${OPTIM_FLAGS}"])
my_save_cflags="$CFLAGS"
CFLAGS="-std=c++11"
AC_MSG_CHECKING([whether CC supports the flag -std=c++11])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[CPP_11_FLAG=-std=c++11],
[AC_MSG_RESULT([no])]
[CPP_11_FLAG=-std=c++0x]
)
CFLAGS="$my_save_cflags"
AC_SUBST([CXXFLAGS],["${CXXFLAGS} ${CPP_11_FLAG}"])
my_save_cflags="$CFLAGS"
CFLAGS="-fstrict-aliasing"
AC_MSG_CHECKING([whether CC supports the flag -fstrict-aliasing])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
AC_SUBST([CXXFLAGS],["${CXXFLAGS} -fstrict-aliasing"]),
[AC_MSG_RESULT([no])]
)
CFLAGS="$my_save_cflags"
my_save_cflags="$CFLAGS"
CFLAGS="-fPIC"
AC_MSG_CHECKING([whether CC supports the flag -fPIC])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
AC_SUBST([CXXFLAGS],["${CXXFLAGS} -fPIC"])
AC_SUBST([LDFLAGS],["${LDFLAGS} -fPIC"]),
[AC_MSG_RESULT([no])]
)
CFLAGS="$my_save_cflags"
###############################################################################
# Definitions
dnl CHECK_MEX_SUFFIX(list-of-suffices, variable-to-set)
AC_DEFUN([CHECK_MEX_SUFFIX],[
cat >conftest.cc <<_ACEOF
extern "C" void mexFunction() {
}
_ACEOF
$CXX -fPIC -c -o conftest.o conftest.cc
$MEX -cxx -output conftest conftest.o
$2=""
for suffix in $1; do
if test -f "conftest.$suffix"; then
$2="$suffix"
rm -f "conftest.$suffix"
fi
done
rm -f conftest.cc conftest.o
])
###############################################################################
# Debug builds
AC_ARG_WITH(messaging,
AS_HELP_STRING([--with-messaging=level],
[enable various messaging levels, default: 1 (info)
Options: 3 (debug), 2 (warnings), 1 (info), 0 (no messages)]),
[ case "${withval}" in
3) messaging=debug ;;
2) messaging=warn ;;
1) messaging=info ;;
0) messaging=nomessage ;;
false) messaging=nomessage ;;
no) messaging=nomessage ;;
*) AC_MSG_ERROR([bad value ${withval} for --with-messaging]) ;;
esac],
[messaging=info])
AS_IF([test "x$messaging" == xdebug],
[AC_DEFINE([DEBUG], [1],
[Define if you want a debug build])
])
AS_IF([test "x$messaging" == xwarn],
[AC_DEFINE([WARNING], [1],
[Define if you want a build with warning information])
])
AS_IF([test "x$messaging" == xinfo],
[AC_DEFINE([INFO], [1],
[Define if you want a build with information])
])
AS_IF([test "x$CXX" == xclang++],
[AC_SUBST([CXXFLAGS],["${CXXFLAGS} -stdlib=libc++"])
])
AC_ARG_WITH(matlab,
AS_HELP_STRING([--with-matlab=<path>],
[compiles matlab's mex interface]),
[],
[with_matlab=no])
MATLAB_PATH=$PATH
HAVE_MATLAB=no
AS_IF([test x$with_matlab != xno],
[MEX_PATH="$with_matlab/bin:$PATH"]
[AC_PATH_PROG([MEX], [mex], [no], [$MEX_PATH])]
[AS_IF([test x$MEX != xno],
[HAVE_MATLAB=yes]
[AC_SUBST(MEX)]
[MATLAB_ROOT="$with_matlab"]
[AC_SUBST(MATLAB_ROOT)]
[with_matlab=yes]
[CHECK_MEX_SUFFIX([mexa64 mexglx mexmaci64 mexmaci],[MEXSUFFIX])]
[AS_IF([test x$MEXSUFFIX != x],
[AC_SUBST(MEXSUFFIX)],
[with_matlab=no]
)
],
[with_matlab=no]
)
],
[with_matlab=no]
)
AC_SUBST(HAVE_MATLAB)
AC_ARG_WITH(octave,
AS_HELP_STRING([--with-octave=<path>],
[compiles octave's oct interface]),
[],
[with_octave=no])
OCTAVE_PATH=$PATH
HAVE_OCTAVE=no
AS_IF([test x$with_octave != xno],
[OCT_PATH="$with_octave/bin:$PATH"]
[AC_PATH_PROG([MKOCTFILE], [mkoctfile], [no], [$OCT_PATH])]
[AS_IF([test x$MKOCTFILE != xno],
[HAVE_OCTAVE=yes]
[AC_SUBST(MKOCTFILE)]
[with_octave=yes],
[with_octave=no]
)
],
[with_octave=no]
)
AC_SUBST(HAVE_OCTAVE)
#AM_CONDITIONAL([WITH_OCTAVE], [test "x$with_octave" = xyes])
AC_ARG_ENABLE([vector],
AS_HELP_STRING([--disable-vector], [Disable vectorization extensions])
)
AS_IF([test "x$enable_vector" != "xno"],
[AC_DEFINE([USE_VECTORIZATION], [1], [Define if you want vectorization extensions to be used])]
[enable_vector=yes])
AC_ARG_ENABLE([openmp],
AS_HELP_STRING([--disable-openmp], [Disable OpenMP parallelization support])
)
AS_IF([test "x$enable_openmp" != "xno"],
[AC_DEFINE([HAVE_OMP], [1], [Define if you want OpenMP parallelization to be used])]
[enable_openmp=yes]
[AC_SUBST([CXXFLAGS],["${CXXFLAGS} -fopenmp"])]
[AC_SUBST([LDFLAGS],["${LDFLAGS} -fopenmp"])] )
AC_SUBST([enable_openmp])
#AS_IF([test "x$messaging" != xdebug],
# [ AC_SUBST([CFLAGS],["${CFLAGS} -fomit-frame-pointer -fforce-addr"])
# AC_SUBST([CXXFLAGS],["${CXXFLAGS} -fomit-frame-pointer -fforce-addr"])
# ])
###############################################################################
AC_OUTPUT
dnl
dnl Output some configuration info for the user
dnl
echo ""
echo " Configuration summary:"
echo ""
echo " prefix: $prefix"
echo " exec_prefix: $exec_prefix"
echo " libdir: $libdir"
echo " includedir: $includedir"
dnl
dnl Output the features included
dnl
echo ""
echo " CXXFLAGS: $CXXFLAGS"
echo ""
echo " Vectorization: $enable_vector"
echo ""
echo " OpenMP: $enable_openmp"
echo ""
echo " With octave: $with_octave"
if test x$with_octave == xyes; then
echo " Mkoctfile path: $MKOCTFILE"
fi
echo ""
echo " With matlab: $with_matlab"
if test x$with_matlab == xyes; then
echo " Matlab path: $MATLAB_ROOT"
echo " Mex suffix: $MEXSUFFIX"
fi
echo ""
echo " Verbosity level: $messaging"
echo ""
echo ""