chiark / gitweb /
add --with-cxx to include C++ code, and don't include C++ (StoGO) by default
authorstevenj <stevenj@alum.mit.edu>
Sat, 12 Apr 2008 04:48:37 +0000 (00:48 -0400)
committerstevenj <stevenj@alum.mit.edu>
Sat, 12 Apr 2008 04:48:37 +0000 (00:48 -0400)
darcs-hash:20080412044837-c8de0-626c401f26424ecb5c0e76dd6fa6c0c837aaf04a.gz

Makefile.am
api/nlopt.c
configure.ac

index 66ec384358656a7e0abaf6af16590b72f94fa3ae..9563690fc8b0e5052f28a40195e2e3a912cf659c 100644 (file)
@@ -3,12 +3,17 @@ lib_LTLIBRARIES = libnlopt.la
 
 ACLOCAL_AMFLAGS=-I ./m4
 
-SUBDIRS= util subplex direct cdirect stogo praxis luksan crs mlsl api . octave test
+if WITH_CXX
+CXX_DIRS = stogo
+CXX_LIBS = stogo/libstogo.la
+endif
+
+SUBDIRS= util subplex direct cdirect $(CXX_DIRS) praxis luksan crs mlsl api . octave test
 EXTRA_DIST=COPYRIGHT autogen.sh nlopt.pc.in m4
 
 libnlopt_la_SOURCES = 
 libnlopt_la_LIBADD = subplex/libsubplex.la direct/libdirect.la \
-cdirect/libcdirect.la stogo/libstogo.la praxis/libpraxis.la    \
+cdirect/libcdirect.la $(CXX_LIBS) praxis/libpraxis.la  \
 luksan/libluksan.la crs/libcrs.la mlsl/libmlsl.la api/libapi.la        \
 util/libutil.la
 
index f60575342b1126c3dece53e22e27fdc3ba514dca..e0251f4a1d8d67b664af01c4c36ecb1a51f16a89 100644 (file)
@@ -51,8 +51,13 @@ static const char nlopt_algorithm_names[NLOPT_NUM_ALGORITHMS][256] = {
      "Original DIRECT version (global, no-derivative)",
      "Original DIRECT-L version (global, no-derivative)",
      "Subplex (local, no-derivative)",
+#ifdef WITH_CXX
      "StoGO (global, derivative-based)",
      "StoGO with randomized search (global, derivative-based)",
+#else
+     "StoGO (NOT COMPILED)",
+     "StoGO randomized (NOT COMPILED)",
+#endif
      "Low-storage BFGS (LBFGS) (local, derivative-based)",
      "Principal-axis, praxis (local, no-derivative)",
      "Limited-memory variable-metric, rank 1 (local, derivative-based)",
@@ -124,7 +129,9 @@ static double f_direct(int n, const double *x, int *undefined, void *data_)
      return f;
 }
 
-#include "stogo.h"
+#ifdef WITH_CXX
+#  include "stogo.h"
+#endif
 
 #include "cdirect.h"
 
@@ -262,11 +269,15 @@ static nlopt_result nlopt_minimize_(
 
         case NLOPT_GD_STOGO:
         case NLOPT_GD_STOGO_RAND:
+#ifdef WITH_CXX
              if (!stogo_minimize(n, f, f_data, x, minf, lb, ub, &stop,
                                  algorithm == NLOPT_GD_STOGO
                                  ? 0 : 2*n))
                   return NLOPT_FAILURE;
              break;
+#else
+             return NLOPT_FAILURE;
+#endif
 
         case NLOPT_LN_SUBPLEX: {
              int iret;
index ef97129e134b2c6a859fff4630ac9436b9874274..92f1859d60fd33fa223c19d0dfb1cdc2dbd1a39d 100644 (file)
@@ -11,7 +11,6 @@ AC_DISABLE_SHARED dnl to hell with shared libraries
 
 dnl Checks for programs.
 AC_PROG_CC
-AC_PROG_CXX
 AC_PROG_CC_STDC
 AC_PROG_INSTALL
 AC_PROG_LN_S
@@ -19,6 +18,15 @@ AC_PROG_MAKE_SET
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 
+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
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDC
 AC_HEADER_TIME