configure.ac 6.4 KB
Newer Older
S
stevenj 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
dnl Process this file with autoconf to produce a configure script.
AC_INIT(nlopt, 0.1, stevenj@alum.mit.edu)
AC_CONFIG_SRCDIR(api/nlopt.h)
SHARED_VERSION_INFO="0:0:0" # CURRENT:REVISION:AGE

AM_INIT_AUTOMAKE(1.7)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AC_SUBST(SHARED_VERSION_INFO)
AC_DISABLE_SHARED dnl to hell with shared libraries

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CC_STDC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

21 22 23 24 25 26 27 28 29
AC_ARG_WITH(cxx,
	[AC_HELP_STRING([--with-cxx], [include C++-based routines])],
        with_cxx=$withval,with_cxx=no)
AM_CONDITIONAL(WITH_CXX, test "x$with_cxx" = xyes)
if test "x$with_cxx" = xyes; then
   AC_PROG_CXX
   AC_DEFINE([WITH_CXX], 1, [Define if compiled including C++-based routines])
fi

S
stevenj 已提交
30 31 32
dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDC
AC_HEADER_TIME
33
AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
S
stevenj 已提交
34 35 36
AC_C_CONST
AC_C_INLINE

37 38 39 40 41 42 43 44
dnl find 32-bit unsigned integer type for random-number generator
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_TYPES(uint32_t, [], [], [$ac_includes_default
#ifdef HAVE_STDINT_H
#  include <stdint.h>
#endif])

S
stevenj 已提交
45 46
dnl Checks for libraries and functions
AC_CHECK_LIB(m, sin)
47
AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time])
S
stevenj 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

AC_MSG_CHECKING([for isnan])
AC_TRY_LINK([#include <math.h>
], if (!isnan(3.14159)) isnan(2.7183);, ok=yes, ok=no)
if test "$ok" = "yes"; then
	AC_DEFINE(HAVE_ISNAN,1,[Define if the isnan() function/macro is available.])
fi
AC_MSG_RESULT(${ok})

AC_MSG_CHECKING([for isinf])
AC_TRY_LINK([#include <math.h>
], if (!isinf(3.14159)) isinf(2.7183);, ok=yes, ok=no)
if test "$ok" = "yes"; then
	AC_DEFINE(HAVE_ISINF,1,[Define if the isinf() function/macro is available.])
fi
AC_MSG_RESULT(${ok})

S
stevenj 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
dnl -----------------------------------------------------------------------
dnl Compiling Octave plug-in

AC_ARG_VAR(OCT_INSTALL_DIR, [where to install GNU Octave .oct plug-ins])
AC_ARG_VAR(M_INSTALL_DIR, [where to install GNU Octave .m plug-ins])
AC_ARG_VAR(MKOCTFILE, [name of mkoctfile program to compile Octave plug-ins])

AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo)
if test "$MKOCTFILE" = "echo"; then
	AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin])
