1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(nlopt, 1.0.2, stevenj@alum.mit.edu)
3 AC_CONFIG_SRCDIR(api/nlopt.h)
4 SHARED_VERSION_INFO="0:2:0" # CURRENT:REVISION:AGE
7 AM_CONFIG_HEADER(config.h)
8 AC_CONFIG_MACRO_DIR([m4])
10 AC_SUBST(SHARED_VERSION_INFO)
11 AC_DISABLE_SHARED dnl to hell with shared libraries
13 dnl Checks for programs.
24 [AC_HELP_STRING([--with-cxx], [include C++-based routines])],
25 with_cxx=$withval,with_cxx=no)
26 AM_CONDITIONAL(WITH_CXX, test "x$with_cxx" = xyes)
28 if test "x$with_cxx" = xyes; then
29 AC_DEFINE([WITH_CXX], 1, [Define if compiled including C++-based routines])
32 AC_SUBST(NLOPT_SUFFIX)
34 AC_ARG_WITH(windows-f77-mangling, [AC_HELP_STRING([--with-windows-f77-mangling],[use common Win32 Fortran interface styles])], with_windows_f77_mangling=$withval, with_windows_f77_mangling=no)
35 if test "$with_windows_f77_mangling" = "yes"; then
36 AC_DEFINE(WINDOWS_F77_MANGLING,1,[Use common Windows Fortran mangling styles for the Fortran interfaces.])
39 dnl Checks for typedefs, structures, and compiler characteristics.
42 AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
46 dnl find 32-bit unsigned integer type for random-number generator
47 AC_CHECK_SIZEOF(unsigned int)
48 AC_CHECK_SIZEOF(unsigned long)
49 AC_CHECK_TYPES(uint32_t, [], [], [$ac_includes_default
54 dnl Checks for libraries and functions
56 AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time qsort_r])
58 AC_MSG_CHECKING([for isnan])
59 AC_TRY_LINK([#include <math.h>
60 ], if (!isnan(3.14159)) isnan(2.7183);, ok=yes, ok=no)
61 if test "$ok" = "yes"; then
62 AC_DEFINE(HAVE_ISNAN,1,[Define if the isnan() function/macro is available.])
66 AC_MSG_CHECKING([for isinf])
67 AC_TRY_LINK([#include <math.h>
68 ], if (!isinf(3.14159)) isinf(2.7183);, ok=yes, ok=no)
69 if test "$ok" = "yes"; then
70 AC_DEFINE(HAVE_ISINF,1,[Define if the isinf() function/macro is available.])
74 dnl -----------------------------------------------------------------------
76 if test "x$with_cxx" = xyes; then
77 test -r $srcdir/lbfgs/ap.cpp && test -r $srcdir/lbfgs/ap.h && test -r $srcdir/lbfgs/l-bfgs-b.cpp && test -r $srcdir/lbfgs/l-bfgs-b.h && have_lbfgs=yes
79 AM_CONDITIONAL(WITH_NOCEDAL, test -n "$have_lbfgs")
80 if test -n "$have_lbfgs"; then
81 AC_DEFINE(WITH_NOCEDAL, [1], [Define if we have the non-free Nocedal LBFGS code])
84 dnl -----------------------------------------------------------------------
85 dnl Compiling Octave plug-in
87 AC_ARG_VAR(OCT_INSTALL_DIR, [where to install GNU Octave .oct plug-ins])
88 AC_ARG_VAR(M_INSTALL_DIR, [where to install GNU Octave .m plug-ins])
89 AC_ARG_VAR(MKOCTFILE, [name of mkoctfile program to compile Octave plug-ins])
91 AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo)
92 if test "$MKOCTFILE" = "echo"; then
93 AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin])
95 elif test x"$OCT_INSTALL_DIR" = "x"; then
96 # try to find installation directory
97 AC_CHECK_PROGS(OCTAVE, octave, echo)
98 AC_MSG_CHECKING(for Octave loadpath)
99 OCTAVE_LOADPATH=`echo "DEFAULT_LOADPATH" | $OCTAVE -q | cut -d'=' -f2`
100 AC_MSG_RESULT($OCTAVE_LOADPATH)
101 AC_MSG_CHECKING(where Octave plugins go)
102 OCT_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/oct" | head -1`
103 if test -n "$OCT_INSTALL_DIR"; then
104 AC_MSG_RESULT($OCT_INSTALL_DIR)
106 AC_MSG_RESULT(unknown)
107 AC_MSG_WARN([can't find where to install GNU Octave plugins])
109 AC_MSG_CHECKING(where Octave scripts go)
110 M_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/m" | head -1`
111 if test -n "$M_INSTALL_DIR"; then
112 AC_MSG_RESULT($M_INSTALL_DIR)
114 AC_MSG_RESULT(unknown)
115 AC_MSG_WARN([can't find where to install GNU Octave scripts])
118 AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
119 AC_SUBST(OCT_INSTALL_DIR)
120 AC_SUBST(M_INSTALL_DIR)
123 dnl -----------------------------------------------------------------------
124 dnl Compiling Matlab plug-in
126 AC_ARG_VAR(MEX_INSTALL_DIR, [where to install Matlab .mex plug-ins])
127 AC_ARG_VAR(MEX, [name of mex program to compile Matlab plug-ins])
128 AC_CHECK_PROGS(MEX, mex, echo)
129 if test "$MEX" = "echo"; then
130 AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin])
132 AC_MSG_CHECKING([for extension of compiled mex files])
134 cat > conftest.c <<EOF
136 void mexFunction(int nlhs, mxArray *plhs[[]],
137 int nrhs, const mxArray *prhs[[]]) { }
139 if $MEX conftest.c; then
140 MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
141 AC_MSG_RESULT($MEXSUFF)
142 AC_CHECK_PROGS(MATLAB, matlab, echo)
144 AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
148 if test x"$MEX_INSTALL_DIR" = "x"; then
149 # try to find installation directory
150 if test x"$MATLAB" != xecho; then
151 AC_MSG_CHECKING(for MATLAB mex installation dir)
152 MEX_INSTALL_DIR=`matlab -nodisplay -nodesktop -nojvm -r 'path;quit' | grep toolbox/local |sed 's,^[[^/]]*,,g' |sort |head -1`
153 AC_MSG_RESULT($MEX_INSTALL_DIR)
154 if test x`basename "$MEX_INSTALL_DIR"` != xlocal; then
159 if test x"$MEX_INSTALL_DIR" = "x"; then
160 AC_MSG_WARN([can't find reasonable Matlab installation directory; Matlab plugins will not be compiled unless you manually specify MEX_INSTALL_DIR])
163 AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
164 AC_SUBST(MEX_INSTALL_DIR)
168 dnl -----------------------------------------------------------------------
169 dnl Check for broken Solaris HUGE_VAL macro under gcc 3.4.x and similar
171 AC_MSG_CHECKING([for working HUGE_VAL])
172 AC_TRY_COMPILE([#include <math.h>], [double x = -HUGE_VAL;],
173 [AC_MSG_RESULT([ok])],
174 [AC_TRY_COMPILE([#include <math.h>
177 #define HUGE_VAL __builtin_huge_val()
178 #endif], [double x = -HUGE_VAL;],
179 [AC_MSG_RESULT([__builtin_huge_val()])
180 AC_DEFINE(REPLACEMENT_HUGE_VAL,[__builtin_huge_val()],
181 [replacement for broken HUGE_VAL macro, if needed])],
182 [AC_MSG_RESULT([unknown])
183 AC_MSG_ERROR([broken HUGE_VAL macro with this compiler, unknown workaround])])])
185 dnl -----------------------------------------------------------------------
188 AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile with extra runtime checks for debugging])], ok=$enableval, ok=no)
189 if test "$ok" = "yes"; then
190 AC_DEFINE(DEBUG,1,[Define to enable extra debugging code.])
193 dnl override CFLAGS selection when debugging
194 if test "${enable_debug}" = "yes"; then
200 dnl add gcc warnings, in debug/maintainer mode only
201 if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
202 if test $ac_cv_prog_gcc = yes; then
203 if test "$ac_test_CFLAGS" != "set"; then
204 CFLAGS="$CFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic -Wshadow -Wbad-function-cast -Wwrite-strings -Wstrict-prototypes -Wredundant-decls -Wnested-externs -Wundef -Wconversion -Wmissing-prototypes -Wmissing-declarations"
206 if test "$ac_test_CXXFLAGS" != "set"; then
207 CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
212 vers=`echo ${VERSION}.0.0 | cut -d. -f1`
213 AC_DEFINE_UNQUOTED(MAJOR_VERSION, $vers, [Major version number.])
214 vers=`echo ${VERSION}.0.0 | cut -d. -f2`
215 AC_DEFINE_UNQUOTED(MINOR_VERSION, $vers, [Minor version number.])
216 vers=`echo ${VERSION}.0.0 | cut -d. -f3`
217 AC_DEFINE_UNQUOTED(BUGFIX_VERSION, $vers, [Bugfix version number.])
219 dnl -----------------------------------------------------------------------