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 dnl Checks for typedefs, structures, and compiler characteristics.
36 AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
40 dnl find 32-bit unsigned integer type for random-number generator
41 AC_CHECK_SIZEOF(unsigned int)
42 AC_CHECK_SIZEOF(unsigned long)
43 AC_CHECK_TYPES(uint32_t, [], [], [$ac_includes_default
48 dnl Checks for libraries and functions
50 AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time])
52 AC_MSG_CHECKING([for isnan])
53 AC_TRY_LINK([#include <math.h>
54 ], if (!isnan(3.14159)) isnan(2.7183);, ok=yes, ok=no)
55 if test "$ok" = "yes"; then
56 AC_DEFINE(HAVE_ISNAN,1,[Define if the isnan() function/macro is available.])
60 AC_MSG_CHECKING([for isinf])
61 AC_TRY_LINK([#include <math.h>
62 ], if (!isinf(3.14159)) isinf(2.7183);, ok=yes, ok=no)
63 if test "$ok" = "yes"; then
64 AC_DEFINE(HAVE_ISINF,1,[Define if the isinf() function/macro is available.])
68 dnl -----------------------------------------------------------------------
70 if test "x$with_cxx" = xyes; then
71 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
73 AM_CONDITIONAL(WITH_NOCEDAL, test -n "$have_lbfgs")
74 if test -n "$have_lbfgs"; then
75 AC_DEFINE(WITH_NOCEDAL, [1], [Define if we have the non-free Nocedal LBFGS code])
78 dnl -----------------------------------------------------------------------
79 dnl Compiling Octave plug-in
81 AC_ARG_VAR(OCT_INSTALL_DIR, [where to install GNU Octave .oct plug-ins])
82 AC_ARG_VAR(M_INSTALL_DIR, [where to install GNU Octave .m plug-ins])
83 AC_ARG_VAR(MKOCTFILE, [name of mkoctfile program to compile Octave plug-ins])
85 AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo)
86 if test "$MKOCTFILE" = "echo"; then
87 AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin])
88 elif test x"$OCT_INSTALL_DIR" = "x"; then
89 # try to find installation directory
90 AC_CHECK_PROGS(OCTAVE, octave, echo)
91 AC_MSG_CHECKING(for Octave loadpath)
92 OCTAVE_LOADPATH=`echo "DEFAULT_LOADPATH" | $OCTAVE -q | cut -d'=' -f2`
93 AC_MSG_RESULT($OCTAVE_LOADPATH)
94 AC_MSG_CHECKING(where Octave plugins go)
95 OCT_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/oct" | head -1`
96 if test -n "$OCT_INSTALL_DIR"; then
97 AC_MSG_RESULT($OCT_INSTALL_DIR)
99 AC_MSG_RESULT(unknown)
100 AC_MSG_WARN([can't find where to install GNU Octave plugins])
102 AC_MSG_CHECKING(where Octave scripts go)
103 M_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/m" | head -1`
104 if test -n "$M_INSTALL_DIR"; then
105 AC_MSG_RESULT($M_INSTALL_DIR)
107 AC_MSG_RESULT(unknown)
108 AC_MSG_WARN([can't find where to install GNU Octave scripts])
111 AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
112 AC_SUBST(OCT_INSTALL_DIR)
113 AC_SUBST(M_INSTALL_DIR)
116 dnl -----------------------------------------------------------------------
117 dnl Compiling Matlab plug-in
119 AC_ARG_VAR(MEX_INSTALL_DIR, [where to install Matlab .mex plug-ins])
120 AC_ARG_VAR(MEX, [name of mex program to compile Matlab plug-ins])
121 AC_CHECK_PROGS(MEX, mex, echo)
122 if test "$MEX" = "echo"; then
123 AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin])
124 elif test x"$MEX_INSTALL_DIR" = "x"; then
125 AC_MSG_CHECKING([for extension of compiled mex files])
127 cat > conftest.c <<EOF
129 void mexFunction(int nlhs, mxArray *plhs[[]],
130 int nrhs, const mxArray *prhs[[]]) { }
132 if $MEX conftest.c; then
133 MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
134 AC_MSG_RESULT($MEXSUFF)
135 AC_CHECK_PROGS(MATLAB, matlab, echo)
137 AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
141 # try to find installation directory
142 if test x"$MATLAB" = xecho; then
143 AC_MSG_WARN([can't fine Matlab; won't compile Matlab plugin])
145 AC_MSG_CHECKING(for MATLAB mex installation dir)
146 matlabpath_line=`matlab -n | grep -n MATLABPATH |head -1 |cut -d: -f1`
147 matlabpath_line=`expr $matlabpath_line + 1`
148 MEX_INSTALL_DIR=`matlab -n | tail -n +$matlabpath_line | head -1 | tr -d ' '`
149 AC_MSG_RESULT($MEX_INSTALL_DIR)
152 AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
153 AC_SUBST(MEX_INSTALL_DIR)
157 dnl -----------------------------------------------------------------------
160 AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile with extra runtime checks for debugging])], ok=$enableval, ok=no)
161 if test "$ok" = "yes"; then
162 AC_DEFINE(DEBUG,1,[Define to enable extra debugging code.])
165 dnl override CFLAGS selection when debugging
166 if test "${enable_debug}" = "yes"; then
172 dnl add gcc warnings, in debug/maintainer mode only
173 if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
174 if test $ac_cv_prog_gcc = yes; then
175 if test "$ac_test_CFLAGS" != "set"; then
176 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"
178 if test "$ac_test_CXXFLAGS" != "set"; then
179 CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
184 vers=`echo ${VERSION}.0.0 | cut -d. -f1`
185 AC_DEFINE_UNQUOTED(MAJOR_VERSION, $vers, [Major version number.])
186 vers=`echo ${VERSION}.0.0 | cut -d. -f2`
187 AC_DEFINE_UNQUOTED(MINOR_VERSION, $vers, [Minor version number.])
188 vers=`echo ${VERSION}.0.0 | cut -d. -f3`
189 AC_DEFINE_UNQUOTED(BUGFIX_VERSION, $vers, [Bugfix version number.])
191 dnl -----------------------------------------------------------------------