elif test x"$OCT_INSTALL_DIR" = "x"; then
	# try to find installation directory
	AC_CHECK_PROGS(OCTAVE, octave, echo)
	AC_MSG_CHECKING(for Octave loadpath)
	OCTAVE_LOADPATH=`echo "DEFAULT_LOADPATH" | $OCTAVE -q | cut -d'=' -f2`
	AC_MSG_RESULT($OCTAVE_LOADPATH)
	AC_MSG_CHECKING(where Octave plugins go)
	OCT_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/oct" | head -1`
	if test -n "$OCT_INSTALL_DIR"; then
		AC_MSG_RESULT($OCT_INSTALL_DIR)
	else
		AC_MSG_RESULT(unknown)
		AC_MSG_WARN([can't find where to install GNU Octave plugins])
	fi
	AC_MSG_CHECKING(where Octave scripts go)
	M_INSTALL_DIR=`echo "$OCTAVE_LOADPATH" | tr ':' '\n' | grep "site/m" | head -1`
	if test -n "$M_INSTALL_DIR"; then
		AC_MSG_RESULT($M_INSTALL_DIR)
	else
		AC_MSG_RESULT(unknown)
		AC_MSG_WARN([can't find where to install GNU Octave scripts])
	fi
fi
AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
AC_SUBST(OCT_INSTALL_DIR)
AC_SUBST(M_INSTALL_DIR)
AC_SUBST(MKOCTFILE)

S
stevenj 已提交
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
dnl -----------------------------------------------------------------------
dnl Compiling Matlab plug-in

AC_ARG_VAR(MEX_INSTALL_DIR, [where to install Matlab .mex plug-ins])
AC_ARG_VAR(MEX, [name of mex program to compile Matlab plug-ins])
AC_CHECK_PROGS(MEX, mex, echo)
if test "$MEX" = "echo"; then
	AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin])
elif test x"$MEX_INSTALL_DIR" = "x"; then
     AC_MSG_CHECKING([for extension of compiled mex files])
     rm -f conftest*
     cat > conftest.c <<EOF
#include <mex.h>
void mexFunction(int nlhs, mxArray *plhs[[]],
                 int nrhs, const mxArray *prhs[[]]) { }
EOF
     if $MEX conftest.c; then
        MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
	AC_MSG_RESULT($MEXSUFF)
	AC_CHECK_PROGS(MATLAB, matlab, echo)
     else
           AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
	MATLAB=echo
     fi

     # try to find installation directory
     if test x"$MATLAB" = xecho; then
        AC_MSG_WARN([can't fine Matlab; won't compile Matlab plugin])
     else
        AC_MSG_CHECKING(for MATLAB mex installation dir)
	matlabpath_line=`matlab -n | grep -n MATLABPATH |head -1 |cut -d: -f1`
	matlabpath_line=`expr $matlabpath_line + 1`
	MEX_INSTALL_DIR=`matlab -n | tail -n +$matlabpath_line | head -1 | tr -d ' '`
	AC_MSG_RESULT($MEX_INSTALL_DIR)
      fi
fi
AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
AC_SUBST(MEX_INSTALL_DIR)
AC_SUBST(MEX)
AC_SUBST(MEXSUFF)

S
stevenj 已提交
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
dnl -----------------------------------------------------------------------
dnl Debugging

AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile with extra runtime checks for debugging])], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
	AC_DEFINE(DEBUG,1,[Define to enable extra debugging code.])
fi

dnl override CFLAGS selection when debugging
if test "${enable_debug}" = "yes"; then
        CFLAGS="-g"
        CXXFLAGS="-g"
        FFLAGS="-g"
fi

dnl add gcc warnings, in debug/maintainer mode only
if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
if test $ac_cv_prog_gcc = yes; then
   if test "$ac_test_CFLAGS" != "set"; then
      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"
   fi
   if test "$ac_test_CXXFLAGS" != "set"; then
      CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
   fi
fi
fi

S
stevenj 已提交
171 172 173 174 175 176 177
vers=`echo ${VERSION}.0.0 | cut -d. -f1`
AC_DEFINE_UNQUOTED(MAJOR_VERSION, $vers, [Major version number.])
vers=`echo ${VERSION}.0.0 | cut -d. -f2`
AC_DEFINE_UNQUOTED(MINOR_VERSION, $vers, [Minor version number.])
vers=`echo ${VERSION}.0.0 | cut -d. -f3`
AC_DEFINE_UNQUOTED(BUGFIX_VERSION, $vers, [Bugfix version number.])

S
stevenj 已提交
178 179 180 181 182 183
dnl -----------------------------------------------------------------------

AC_CONFIG_FILES([
   Makefile
   nlopt.pc
   api/Makefile
184
   util/Makefile
S
stevenj 已提交
185
   octave/Makefile
S
stevenj 已提交
186
   direct/Makefile
187
   cdirect/Makefile
S
stevenj 已提交
188 189
   stogo/Makefile
   subplex/Makefile
190
   praxis/Makefile
191
   luksan/Makefile
192
   crs/Makefile
193
   mlsl/Makefile
194
   test/Makefile
S
stevenj 已提交
195 196 197
])

AC_OUTPUT