1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(nlopt, 0.1, stevenj@alum.mit.edu)
3 AC_CONFIG_SRCDIR(api/nlopt.h)
4 SHARED_VERSION_INFO="0:0:0" # CURRENT:REVISION:AGE
7 AM_CONFIG_HEADER(config.h)
9 AC_SUBST(SHARED_VERSION_INFO)
10 AC_DISABLE_SHARED dnl to hell with shared libraries
12 dnl Checks for programs.
23 [AC_HELP_STRING([--with-cxx], [include C++-based routines])],
24 with_cxx=$withval,with_cxx=no)
25 AM_CONDITIONAL(WITH_CXX, test "x$with_cxx" = xyes)
26 if test "x$with_cxx" = xyes; then
28 AC_DEFINE([WITH_CXX], 1, [Define if compiled including C++-based routines])
31 AC_SUBST(NLOPT_SUFFIX)
33 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)
34 if test "$with_windows_f77_mangling" = "yes"; then
35 AC_DEFINE(WINDOWS_F77_MANGLING,1,[Use common Windows Fortran mangling styles for the Fortran interfaces.])
38 dnl Checks for typedefs, structures, and compiler characteristics.
41 AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
45 dnl find 32-bit unsigned integer type for random-number generator
46 AC_CHECK_SIZEOF(unsigned int)
47 AC_CHECK_SIZEOF(unsigned long)
48 AC_CHECK_TYPES(uint32_t, [], [], [$ac_includes_default
53 dnl Checks for libraries and functions
55 AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time])
57 AC_MSG_CHECKING([for isnan])
58 AC_TRY_LINK([#include <math.h>
59 ], if (!isnan(3.14159)) isnan(2.7183);, ok=yes, ok=no)
60 if test "$ok" = "yes"; then
61 AC_DEFINE(HAVE_ISNAN,1,[Define if the isnan() function/macro is available.])
65 AC_MSG_CHECKING([for isinf])
66 AC_TRY_LINK([#include <math.h>
67 ], if (!isinf(3.14159)) isinf(2.7183);, ok=yes, ok=no)
68 if test "$ok" = "yes"; then
69 AC_DEFINE(HAVE_ISINF,1,[Define if the isinf() function/macro is available.])
73 dnl -----------------------------------------------------------------------
75 if test "x$with_cxx" = xyes; then
76 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
78 AM_CONDITIONAL(WITH_NOCEDAL, test -n "$have_lbfgs")
79 if test -n "$have_lbfgs"; then
80 AC_DEFINE(WITH_NOCEDAL, [1], [Define if we have the non-free Nocedal LBFGS code])
83 dnl -----------------------------------------------------------------------
84 dnl Compiling Octave plug-in
86 AC_ARG_VAR(OCT_INSTALL_DIR, [where to install GNU Octave .oct plug-ins])
87 AC_ARG_VAR(M_INSTALL_DIR, [where to install GNU Octave .m plug-ins])
88 AC_ARG_VAR(MKOCTFILE, [name of mkoctfile program to compile Octave plug-ins])
90 AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo)
91 if test "$MKOCTFILE" = "echo"; then
92 AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin])
93 elif test x"$OCT_INSTALL_DIR" = "x"; then
94 # try to find installation directory
95 AC_CHECK_PROGS(OCTAVE, octave, echo)
96 AC_MSG_CHECKING(for Octave loadpath)
97 OCTAVE_LOADPATH=`echo "DEFAULT_LOADPATH" | $OCTAVE -q | cut -d'=' -f2`
98 AC_MSG_RESULT($OCTAVE_LOADPATH)
99 AC_MSG_CHECKING(where Octave plugins go)
100 OCT_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/oct" | head -1`
101 if test -n "$OCT_INSTALL_DIR"; then
102 AC_MSG_RESULT($OCT_INSTALL_DIR)
104 AC_MSG_RESULT(unknown)
105 AC_MSG_WARN([can't find where to install GNU Octave plugins])
107 AC_MSG_CHECKING(where Octave scripts go)
108 M_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/m" | head -1`
109 if test -n "$M_INSTALL_DIR"; then
110 AC_MSG_RESULT($M_INSTALL_DIR)
112 AC_MSG_RESULT(unknown)
113 AC_MSG_WARN([can't find where to install GNU Octave scripts])
116 AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
117 AC_SUBST(OCT_INSTALL_DIR)
118 AC_SUBST(M_INSTALL_DIR)
121 dnl -----------------------------------------------------------------------
122 dnl Compiling Matlab plug-in
124 AC_ARG_VAR(MEX_INSTALL_DIR, [where to install Matlab .mex plug-ins])
125 AC_ARG_VAR(MEX, [name of mex program to compile Matlab plug-ins])
126 AC_CHECK_PROGS(MEX, mex, echo)
127 if test "$MEX" = "echo"; then
128 AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin])
129 elif test x"$MEX_INSTALL_DIR" = "x"; then
130 AC_MSG_CHECKING([for extension of compiled mex files])
132 cat > conftest.c <<EOF
134 void mexFunction(int nlhs, mxArray *plhs[[]],
135 int nrhs, const mxArray *prhs[[]]) { }
137 if $MEX conftest.c; then
138 MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
139 AC_MSG_RESULT($MEXSUFF)
140 AC_CHECK_PROGS(MATLAB, matlab, echo)
142 AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
146 # try to find installation directory
147 if test x"$MATLAB" = xecho; then
148 AC_MSG_WARN([can't fine Matlab; won't compile Matlab plugin])
150 AC_MSG_CHECKING(for MATLAB mex installation dir)
151 matlabpath_line=`matlab -n | grep -n MATLABPATH |head -1 |cut -d: -f1`
152 matlabpath_line=`expr $matlabpath_line + 1`
153 MEX_INSTALL_DIR=`matlab -n | tail -n +$matlabpath_line | head -1 | tr -d ' '`
154 AC_MSG_RESULT($MEX_INSTALL_DIR)
157 AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
158 AC_SUBST(MEX_INSTALL_DIR)
162 dnl -----------------------------------------------------------------------
165 AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile with extra runtime checks for debugging])], ok=$enableval, ok=no)
166 if test "$ok" = "yes"; then
167 AC_DEFINE(DEBUG,1,[Define to enable extra debugging code.])
170 dnl override CFLAGS selection when debugging
171 if test "${enable_debug}" = "yes"; then
177 dnl add gcc warnings, in debug/maintainer mode only
178 if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
179 if test $ac_cv_prog_gcc = yes; then
180 if test "$ac_test_CFLAGS" != "set"; then
181 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"
183 if test "$ac_test_CXXFLAGS" != "set"; then
184 CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
189 vers=`echo ${VERSION}.0.0 | cut -d. -f1`
190 AC_DEFINE_UNQUOTED(MAJOR_VERSION, $vers, [Major version number.])
191 vers=`echo ${VERSION}.0.0 | cut -d. -f2`
192 AC_DEFINE_UNQUOTED(MINOR_VERSION, $vers, [Minor version number.])
193 vers=`echo ${VERSION}.0.0 | cut -d. -f3`
194 AC_DEFINE_UNQUOTED(BUGFIX_VERSION, $vers, [Bugfix version number.])
196 dnl -----------------------------------------------------------------------