chiark / gitweb /
added NEWUOA, unified starting step-size for derivative-free algorithms
[nlopt.git] / configure.ac
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
5
6 AM_INIT_AUTOMAKE(1.7)
7 AM_CONFIG_HEADER(config.h)
8 AM_MAINTAINER_MODE
9 AC_SUBST(SHARED_VERSION_INFO)
10 AC_DISABLE_SHARED dnl to hell with shared libraries
11
12 dnl Checks for programs.
13 AC_PROG_CC
14 AC_PROG_CC_STDC
15 AC_PROG_INSTALL
16 AC_PROG_LN_S
17 AC_PROG_MAKE_SET
18 AC_LIBTOOL_WIN32_DLL
19 AC_PROG_LIBTOOL
20
21 NLOPT_SUFFIX=""
22 AC_ARG_WITH(cxx,
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
27    AC_PROG_CXX
28    AC_DEFINE([WITH_CXX], 1, [Define if compiled including C++-based routines])
29    NLOPT_SUFFIX="_cxx"
30 fi
31 AC_SUBST(NLOPT_SUFFIX)
32
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.])
36 fi
37
38 dnl Checks for typedefs, structures, and compiler characteristics.
39 AC_HEADER_STDC
40 AC_HEADER_TIME
41 AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
42 AC_C_CONST
43 AC_C_INLINE
44
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
49 #ifdef HAVE_STDINT_H
50 #  include <stdint.h>
51 #endif])
52
53 dnl Checks for libraries and functions
54 AC_CHECK_LIB(m, sin)
55 AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time])
56
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.])
62 fi
63 AC_MSG_RESULT(${ok})
64
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.])
70 fi
71 AC_MSG_RESULT(${ok})
72
73 dnl -----------------------------------------------------------------------
74
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
77 fi
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])
81 fi
82
83 dnl -----------------------------------------------------------------------
84 dnl Compiling Octave plug-in
85
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])
89
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)
103         else
104                 AC_MSG_RESULT(unknown)
105                 AC_MSG_WARN([can't find where to install GNU Octave plugins])
106         fi
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)
111         else
112                 AC_MSG_RESULT(unknown)
113                 AC_MSG_WARN([can't find where to install GNU Octave scripts])
114         fi
115 fi
116 AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
117 AC_SUBST(OCT_INSTALL_DIR)
118 AC_SUBST(M_INSTALL_DIR)
119 AC_SUBST(MKOCTFILE)
120
121 dnl -----------------------------------------------------------------------
122 dnl Compiling Matlab plug-in
123
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])
131      rm -f conftest*
132      cat > conftest.c <<EOF
133 #include <mex.h>
134 void mexFunction(int nlhs, mxArray *plhs[[]],
135                  int nrhs, const mxArray *prhs[[]]) { }
136 EOF
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)
141      else
142            AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
143         MATLAB=echo
144      fi
145
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])
149      else
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)
155       fi
156 fi
157 AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
158 AC_SUBST(MEX_INSTALL_DIR)
159 AC_SUBST(MEX)
160 AC_SUBST(MEXSUFF)
161
162 dnl -----------------------------------------------------------------------
163 dnl Debugging
164
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.])
168 fi
169
170 dnl override CFLAGS selection when debugging
171 if test "${enable_debug}" = "yes"; then
172         CFLAGS="-g"
173         CXXFLAGS="-g"
174         FFLAGS="-g"
175 fi
176
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"
182    fi
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"
185    fi
186 fi
187 fi
188
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.])
195
196 dnl -----------------------------------------------------------------------
197
198 AC_CONFIG_FILES([
199    Makefile
200    nlopt.pc
201    api/Makefile
202    util/Makefile
203    octave/Makefile
204    direct/Makefile
205    cdirect/Makefile
206    stogo/Makefile
207    subplex/Makefile
208    praxis/Makefile
209    lbfgs/Makefile
210    luksan/Makefile
211    crs/Makefile
212    mlsl/Makefile
213    mma/Makefile
214    cobyla/Makefile
215    newuoa/Makefile
216    test/Makefile
217 ])
218
219 AC_OUTPUT