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.
22 [AC_HELP_STRING([--with-cxx], [include C++-based routines])],
23 with_cxx=$withval,with_cxx=no)
24 AM_CONDITIONAL(WITH_CXX, test "x$with_cxx" = xyes)
25 if test "x$with_cxx" = xyes; then
27 AC_DEFINE([WITH_CXX], 1, [Define if compiled including C++-based routines])
30 dnl Checks for typedefs, structures, and compiler characteristics.
33 AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
37 dnl find 32-bit unsigned integer type for random-number generator
38 AC_CHECK_SIZEOF(unsigned int)
39 AC_CHECK_SIZEOF(unsigned long)
40 AC_CHECK_TYPES(uint32_t, [], [], [$ac_includes_default
45 dnl Checks for libraries and functions
47 AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time])
49 AC_MSG_CHECKING([for isnan])
50 AC_TRY_LINK([#include <math.h>
51 ], if (!isnan(3.14159)) isnan(2.7183);, ok=yes, ok=no)
52 if test "$ok" = "yes"; then
53 AC_DEFINE(HAVE_ISNAN,1,[Define if the isnan() function/macro is available.])
57 AC_MSG_CHECKING([for isinf])
58 AC_TRY_LINK([#include <math.h>
59 ], if (!isinf(3.14159)) isinf(2.7183);, ok=yes, ok=no)
60 if test "$ok" = "yes"; then
61 AC_DEFINE(HAVE_ISINF,1,[Define if the isinf() function/macro is available.])
65 dnl -----------------------------------------------------------------------
67 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
68 AM_CONDITIONAL(WITH_NOCEDAL, test -n "$have_lbfgs")
69 if test -n "$have_lbfgs"; then
70 AC_DEFINE(WITH_NOCEDAL, [1], [Define if we have the non-free Nocedal LBFGS code])
73 dnl -----------------------------------------------------------------------
74 dnl Compiling Octave plug-in
76 AC_ARG_VAR(OCT_INSTALL_DIR, [where to install GNU Octave .oct plug-ins])
77 AC_ARG_VAR(M_INSTALL_DIR, [where to install GNU Octave .m plug-ins])
78 AC_ARG_VAR(MKOCTFILE, [name of mkoctfile program to compile Octave plug-ins])
80 AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo)
81 if test "$MKOCTFILE" = "echo"; then
82 AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin])
83 elif test x"$OCT_INSTALL_DIR" = "x"; then
84 # try to find installation directory
85 AC_CHECK_PROGS(OCTAVE, octave, echo)
86 AC_MSG_CHECKING(for Octave loadpath)
87 OCTAVE_LOADPATH=`echo "DEFAULT_LOADPATH" | $OCTAVE -q | cut -d'=' -f2`
88 AC_MSG_RESULT($OCTAVE_LOADPATH)
89 AC_MSG_CHECKING(where Octave plugins go)
90 OCT_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/oct" | head -1`
91 if test -n "$OCT_INSTALL_DIR"; then
92 AC_MSG_RESULT($OCT_INSTALL_DIR)
94 AC_MSG_RESULT(unknown)
95 AC_MSG_WARN([can't find where to install GNU Octave plugins])
97 AC_MSG_CHECKING(where Octave scripts go)
98 M_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/m" | head -1`
99 if test -n "$M_INSTALL_DIR"; then
100 AC_MSG_RESULT($M_INSTALL_DIR)
102 AC_MSG_RESULT(unknown)
103 AC_MSG_WARN([can't find where to install GNU Octave scripts])
106 AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
107 AC_SUBST(OCT_INSTALL_DIR)
108 AC_SUBST(M_INSTALL_DIR)
111 dnl -----------------------------------------------------------------------
112 dnl Compiling Matlab plug-in
114 AC_ARG_VAR(MEX_INSTALL_DIR, [where to install Matlab .mex plug-ins])
115 AC_ARG_VAR(MEX, [name of mex program to compile Matlab plug-ins])
116 AC_CHECK_PROGS(MEX, mex, echo)
117 if test "$MEX" = "echo"; then
118 AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin])
119 elif test x"$MEX_INSTALL_DIR" = "x"; then
120 AC_MSG_CHECKING([for extension of compiled mex files])
122 cat > conftest.c <<EOF
124 void mexFunction(int nlhs, mxArray *plhs[[]],
125 int nrhs, const mxArray *prhs[[]]) { }
127 if $MEX conftest.c; then
128 MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
129 AC_MSG_RESULT($MEXSUFF)
130 AC_CHECK_PROGS(MATLAB, matlab, echo)
132 AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
136 # try to find installation directory
137 if test x"$MATLAB" = xecho; then
138 AC_MSG_WARN([can't fine Matlab; won't compile Matlab plugin])
140 AC_MSG_CHECKING(for MATLAB mex installation dir)
141 matlabpath_line=`matlab -n | grep -n MATLABPATH |head -1 |cut -d: -f1`
142 matlabpath_line=`expr $matlabpath_line + 1`
143 MEX_INSTALL_DIR=`matlab -n | tail -n +$matlabpath_line | head -1 | tr -d ' '`
144 AC_MSG_RESULT($MEX_INSTALL_DIR)
147 AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
148 AC_SUBST(MEX_INSTALL_DIR)
152 dnl -----------------------------------------------------------------------
155 AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile with extra runtime checks for debugging])], ok=$enableval, ok=no)
156 if test "$ok" = "yes"; then
157 AC_DEFINE(DEBUG,1,[Define to enable extra debugging code.])
160 dnl override CFLAGS selection when debugging
161 if test "${enable_debug}" = "yes"; then
167 dnl add gcc warnings, in debug/maintainer mode only
168 if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
169 if test $ac_cv_prog_gcc = yes; then
170 if test "$ac_test_CFLAGS" != "set"; then
171 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"
173 if test "$ac_test_CXXFLAGS" != "set"; then
174 CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
179 vers=`echo ${VERSION}.0.0 | cut -d. -f1`
180 AC_DEFINE_UNQUOTED(MAJOR_VERSION, $vers, [Major version number.])
181 vers=`echo ${VERSION}.0.0 | cut -d. -f2`
182 AC_DEFINE_UNQUOTED(MINOR_VERSION, $vers, [Minor version number.])
183 vers=`echo ${VERSION}.0.0 | cut -d. -f3`
184 AC_DEFINE_UNQUOTED(BUGFIX_VERSION, $vers, [Bugfix version number.])
186 dnl -----------------------------------------------------------------------