chiark / gitweb /
added first version of MLSL multistart-type algorithm
[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_CXX
15 AC_PROG_CC_STDC
16 AC_PROG_INSTALL
17 AC_PROG_LN_S
18 AC_PROG_MAKE_SET
19 AC_LIBTOOL_WIN32_DLL
20 AC_PROG_LIBTOOL
21
22 dnl Checks for typedefs, structures, and compiler characteristics.
23 AC_HEADER_STDC
24 AC_HEADER_TIME
25 AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
26 AC_C_CONST
27 AC_C_INLINE
28
29 dnl find 32-bit unsigned integer type for random-number generator
30 AC_CHECK_SIZEOF(unsigned int)
31 AC_CHECK_SIZEOF(unsigned long)
32 AC_CHECK_TYPES(uint32_t, [], [], [$ac_includes_default
33 #ifdef HAVE_STDINT_H
34 #  include <stdint.h>
35 #endif])
36
37 dnl Checks for libraries and functions
38 AC_CHECK_LIB(m, sin)
39 AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time])
40
41 AC_MSG_CHECKING([for isnan])
42 AC_TRY_LINK([#include <math.h>
43 ], if (!isnan(3.14159)) isnan(2.7183);, ok=yes, ok=no)
44 if test "$ok" = "yes"; then
45         AC_DEFINE(HAVE_ISNAN,1,[Define if the isnan() function/macro is available.])
46 fi
47 AC_MSG_RESULT(${ok})
48
49 AC_MSG_CHECKING([for isinf])
50 AC_TRY_LINK([#include <math.h>
51 ], if (!isinf(3.14159)) isinf(2.7183);, ok=yes, ok=no)
52 if test "$ok" = "yes"; then
53         AC_DEFINE(HAVE_ISINF,1,[Define if the isinf() function/macro is available.])
54 fi
55 AC_MSG_RESULT(${ok})
56
57 dnl -----------------------------------------------------------------------
58 dnl Compiling Octave plug-in
59
60 AC_ARG_VAR(OCT_INSTALL_DIR, [where to install GNU Octave .oct plug-ins])
61 AC_ARG_VAR(M_INSTALL_DIR, [where to install GNU Octave .m plug-ins])
62 AC_ARG_VAR(MKOCTFILE, [name of mkoctfile program to compile Octave plug-ins])
63
64 AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo)
65 if test "$MKOCTFILE" = "echo"; then
66         AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin])
67 elif test x"$OCT_INSTALL_DIR" = "x"; then
68         # try to find installation directory
69         AC_CHECK_PROGS(OCTAVE, octave, echo)
70         AC_MSG_CHECKING(for Octave loadpath)
71         OCTAVE_LOADPATH=`echo "DEFAULT_LOADPATH" | $OCTAVE -q | cut -d'=' -f2`
72         AC_MSG_RESULT($OCTAVE_LOADPATH)
73         AC_MSG_CHECKING(where Octave plugins go)
74         OCT_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/oct" | head -1`
75         if test -n "$OCT_INSTALL_DIR"; then
76                 AC_MSG_RESULT($OCT_INSTALL_DIR)
77         else
78                 AC_MSG_RESULT(unknown)
79                 AC_MSG_WARN([can't find where to install GNU Octave plugins])
80         fi
81         AC_MSG_CHECKING(where Octave scripts go)
82         M_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/m" | head -1`
83         if test -n "$M_INSTALL_DIR"; then
84                 AC_MSG_RESULT($M_INSTALL_DIR)
85         else
86                 AC_MSG_RESULT(unknown)
87                 AC_MSG_WARN([can't find where to install GNU Octave scripts])
88         fi
89 fi
90 AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
91 AC_SUBST(OCT_INSTALL_DIR)
92 AC_SUBST(M_INSTALL_DIR)
93 AC_SUBST(MKOCTFILE)
94
95 dnl -----------------------------------------------------------------------
96 dnl Compiling Matlab plug-in
97
98 AC_ARG_VAR(MEX_INSTALL_DIR, [where to install Matlab .mex plug-ins])
99 AC_ARG_VAR(MEX, [name of mex program to compile Matlab plug-ins])
100 AC_CHECK_PROGS(MEX, mex, echo)
101 if test "$MEX" = "echo"; then
102         AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin])
103 elif test x"$MEX_INSTALL_DIR" = "x"; then
104      AC_MSG_CHECKING([for extension of compiled mex files])
105      rm -f conftest*
106      cat > conftest.c <<EOF
107 #include <mex.h>
108 void mexFunction(int nlhs, mxArray *plhs[[]],
109                  int nrhs, const mxArray *prhs[[]]) { }
110 EOF
111      if $MEX conftest.c; then
112         MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
113         AC_MSG_RESULT($MEXSUFF)
114         AC_CHECK_PROGS(MATLAB, matlab, echo)
115      else
116            AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
117         MATLAB=echo
118      fi
119
120      # try to find installation directory
121      if test x"$MATLAB" = xecho; then
122         AC_MSG_WARN([can't fine Matlab; won't compile Matlab plugin])
123      else
124         AC_MSG_CHECKING(for MATLAB mex installation dir)
125         matlabpath_line=`matlab -n | grep -n MATLABPATH |head -1 |cut -d: -f1`
126         matlabpath_line=`expr $matlabpath_line + 1`
127         MEX_INSTALL_DIR=`matlab -n | tail -n +$matlabpath_line | head -1 | tr -d ' '`
128         AC_MSG_RESULT($MEX_INSTALL_DIR)
129       fi
130 fi
131 AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
132 AC_SUBST(MEX_INSTALL_DIR)
133 AC_SUBST(MEX)
134 AC_SUBST(MEXSUFF)
135
136 dnl -----------------------------------------------------------------------
137 dnl Debugging
138
139 AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile with extra runtime checks for debugging])], ok=$enableval, ok=no)
140 if test "$ok" = "yes"; then
141         AC_DEFINE(DEBUG,1,[Define to enable extra debugging code.])
142 fi
143
144 dnl override CFLAGS selection when debugging
145 if test "${enable_debug}" = "yes"; then
146         CFLAGS="-g"
147         CXXFLAGS="-g"
148         FFLAGS="-g"
149 fi
150
151 dnl add gcc warnings, in debug/maintainer mode only
152 if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
153 if test $ac_cv_prog_gcc = yes; then
154    if test "$ac_test_CFLAGS" != "set"; then
155       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"
156    fi
157    if test "$ac_test_CXXFLAGS" != "set"; then
158       CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
159    fi
160 fi
161 fi
162
163 vers=`echo ${VERSION}.0.0 | cut -d. -f1`
164 AC_DEFINE_UNQUOTED(MAJOR_VERSION, $vers, [Major version number.])
165 vers=`echo ${VERSION}.0.0 | cut -d. -f2`
166 AC_DEFINE_UNQUOTED(MINOR_VERSION, $vers, [Minor version number.])
167 vers=`echo ${VERSION}.0.0 | cut -d. -f3`
168 AC_DEFINE_UNQUOTED(BUGFIX_VERSION, $vers, [Bugfix version number.])
169
170 dnl -----------------------------------------------------------------------
171
172 AC_CONFIG_FILES([
173    Makefile
174    nlopt.pc
175    api/Makefile
176    util/Makefile
177    octave/Makefile
178    direct/Makefile
179    cdirect/Makefile
180    stogo/Makefile
181    subplex/Makefile
182    praxis/Makefile
183    luksan/Makefile
184    crs/Makefile
185    mlsl/Makefile
186    test/Makefile
187 ])
188
189 AC_OUTPUT