diff --git a/.gitignore b/.gitignore index fd664958..6175391f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ *.mex* *.oct *.zip +build # generated code api/nlopt.f @@ -30,28 +31,3 @@ mingw64 octave/dummy test/testopt util/redblack_test - -# autotools stuff -Makefile -Makefile.in -.deps -.libs -stamp-h1 -install-sh -libtool -ltmain.sh -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 -configure -config.* -autom4te.cache -INSTALL -README -aclocal.m4 -depcomp -missing -py-compile -compile diff --git a/.travis.yml b/.travis.yml index efa2bde7..92021c4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,40 @@ language: cpp sudo: false -addons: - apt: - packages: - - swig - - python-dev - - python-numpy - - guile-2.0-dev - - octave3.2-headers - - cmake +matrix: + include: + - os: linux + addons: + apt: + packages: + - swig + - python-dev + - python-numpy + - guile-2.0-dev + - octave3.2-headers + - cmake + - g++-mingw-w64-i686 + - gcc-mingw-w64-i686 + - binutils-mingw-w64-i686 + - g++-mingw-w64-x86-64 + - gcc-mingw-w64-x86-64 + - binutils-mingw-w64-x86-64 + script: + - mkdir build && pushd build + - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DWITH_CXX=ON .. + - make install -j2 && make tests -j2 && ctest -j2 --output-on-failure + - rm -rf * ~/.local + - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DWITH_CXX=ON -DBUILD_PYTHON=OFF -DBUILD_OCTAVE=OFF -DBUILD_GUILE=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-i686-w64-mingw32.cmake .. + - make install -j2 && make tests -j2 + - rm -rf * ~/.local + - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DWITH_CXX=ON -DBUILD_PYTHON=OFF -DBUILD_OCTAVE=OFF -DBUILD_GUILE=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake .. + - make install -j2 && make tests -j2 -script: - - ./autogen.sh --no-configure - - mkdir build && pushd build - - ../configure --prefix=$HOME/.local --enable-shared --enable-maintainer-mode --enable-cxx - - make -j2 - - make install - - python ../test/test_std.py - - rm -rf * ~/.local - - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBUILD_SHARED_LIBS=ON .. - - make install -j2 - - python ../test/test_std.py + - os: osx + install: + - brew tap homebrew/python + - brew install swig python + script: + - mkdir build && pushd build + - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DWITH_CXX=ON .. + - make install && make tests && ctest --output-on-failure \ No newline at end of file diff --git a/BUILD-MINGW32.sh b/BUILD-MINGW32.sh deleted file mode 100755 index b5ce3682..00000000 --- a/BUILD-MINGW32.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh -set -ev - -rm -rf mingw32 -make distclean || true - -echo "COMPILING..." - -./configure --prefix=`pwd`/mingw32 --host=i686-w64-mingw32 --enable-shared --disable-static --without-matlab --without-octave --without-python --without-guile --without-threadlocal && make -j4 && make install - -echo "POST-PROCESSING..." - -cd mingw32/bin -for dll in *.dll; do - def=`basename $dll .dll`.def - echo "LIBRARY $dll" > $def - echo EXPORTS >> $def - i686-w64-mingw32-nm $dll | grep ' T _' | sed 's/.* T _//' | egrep 'nlopt|nlo_' >> $def -done -cd ../.. - -perl -pi -e 's,^ * #define NLOPT_DLL,*/\n#define NLOPT_DLL\n/*,' mingw32/include/nlopt.h - -cat > README-WINDOWS <> README-WINDOWS - -# grep -v "nlopt-util.h" octave/nlopt_minimize_constrained-mex.c > mingw32/nlopt_minimize_constrained.c - -nlopt_vers=`grep PACKAGE_VERSION config.h |cut -d" " -f3 |tr -d \"` - -mkdir mingw32/matlab -cd octave -cp `grep 'MFILES =' Makefile.am | cut -d= -f2` ../mingw32/matlab -cp `grep 'm_DATA =' Makefile.am | cut -d\) -f2` ../mingw32/matlab -cp nlopt_optimize-mex.c ../mingw32/matlab/nlopt_optimize.c -cd .. - -mkdir mingw32/python -cp swig/nlopt.py swig/nlopt-python.cpp mingw32/python -cat > mingw32/python/setup.py < $def - echo EXPORTS >> $def - x86_64-w64-mingw32-nm $dll | grep ' T ' | sed 's/.* T //' | egrep 'nlopt|nlo_' >> $def -done -cd ../.. - -perl -pi -e 's,^ * #define NLOPT_DLL,*/\n#define NLOPT_DLL\n/*,' mingw64/include/nlopt.h - -cat > README-WINDOWS <> README-WINDOWS - -# grep -v "nlopt-util.h" octave/nlopt_minimize_constrained-mex.c > mingw64/nlopt_minimize_constrained.c - -nlopt_vers=`grep PACKAGE_VERSION config.h |cut -d" " -f3 |tr -d \"` - -mkdir mingw64/matlab -cd octave -cp `grep 'MFILES =' Makefile.am | cut -d= -f2` ../mingw64/matlab -cp `grep 'm_DATA =' Makefile.am | cut -d\) -f2` ../mingw64/matlab -cp nlopt_optimize-mex.c ../mingw64/matlab/nlopt_optimize.c -cd .. - -mkdir mingw64/python -cp swig/nlopt.py swig/nlopt-python.cpp mingw64/python -cat > mingw64/python/setup.py <\n") + file (APPEND ${CMAKE_BINARY_DIR}/fpclassify.c "int main(void) {\n") + file (APPEND ${CMAKE_BINARY_DIR}/fpclassify.c "if (!fpclassify(3.14159)) fpclassify(2.7183);\n") + file (APPEND ${CMAKE_BINARY_DIR}/fpclassify.c " return 0; }\n") + try_compile (HAVE_FPCLASSIFY + ${CMAKE_BINARY_DIR}/build_fpclassify + ${CMAKE_BINARY_DIR}/fpclassify.c + CMAKE_FLAGS -DLINK_LIBRARIES=m) + message(STATUS "Looking for fpclassify - ${HAVE_FPCLASSIFY}") +endif () -#--------------------------------- -# If version matches 'X.X.X' -#--------------------------------- -IF(${NLOPT_AUTOMAKE_LINE_VERSION} MATCHES ".*[0-9]+\\.[0-9]+\\.[0-9]+") - STRING( REGEX REPLACE ".*([0-9]+)\\.[0-9]+\\.[0-9]*.*" "\\1" NLOPT_MAJOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") - STRING( REGEX REPLACE ".*[0-9]+\\.([0-9]+)\\.[0-9]*.*" "\\1" NLOPT_MINOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") - STRING( REGEX REPLACE ".*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" NLOPT_BUGFIX_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") -#--------------------------------- -# Else (consider that version matches 'X.X') -#--------------------------------- -ELSE(${NLOPT_AUTOMAKE_LINE_VERSION} MATCHES ".*[0-9]+\\.[0-9]+\\.[0-9]+") - STRING( REGEX REPLACE ".*([0-9]+)\\.[0-9]+.*" "\\1" NLOPT_MAJOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") - STRING( REGEX REPLACE ".*[0-9]+\\.([0-9]+).*" "\\1" NLOPT_MINOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") - SET (NLOPT_BUGFIX_VERSION "0") -ENDIF(${NLOPT_AUTOMAKE_LINE_VERSION} MATCHES ".*[0-9]+\\.[0-9]+\\.[0-9]+") +option (WITH_THREADLOCAL "check thread local keyword" ON) +if (WITH_THREADLOCAL AND NOT DEFINED HAVE_THREAD_LOCAL_STORAGE) + foreach (_THREADLOCAL_KEY "__thread" "__declspec(thread)") + unset (HAVE_THREAD_LOCAL_STORAGE CACHE) + check_c_source_compiles(" + ${_THREADLOCAL_KEY} int tls; -MESSAGE(STATUS "NLOPT: Version number ${NLOPT_MAJOR_VERSION}.${NLOPT_MINOR_VERSION}.${NLOPT_BUGFIX_VERSION} found in configure.ac" ) + int main(void) { + return 0; + }" HAVE_THREAD_LOCAL_STORAGE) + if (${HAVE_THREAD_LOCAL_STORAGE}) + set (THREADLOCAL ${_THREADLOCAL_KEY}) + endif () + endforeach() +endif () +#============================================================================== +# version +#============================================================================== +set (NLOPT_MAJOR_VERSION "2") +set (NLOPT_MINOR_VERSION "5") +set (NLOPT_BUGFIX_VERSION "0") +set (NLOPT_VERSION_STRING ${NLOPT_MAJOR_VERSION}.${NLOPT_MINOR_VERSION}.${NLOPT_BUGFIX_VERSION}) +message (STATUS "NLopt version ${NLOPT_VERSION_STRING}") #============================================================================== # CREATE config.h #============================================================================== -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h IMMEDIATE ) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h IMMEDIATE) +# pkgconfig file +if (UNIX OR MINGW) + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/nlopt.pc.in ${CMAKE_CURRENT_BINARY_DIR}/nlopt.pc @ONLY) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.pc DESTINATION ${RELATIVE_INSTALL_LIB_DIR}/pkgconfig) +endif () #============================================================================== # INCLUDE DIRECTORIES #============================================================================== -SET(${INCLUDE_DIRECTORIES} "") -INCLUDE_DIRECTORIES ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - stogo - util - direct - cdirect - praxis - luksan - crs - mlsl - mma - cobyla - newuoa - neldermead - auglag - bobyqa - isres - slsqp - esch - api ) +set (${INCLUDE_DIRECTORIES} "") +include_directories ( + ${CMAKE_BINARY_DIR}/api + ${CMAKE_BINARY_DIR} + stogo + util + direct + cdirect + praxis + luksan + crs + mlsl + mma + cobyla + newuoa + neldermead + auglag + bobyqa + isres + slsqp + esch + api) #============================================================================== @@ -119,7 +182,7 @@ INCLUDE_DIRECTORIES ( #============================================================================== SET ( NLOPT_HEADERS - api/nlopt.h api/nlopt.hpp api/nlopt.f + api/nlopt.h ${CMAKE_BINARY_DIR}/api/nlopt.hpp ${CMAKE_BINARY_DIR}/api/nlopt.f ) SET ( NLOPT_SOURCES @@ -140,41 +203,121 @@ SET ( NLOPT_SOURCES esch/esch.c esch/esch.h api/general.c api/options.c api/optimize.c api/deprecated.c api/nlopt-internal.h api/nlopt.h api/f77api.c api/f77funcs.h api/f77funcs_.h api/nlopt.hpp api/nlopt-in.hpp util/mt19937ar.c util/sobolseq.c util/soboldata.h util/timer.c util/stop.c util/nlopt-util.h util/redblack.c util/redblack.h util/qsort_r.c util/rescale.c - stogo/global.cc stogo/linalg.cc stogo/local.cc stogo/stogo.cc stogo/tools.cc stogo/global.h stogo/linalg.h stogo/local.h stogo/stogo_config.h stogo/stogo.h stogo/tools.h ) -OPTION(BUILD_SHARED_LIBS "Build NLOPT as a shared library" OFF ) +if (WITH_CXX) + list (APPEND NLOPT_SOURCES stogo/global.cc stogo/linalg.cc stogo/local.cc stogo/stogo.cc stogo/tools.cc stogo/global.h stogo/linalg.h stogo/local.h stogo/stogo_config.h stogo/stogo.h stogo/tools.h) +endif () + if (BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DNLOPT_DLL) - ADD_DEFINITIONS(-DNLOPT_DLL_EXPORT ) - - if (NOT CMAKE_INSTALL_PREFIX MATCHES "^/usr") - set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - endif () + add_definitions (-DNLOPT_DLL) + add_definitions (-DNLOPT_DLL_EXPORT) endif () -INSTALL ( FILES ${NLOPT_HEADERS} DESTINATION include ) +install (FILES ${NLOPT_HEADERS} DESTINATION include) -ADD_LIBRARY (nlopt ${NLOPT_SOURCES} ) +set (nlopt_lib nlopt${NLOPT_SUFFIX}) +add_library (${nlopt_lib} ${NLOPT_SOURCES}) +set_target_properties (${nlopt_lib} PROPERTIES SOVERSION 0) +set_target_properties (${nlopt_lib} PROPERTIES VERSION 0.9.0) -# parse configure.ac for lib version -STRING( REGEX MATCH "SHARED_VERSION_INFO=\"[0-9]+:[0-9]+:[0-9]+\"" _VERSION_INFO_LINE "${CONFIG_AUTOMAKE}") -IF (_VERSION_INFO_LINE) - STRING( REGEX REPLACE "SHARED_VERSION_INFO=\"([0-9]+):[0-9]+:[0-9]+\"" "\\1" _VERSION_INFO_CURRENT "${_VERSION_INFO_LINE}") - STRING( REGEX REPLACE "SHARED_VERSION_INFO=\"[0-9]+:([0-9]+):[0-9]+\"" "\\1" _VERSION_INFO_REVISION "${_VERSION_INFO_LINE}") - STRING( REGEX REPLACE "SHARED_VERSION_INFO=\"[0-9]+:[0-9]+:([0-9]+)\"" "\\1" _VERSION_INFO_AGE "${_VERSION_INFO_LINE}") - MATH(EXPR _INFO_SOVERSION "${_VERSION_INFO_CURRENT} - ${_VERSION_INFO_AGE} ") - SET(_INFO_VERSION "${_INFO_SOVERSION}.${_VERSION_INFO_AGE}.${_VERSION_INFO_REVISION}") - SET_TARGET_PROPERTIES(nlopt PROPERTIES SOVERSION ${_INFO_SOVERSION}) - SET_TARGET_PROPERTIES(nlopt PROPERTIES VERSION ${_INFO_VERSION} ) -ENDIF () +# pass -fPIC in case swig module is built with static library +if (NOT BUILD_SHARED_LIBS) + check_c_compiler_flag (-fPIC HAS_FPIC) + if (HAS_FPIC) + set (CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}") + set (CMAKE_CXX_FLAGS "-fPIC ${CMAKE_CXX_FLAGS}") + endif () +endif () -INSTALL ( TARGETS nlopt - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} +install ( TARGETS ${nlopt_lib} + EXPORT NLoptLibraryDepends + RUNTIME DESTINATION ${RELATIVE_INSTALL_BIN_DIR} + LIBRARY DESTINATION ${RELATIVE_INSTALL_LIB_DIR} + ARCHIVE DESTINATION ${RELATIVE_INSTALL_LIB_DIR} ) +add_subdirectory (api) + +if (BUILD_PYTHON) + find_package (PythonInterp) + find_package (PythonLibs) + find_package (NumPy) +endif () + +if (PYTHONINTERP_FOUND) + execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" + OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE ) + + get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) + file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) + + set (PYTHON_MODULE_PATH ${_REL_PYTHON_MODULE_PATH}) + +endif () + +if (BUILD_GUILE) + find_package (Guile) +endif () + +if (USE_SWIG) + find_package (SWIG) +endif () + add_subdirectory (swig) + +if (BUILD_OCTAVE) + find_package (Octave) +endif () + +if (OCTAVE_FOUND) + add_subdirectory (octave) +endif () + +enable_testing () +add_subdirectory (test) + +set (CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") +set (CPACK_PACKAGE_VERSION_MAJOR "${NLOPT_MAJOR_VERSION}") +set (CPACK_PACKAGE_VERSION_MINOR "${NLOPT_MINOR_VERSION}") +set (CPACK_PACKAGE_VERSION_PATCH "${NLOPT_BUGFIX_VERSION}") +set (CPACK_SOURCE_GENERATOR "TBZ2;TGZ" ) +set (CPACK_BINARY_STGZ "OFF" ) +set (CPACK_BINARY_TBZ2 "ON" ) +set (CPACK_BINARY_TGZ "ON" ) +set (CPACK_BINARY_TZ "OFF" ) +set (CPACK_SOURCE_IGNORE_FILES ".git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}") + +set (CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${NLOPT_VERSION_STRING}) + +include (CPack) + +# configuration files +export (TARGETS ${nlopt_lib} FILE ${PROJECT_BINARY_DIR}/NLoptLibraryDepends.cmake) + +# Install the export set for use with the install-tree +install(EXPORT NLoptLibraryDepends + DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR} + COMPONENT Development) + +# Create a NLOPTConfig.cmake file for the use from the install tree +# and install it +set (NLOPT_LIBRARIES ${nlopt_lib}) + +set (NLOPT_CMAKE_DIR "${INSTALL_CMAKE_DIR}") +file (RELATIVE_PATH rel_include_dir "${NLOPT_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}") +list (APPEND RELATIVE_NLOPT_INCLUDE_DIRS ${rel_include_dir}) + +file (RELATIVE_PATH rel_lib_dir "${NLOPT_CMAKE_DIR}" "${INSTALL_LIB_DIR}") +list (APPEND RELATIVE_NLOPT_LIB_DIR ${rel_lib_dir}) + +configure_file (cmake/NLoptConfig.cmake.in NLoptConfig.cmake @ONLY) +configure_file (cmake/NLoptConfigVersion.cmake.in NLoptConfigVersion.cmake @ONLY) +install (FILES + ${CMAKE_CURRENT_BINARY_DIR}/NLoptConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/NLoptConfigVersion.cmake + DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR} + COMPONENT Development) + diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 9cf85fa2..00000000 --- a/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -OPTIONS_AUTOMAKE=gnu -lib_LTLIBRARIES = libnlopt@NLOPT_SUFFIX@.la - -ACLOCAL_AMFLAGS=-I m4 - -if WITH_CXX -CXX_DIRS = stogo -CXX_LIBS = stogo/libstogo.la -endif - -SUBDIRS = util direct cdirect $(CXX_DIRS) praxis luksan crs mlsl mma cobyla newuoa neldermead auglag bobyqa isres slsqp esch api . octave test swig -EXTRA_DIST = autogen.sh nlopt.pc.in m4 CMakeLists.txt config.cmake.h.in - -libnlopt@NLOPT_SUFFIX@_la_SOURCES = -if WITH_CXX -# Dummy C++ source to cause C++ linking -nodist_EXTRA_libnlopt@NLOPT_SUFFIX@_la_SOURCES = dummy.cxx -endif -libnlopt@NLOPT_SUFFIX@_la_LIBADD = direct/libdirect.la \ -cdirect/libcdirect.la $(CXX_LIBS) praxis/libpraxis.la \ -luksan/libluksan.la crs/libcrs.la mlsl/libmlsl.la mma/libmma.la \ -cobyla/libcobyla.la newuoa/libnewuoa.la neldermead/libneldermead.la \ -auglag/libauglag.la bobyqa/libbobyqa.la isres/libisres.la \ -slsqp/libslsqp.la esch/libesch.la api/libapi.la util/libutil.la - -libnlopt@NLOPT_SUFFIX@_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@ -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = nlopt.pc - -if MAINTAINER_MODE - -README: README.md - cp -f $(srcdir)/README.md $@ - -endif diff --git a/README.md b/README.md index a8c34af8..d954ffa6 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,9 @@ nonlinear optimization libraries. The latest release and a complete manual may be found at the NLopt home page: http://ab-initio.mit.edu/nlopt -It is compiled and installed with the standard GNU autoconf/automake -commands: +It is compiled and installed with CMake build system: - ./configure - make + cmake . make install See `./configure --help` or the `INSTALL` file for other options. To @@ -20,11 +18,10 @@ build the latest development sources: git clone git://github.com/stevengj/nlopt cd nlopt - sh autogen.sh + cmake . make -(To build from git, you will need GNU autoconf, automake, and libtool -installed, along with SWIG and Unix tools such as m4, perl, and sed.) +(To build from git, you will need SWIG.) Once it is installed, `#include ` in your C/C++ programs and link it with `-lnlopt -lm`. You may need to use the C++ compiler to link diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt new file mode 100644 index 00000000..0ea4f158 --- /dev/null +++ b/api/CMakeLists.txt @@ -0,0 +1,80 @@ + +# install man +if (UNIX) + install (FILES nlopt.3 DESTINATION share/man/man3) +endif () + +# generate nlopt.f from nlopt.h enums +if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/nlopt.f) + file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/nlopt.f "") + file (STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt.h NLOPT_H_LINES REGEX " NLOPT_[A-Z0-9_]+") + set (i 0) + foreach (NLOPT_H_LINE ${NLOPT_H_LINES}) + if (NOT NLOPT_H_LINE MATCHES "NLOPT_NUM_") + string (REGEX REPLACE ".*NLOPT_([A-Z0-9_]+).*" "\\1" ENUM_STRING ${NLOPT_H_LINE}) + string (REGEX REPLACE ".*NLOPT_[A-Z0-9_]+ = (-?[0-9]+).*" "\\1" ENUM_VAL ${NLOPT_H_LINE}) + if (ENUM_VAL MATCHES "^-?[0-9]+$") + set (i ${ENUM_VAL}) + endif () + set (ENUM_LINE " integer NLOPT_${ENUM_STRING}\n parameter (NLOPT_${ENUM_STRING}=${i})\n") + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.f "${ENUM_LINE}") + + # https://public.kitware.com/Bug/print_bug_page.php?bug_id=8996 + if (i MATCHES "^-") + math (EXPR i "1 ${i}") + else () + math (EXPR i "${i} + 1") + endif () + endif () + endforeach () +endif () + +# generate nlopt.hpp from nlopt-in.hpp +if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp) + file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp "") + file (STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-in.hpp NLOPT_HPP_LINES) + foreach (NLOPT_HPP_LINE ${NLOPT_HPP_LINES}) + list(LENGTH NLOPT_HPP_LINE line_len) + # handling trailing backlashes in "file (STRINGS" is a little tricky + if (line_len VERSION_LESS 8) + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp "${NLOPT_HPP_LINE}\n") + else () + set (prev_inst FALSE) + foreach(NLOPT_HPP_SUBLINE ${NLOPT_HPP_LINE}) + # test is we need to add the eaten semicolon + if (NLOPT_HPP_SUBLINE MATCHES "\\)$" OR NLOPT_HPP_SUBLINE MATCHES "return") + set (new_inst TRUE) + else () + set (new_inst FALSE) + endif () + if (NOT prev_inst) + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp "${NLOPT_HPP_SUBLINE}") + if (new_inst) + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp ";") + endif () + list (FIND NLOPT_HPP_LINE "${NLOPT_HPP_SUBLINE}" index) + math (EXPR index "${index} + 1") + list (LENGTH NLOPT_HPP_LINE total) + if (NOT index STREQUAL total) + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp " \\") + endif () + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp "\n") + endif () + set (prev_inst ${new_inst}) + endforeach () + endif () + if (NLOPT_HPP_LINE MATCHES "GEN_ENUMS_HERE") + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp " enum algorithm {\n") + file (STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt.h NLOPT_H_LINES REGEX " NLOPT_[A-Z0-9_]+") + foreach (NLOPT_H_LINE ${NLOPT_H_LINES}) + string (REGEX REPLACE "NLOPT_" "" ENUM_LINE ${NLOPT_H_LINE}) + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp "${ENUM_LINE}\n") + if (NLOPT_H_LINE MATCHES "NLOPT_NUM_ALGORITHMS") + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp " };\n enum result {\n") + elseif (NLOPT_H_LINE MATCHES "NLOPT_MAXTIME_REACHED") + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp " };\n") + endif () + endforeach () + endif () + endforeach () +endif () diff --git a/api/Makefile.am b/api/Makefile.am deleted file mode 100644 index d4d08d29..00000000 --- a/api/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/cdirect -I$(top_srcdir)/direct -I$(top_srcdir)/stogo -I$(top_srcdir)/praxis -I$(top_srcdir)/lbfgs -I$(top_srcdir)/luksan -I$(top_srcdir)/crs -I$(top_srcdir)/mlsl -I$(top_srcdir)/mma -I$(top_srcdir)/cobyla -I$(top_srcdir)/newuoa -I$(top_srcdir)/neldermead -I$(top_srcdir)/auglag -I$(top_srcdir)/bobyqa -I$(top_srcdir)/isres -I$(top_srcdir)/slsqp -I$(top_srcdir)/esch -I$(top_srcdir)/util - -include_HEADERS = nlopt.h nlopt.f nlopt.hpp -noinst_LTLIBRARIES = libapi.la -dist_man_MANS = nlopt.3 - -libapi_la_SOURCES = general.c options.c optimize.c deprecated.c \ -nlopt-internal.h nlopt.h f77api.c f77funcs.h f77funcs_.h - -BUILT_SOURCES = nlopt.f nlopt.hpp -EXTRA_DIST = nlopt-in.hpp - -if MAINTAINER_MODE -# convert constants to F77 parameter statements & C++ - -nlopt.f: nlopt.h - rm -f $@ - (i=0; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' $(srcdir)/nlopt.h | tr -d ' =0,' | while read n; do echo " integer $$n"; echo " parameter ($$n=$$i)"; i=`expr $$i + 1`; done; tail -n +`grep -n enum $(srcdir)/nlopt.h |cut -d: -f1 |tail -n 1` $(srcdir)/nlopt.h | grep NLOPT | egrep -v 'EXTERN|DEPRECATED|MINF_MAX' | cut -d, -f1 | tr -d ' ' | perl -pe 's/([A-Za-z0-9_]+)=([-+0-9]+)/ integer \1\n parameter (\1=\2)/') > $(srcdir)/$@ - -nlopt.hpp: nlopt.h nlopt-in.hpp - rm -f $@ - (n=`grep -n GEN_ENUMS_HERE $(srcdir)/nlopt-in.hpp | cut -d: -f1`; head -n $$n $(srcdir)/nlopt-in.hpp; echo " enum algorithm {"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(srcdir)/nlopt.h | sed 's/NLOPT_//g'; echo " };"; echo " enum result {"; egrep 'NLOPT_[A-Z_]* =' $(srcdir)/nlopt.h | egrep -v 'NLOPT_[LG][DN]' | sed 's/NLOPT_//g'; echo " };"; tail -n +$$n $(srcdir)/nlopt-in.hpp) > $(srcdir)/$@ - -endif diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..6c378f47 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +version: 1.0.{build} +os: Visual Studio 2015 +clone_folder: C:\projects\nlopt +test: off +configuration: + - Release +branches: + only: + - master +environment: + matrix: + - CMAKE_PLATFORM: "Visual Studio 14 2015" + - CMAKE_PLATFORM: "Visual Studio 14 2015 Win64" +#install: + #- cinstall: python + #- choco install swig +build_script: + - echo Running cmake... + - cd c:\projects\nlopt + - cmake -G "%CMAKE_PLATFORM%" -DBUILD_SHARED_LIBS=OFF -DWITH_CXX=ON -DCMAKE_INSTALL_PREFIX="C:\projects\nlopt\install" . + - cmake --build . --config %Configuration% --target install + - cmake --build . --config %Configuration% --target tests + - ctest -C %Configuration% --output-on-failure --timeout 100 diff --git a/auglag/Makefile.am b/auglag/Makefile.am deleted file mode 100644 index 77954152..00000000 --- a/auglag/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libauglag.la -libauglag_la_SOURCES = auglag.c auglag.h - -EXTRA_DIST = README diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 05b709b9..00000000 --- a/autogen.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -configure_args="" -configure="yes" - -while test $# -ge 1; do - case $1 in - --verbose) verbose=yes ;; - --enable-*) configure_args="$configure_args $1" ;; - --disable-*) configure_args="$configure_args $1" ;; - --with-*) configure_args="$configure_args $1" ;; - --without-*) configure_args="$configure_args $1" ;; - --no-configure) configure="no" ;; - *) echo "unknown argument $1"; exit 1 ;; - esac - shift -done - -touch swig/nlopt.scm.in - -cp README.md README - -# paranoia: sometimes autoconf doesn't get things right the first time -autoreconf --verbose --install --symlink --force -autoreconf --verbose --install --symlink --force -autoreconf --verbose --install --symlink --force - -if test "$configure" = "yes" -then - config=good # hackery so darcs_test still outputs config.log w/failed configure - - ./configure --enable-maintainer-mode $configure_args || config=bad - - if test x$verbose = xyes; then - cat config.log - fi - - test $config = bad && exit 1 -fi \ No newline at end of file diff --git a/bobyqa/Makefile.am b/bobyqa/Makefile.am deleted file mode 100644 index 71f2d9b4..00000000 --- a/bobyqa/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libbobyqa.la -libbobyqa_la_SOURCES = bobyqa.c bobyqa.h - -EXTRA_DIST = README README.orig COPYRIGHT diff --git a/cdirect/Makefile.am b/cdirect/Makefile.am deleted file mode 100644 index b5695e72..00000000 --- a/cdirect/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libcdirect.la -libcdirect_la_SOURCES = cdirect.c hybrid.c cdirect.h - -EXTRA_DIST = README diff --git a/cmake/FindGuile.cmake b/cmake/FindGuile.cmake new file mode 100644 index 00000000..c2862d0c --- /dev/null +++ b/cmake/FindGuile.cmake @@ -0,0 +1,97 @@ +# Copyright (c) 2008, 2014 OpenCog.org (http://opencog.org) +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# - Try to find Guile; Once done this will define +# +# GUILE_FOUND - system has the GUILE library +# GUILE_INCLUDE_DIRS - the GUILE include directory +# GUILE_LIBRARIES - The libraries needed to use GUILE +# GUILE_VERSION_STRING - Version +# GUILE_SITE_DIR - site dir +# GUILE_EXTENSION_DIR - extension dir +# GUILE_ROOT_DIR - prefix dir + +# Look for the header file +# Look for guile-2.2 first, then 2.0, then 1.8 +# Macports for OSX puts things in /opt/local +find_path (GUILE_INCLUDE_DIR libguile.h + PATH_SUFFIXES + guile/2.2 + guile/2.0 + guile/1.8 + libguile + guile + HINTS /opt/local/include +) + +# Look for the library +find_library (GUILE_LIBRARY NAMES guile-2.2 guile-2.0 guile + HINTS + /opt/local/lib +) + + +set (GUILE_LIBRARIES ${GUILE_LIBRARY}) +set (GUILE_INCLUDE_DIRS ${GUILE_INCLUDE_DIR}) + + +# check guile's version if we're using cmake >= 2.6 +if (GUILE_INCLUDE_DIR) + SET(GUILE_VERSION_MAJOR 0) + SET(GUILE_VERSION_MINOR 0) + SET(GUILE_VERSION_PATCH 0) + + IF(NOT EXISTS "${GUILE_INCLUDE_DIR}/libguile/version.h") + MESSAGE(FATAL_ERROR "Found ${GUILE_INCLUDE_DIR}/libguile.h but not version.h; check your guile installation!") + ENDIF(NOT EXISTS "${GUILE_INCLUDE_DIR}/libguile/version.h") + + # Extract the libguile version from the 'version.h' file + SET(GUILE_MAJOR_VERSION 0) + FILE(READ "${GUILE_INCLUDE_DIR}/libguile/version.h" _GUILE_VERSION_H_CONTENTS) + + STRING(REGEX MATCH "#define SCM_MAJOR_VERSION[ ]+([0-9])" _MATCH "${_GUILE_VERSION_H_CONTENTS}") + SET(GUILE_VERSION_MAJOR ${CMAKE_MATCH_1}) + STRING(REGEX MATCH "#define SCM_MINOR_VERSION[ ]+([0-9]+)" _MATCH "${_GUILE_VERSION_H_CONTENTS}") + SET(GUILE_VERSION_MINOR ${CMAKE_MATCH_1}) + STRING(REGEX MATCH "#define SCM_MICRO_VERSION[ ]+([0-9]+)" _MATCH "${_GUILE_VERSION_H_CONTENTS}") + SET(GUILE_VERSION_PATCH ${CMAKE_MATCH_1}) + + SET(GUILE_VERSION_STRING "${GUILE_VERSION_MAJOR}.${GUILE_VERSION_MINOR}.${GUILE_VERSION_PATCH}") + +endif () + +find_program(GUILE_CONFIG_EXECUTABLE + NAMES guile-config + ) + + +if (GUILE_CONFIG_EXECUTABLE) + execute_process (COMMAND ${GUILE_CONFIG_EXECUTABLE} info prefix + OUTPUT_VARIABLE GUILE_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${GUILE_CONFIG_EXECUTABLE} info sitedir + OUTPUT_VARIABLE GUILE_SITE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${GUILE_CONFIG_EXECUTABLE} info extensiondir + OUTPUT_VARIABLE GUILE_EXTENSION_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif () + +# IF(GUILE_FOUND AND GUILE_VERSION_MAJOR EQUAL 2) +# ADD_DEFINITIONS(-DHAVE_GUILE2) +# ENDIF(GUILE_FOUND AND GUILE_VERSION_MAJOR EQUAL 2) + +# handle REQUIRED and QUIET options +include (FindPackageHandleStandardArgs) +if (CMAKE_VERSION LESS 2.8.3) + find_package_handle_standard_args (Guile DEFAULT_MSG GUILE_ROOT_DIR GUILE_INCLUDE_DIRS GUILE_LIBRARIES GUILE_VERSION_STRING) +else () + find_package_handle_standard_args (Guile REQUIRED_VARS GUILE_ROOT_DIR GUILE_INCLUDE_DIRS GUILE_LIBRARIES VERSION_VAR GUILE_VERSION_STRING) +endif () + + +MARK_AS_ADVANCED(GUILE_INCLUDE_DIR GUILE_LIBRARY) diff --git a/cmake/FindNumPy.cmake b/cmake/FindNumPy.cmake new file mode 100644 index 00000000..58bb531f --- /dev/null +++ b/cmake/FindNumPy.cmake @@ -0,0 +1,100 @@ +# - Find the NumPy libraries +# This module finds if NumPy is installed, and sets the following variables +# indicating where it is. +# +# TODO: Update to provide the libraries and paths for linking npymath lib. +# +# NUMPY_FOUND - was NumPy found +# NUMPY_VERSION - the version of NumPy found as a string +# NUMPY_VERSION_MAJOR - the major version number of NumPy +# NUMPY_VERSION_MINOR - the minor version number of NumPy +# NUMPY_VERSION_PATCH - the patch version number of NumPy +# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 +# NUMPY_INCLUDE_DIRS - path to the NumPy include files + +#============================================================================ +# Copyright 2012 Continuum Analytics, Inc. +# +# MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +#============================================================================ + +# Finding NumPy involves calling the Python interpreter +if(NumPy_FIND_REQUIRED) + find_package(PythonInterp REQUIRED) +else() + find_package(PythonInterp) +endif() + +if(NOT PYTHONINTERP_FOUND) + set(NUMPY_FOUND FALSE) + return() +endif() + +execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" + "import numpy as n; print(n.__version__); print(n.get_include());" + RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS + OUTPUT_VARIABLE _NUMPY_VALUES_OUTPUT + ERROR_VARIABLE _NUMPY_ERROR_VALUE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) + if(NumPy_FIND_REQUIRED) + message(FATAL_ERROR + "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") + endif() + set(NUMPY_FOUND FALSE) + return() +endif() + +# Convert the process output into a list +string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES_OUTPUT}) +string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) +list(GET _NUMPY_VALUES 0 NUMPY_VERSION) +list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS) + +string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" _VER_CHECK "${NUMPY_VERSION}") +if("${_VER_CHECK}" STREQUAL "") + # The output from Python was unexpected. Raise an error always + # here, because we found NumPy, but it appears to be corrupted somehow. + message(FATAL_ERROR + "Requested version and include path from NumPy, got instead:\n${_NUMPY_VALUES_OUTPUT}\n") + return() +endif() + +# Make sure all directory separators are '/' +string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + +# Get the major and minor version numbers +string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) +list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) +list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) +list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) +string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) +math(EXPR NUMPY_VERSION_DECIMAL + "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") + +find_package_message(NUMPY + "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" + "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") + +set(NUMPY_FOUND TRUE) diff --git a/cmake/FindOctave.cmake b/cmake/FindOctave.cmake new file mode 100644 index 00000000..2363f1c7 --- /dev/null +++ b/cmake/FindOctave.cmake @@ -0,0 +1,210 @@ +# - Find Octave +# GNU Octave is a high-level interpreted language, primarily intended for numerical computations. +# available at http://www.gnu.org/software/octave/ +# +# This module defines: +# OCTAVE_EXECUTABLE - octave interpreter +# OCTAVE_INCLUDE_DIRS - include path for mex.h, mexproto.h +# OCTAVE_LIBRARIES - required libraries: octinterp, octave, cruft +# OCTAVE_OCTINTERP_LIBRARY - path to the library octinterp +# OCTAVE_OCTAVE_LIBRARY - path to the library octave +# OCTAVE_CRUFT_LIBRARY - path to the library cruft +# OCTAVE_VERSION_STRING - octave version string +# OCTAVE_MAJOR_VERSION - major version +# OCTAVE_MINOR_VERSION - minor version +# OCTAVE_PATCH_VERSION - patch version +# OCTAVE_OCT_FILE_DIR - object files that will be dynamically loaded +# OCTAVE_OCT_LIB_DIR - oct libraries +# OCTAVE_ROOT_DIR - octave prefix +# OCTAVE_M_SITE_DIR - .m files site dir +# OCTAVE_OCT_SITE_DIR - .oct files site dir +# +# The macro octave_add_oct allows to create compiled modules. +# octave_add_oct (target_name +# [SOURCES] source1 [source2 ...] +# [LINK_LIBRARIES lib1 [lib2 ...]] +# [EXTENSION ext] +#) +# +# To install it, you can the use the variable OCTAVE_OCT_FILE_DIR as follow: +# file (RELATIVE_PATH PKG_OCTAVE_OCT_SITE_DIR ${OCTAVE_ROOT_DIR} ${OCTAVE_OCT_SITE_DIR}) +# install ( +# TARGETS target_name +# DESTINATION ${PKG_OCTAVE_OCT_SITE_DIR} +#) + + +#============================================================================= +# Copyright 2013, Julien Schueller +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# The views and conclusions contained in the software and documentation are those +# of the authors and should not be interpreted as representing official policies, +# either expressed or implied, of the FreeBSD Project. +#============================================================================= + +find_program(OCTAVE_CONFIG_EXECUTABLE + NAMES octave-config + ) + + +if (OCTAVE_CONFIG_EXECUTABLE) + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p PREFIX + OUTPUT_VARIABLE OCTAVE_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} --m-site-dir + OUTPUT_VARIABLE OCTAVE_M_SITE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} --oct-site-dir + OUTPUT_VARIABLE OCTAVE_OCT_SITE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p BINDIR + OUTPUT_VARIABLE OCTAVE_BIN_PATHS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTINCLUDEDIR + OUTPUT_VARIABLE OCTAVE_INCLUDE_PATHS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTLIBDIR + OUTPUT_VARIABLE OCTAVE_LIBRARIES_PATHS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTFILEDIR + OUTPUT_VARIABLE OCTAVE_OCT_FILE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTLIBDIR + OUTPUT_VARIABLE OCTAVE_OCT_LIB_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -v + OUTPUT_VARIABLE OCTAVE_VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (OCTAVE_VERSION_STRING) + string (REGEX REPLACE "([0-9]+)\\..*" "\\1" OCTAVE_MAJOR_VERSION ${OCTAVE_VERSION_STRING}) + string (REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" OCTAVE_MINOR_VERSION ${OCTAVE_VERSION_STRING}) + string (REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OCTAVE_PATCH_VERSION ${OCTAVE_VERSION_STRING}) + endif () +endif () + + +find_program(OCTAVE_EXECUTABLE + HINTS ${OCTAVE_BIN_PATHS} + NAMES octave + ) + +find_program(OCTAVE_MKOCTFILE + HINTS ${OCTAVE_BIN_PATHS} + NAMES mkoctfile + ) + +find_library(OCTAVE_OCTINTERP_LIBRARY + NAMES octinterp liboctinterp + HINTS ${OCTAVE_LIBRARIES_PATHS} + ) +find_library(OCTAVE_OCTAVE_LIBRARY + NAMES octave liboctave + HINTS ${OCTAVE_LIBRARIES_PATHS} + ) +find_library(OCTAVE_CRUFT_LIBRARY + NAMES cruft libcruft + HINTS ${OCTAVE_LIBRARIES_PATHS} + ) + +set (OCTAVE_LIBRARIES ${OCTAVE_OCTINTERP_LIBRARY}) +list (APPEND OCTAVE_LIBRARIES ${OCTAVE_OCTAVE_LIBRARY}) +if (OCTAVE_CRUFT_LIBRARY) + list (APPEND OCTAVE_LIBRARIES ${OCTAVE_CRUFT_LIBRARY}) +endif () + +find_path (OCTAVE_INCLUDE_DIR + NAMES octave/oct.h + PATHS "${OCTAVE_INCLUDE_PATHS}/.." + ) + +set (OCTAVE_INCLUDE_DIRS ${OCTAVE_INCLUDE_DIR}) + + +macro (octave_add_oct FUNCTIONNAME) + set (_CMD SOURCES) + set (_SOURCES) + set (_LINK_LIBRARIES) + set (_EXTENSION) + set (_OCT_EXTENSION oct) + foreach (_ARG ${ARGN}) + if (${_ARG} MATCHES SOURCES) + set (_CMD SOURCES) + elseif (${_ARG} MATCHES LINK_LIBRARIES) + set (_CMD LINK_LIBRARIES) + elseif (${_ARG} MATCHES EXTENSION) + set (_CMD EXTENSION) + else () + if (${_CMD} MATCHES SOURCES) + list (APPEND _SOURCES "${_ARG}") + elseif (${_CMD} MATCHES LINK_LIBRARIES) + list (APPEND _LINK_LIBRARIES "${_ARG}") + elseif (${_CMD} MATCHES EXTENSION) + set (_OCT_EXTENSION ${_ARG}) + endif () + endif () + endforeach () + add_library (${FUNCTIONNAME} SHARED ${_SOURCES}) + target_link_libraries (${FUNCTIONNAME} ${OCTAVE_LIBRARIES} ${_LINK_LIBRARIES}) + set_target_properties (${FUNCTIONNAME} PROPERTIES + PREFIX "" + SUFFIX ".${_OCT_EXTENSION}" +) +endmacro () + + +# handle REQUIRED and QUIET options +include (FindPackageHandleStandardArgs) +if (CMAKE_VERSION LESS 2.8.3) + find_package_handle_standard_args (Octave DEFAULT_MSG OCTAVE_EXECUTABLE OCTAVE_ROOT_DIR OCTAVE_INCLUDE_DIRS OCTAVE_LIBRARIES OCTAVE_VERSION_STRING) +else () + find_package_handle_standard_args (Octave REQUIRED_VARS OCTAVE_EXECUTABLE OCTAVE_ROOT_DIR OCTAVE_INCLUDE_DIRS OCTAVE_LIBRARIES VERSION_VAR OCTAVE_VERSION_STRING) +endif () + + +mark_as_advanced ( + OCTAVE_OCT_FILE_DIR + OCTAVE_OCT_LIB_DIR + OCTAVE_OCTINTERP_LIBRARY + OCTAVE_OCTAVE_LIBRARY + OCTAVE_CRUFT_LIBRARY + OCTAVE_LIBRARIES + OCTAVE_INCLUDE_DIR + OCTAVE_INCLUDE_DIRS + OCTAVE_ROOT_DIR + OCTAVE_VERSION_STRING + OCTAVE_MAJOR_VERSION + OCTAVE_MINOR_VERSION + OCTAVE_PATCH_VERSION +) + + + diff --git a/cmake/NLoptConfig.cmake.in b/cmake/NLoptConfig.cmake.in new file mode 100644 index 00000000..541808bb --- /dev/null +++ b/cmake/NLoptConfig.cmake.in @@ -0,0 +1,26 @@ + +# defined since 2.8.3 +if (CMAKE_VERSION VERSION_LESS 2.8.3) + get_filename_component (CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +endif () + +# Tell the user project where to find our headers and libraries + +set (NLOPT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/@RELATIVE_NLOPT_INCLUDE_DIRS@") +set (NLOPT_LIBRARY_DIRS "${CMAKE_CURRENT_LIST_DIR}/@RELATIVE_NLOPT_LIB_DIR@") + +# Allows loading NLOPT settings from another project +set (NLOPT_CONFIG_FILE "${CMAKE_CURRENT_LIST_FILE}") + +# List of compilation flags -DTOTO to export +set (NLOPT_DEFINITIONS "@NLOPT_DEFINITIONS@") + +# Our library dependencies (contains definitions for IMPORTED targets) +include ("${CMAKE_CURRENT_LIST_DIR}/NLoptLibraryDepends.cmake") + +# These are IMPORTED targets created by NLOPTLibraryDepends.cmake +set (NLOPT_LIBRARIES "@NLOPT_LIBRARIES@") + +if (CMAKE_VERSION VERSION_LESS 2.8.3) + set (CMAKE_CURRENT_LIST_DIR) +endif () diff --git a/cmake/NLoptConfigVersion.cmake.in b/cmake/NLoptConfigVersion.cmake.in new file mode 100644 index 00000000..ee4df4e1 --- /dev/null +++ b/cmake/NLoptConfigVersion.cmake.in @@ -0,0 +1,12 @@ + +set (PACKAGE_VERSION "@NLOPT_VERSION_STRING@") + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set (PACKAGE_VERSION_COMPATIBLE FALSE) +else () + set (PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set (PACKAGE_VERSION_EXACT TRUE) + endif () +endif () diff --git a/cmake/toolchain-i686-w64-mingw32.cmake b/cmake/toolchain-i686-w64-mingw32.cmake new file mode 100644 index 00000000..ff9b450a --- /dev/null +++ b/cmake/toolchain-i686-w64-mingw32.cmake @@ -0,0 +1,32 @@ +set (CMAKE_SYSTEM_NAME Windows) + +# specify the cross compiler +set (CMAKE_C_COMPILER i686-w64-mingw32-gcc) +set (CMAKE_CXX_COMPILER i686-w64-mingw32-g++) + +# where is the target environment +set (CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) + +# search for programs in the build host directories +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# Make sure Qt can be detected by CMake +set (QT_BINARY_DIR /usr/i686-w64-mingw32/bin /usr/bin) +set (QT_INCLUDE_DIRS_NO_SYSTEM ON) + +# set the resource compiler (RHBZ #652435) +set (CMAKE_RC_COMPILER i686-w64-mingw32-windres) +set (CMAKE_MC_COMPILER i686-w64-mingw32-windmc) + +# override boost thread component suffix as mingw-w64-boost is compiled with threadapi=win32 +set (Boost_THREADAPI win32) + +# These are needed for compiling lapack (RHBZ #753906) +set (CMAKE_Fortran_COMPILER i686-w64-mingw32-gfortran) +set (CMAKE_AR:FILEPATH i686-w64-mingw32-ar) +set (CMAKE_RANLIB:FILEPATH i686-w64-mingw32-ranlib) + diff --git a/cmake/toolchain-x86_64-w64-mingw32.cmake b/cmake/toolchain-x86_64-w64-mingw32.cmake new file mode 100644 index 00000000..470b4782 --- /dev/null +++ b/cmake/toolchain-x86_64-w64-mingw32.cmake @@ -0,0 +1,32 @@ +set (CMAKE_SYSTEM_NAME Windows) + +# specify the cross compiler +set (CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set (CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + +# where is the target environment +set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + +# search for programs in the build host directories +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# Make sure Qt can be detected by CMake +set (QT_BINARY_DIR /usr/x86_64-w64-mingw32/bin /usr/bin) +set (QT_INCLUDE_DIRS_NO_SYSTEM ON) + +# set the resource compiler (RHBZ #652435) +set (CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) +set (CMAKE_MC_COMPILER x86_64-w64-mingw32-windmc) + +# override boost thread component suffix as mingw-w64-boost is compiled with threadapi=win32 +set (Boost_THREADAPI win32) + +# These are needed for compiling lapack (RHBZ #753906) +set (CMAKE_Fortran_COMPILER x86_64-w64-mingw32-gfortran) +set (CMAKE_AR:FILEPATH x86_64-w64-mingw32-ar) +set (CMAKE_RANLIB:FILEPATH x86_64-w64-mingw32-ranlib) + diff --git a/cobyla/Makefile.am b/cobyla/Makefile.am deleted file mode 100644 index 2c5752a3..00000000 --- a/cobyla/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libcobyla.la -libcobyla_la_SOURCES = cobyla.c cobyla.h - -EXTRA_DIST = README COPYRIGHT README.orig diff --git a/config.cmake.h.in b/config.cmake.h.in index 0dce2dba..0937ab73 100644 --- a/config.cmake.h.in +++ b/config.cmake.h.in @@ -25,14 +25,20 @@ /* Define to 1 if you have the `BSDgettimeofday' function. */ #undef HAVE_BSDGETTIMEOFDAY +/* Define if the copysign function/macro is available. */ +#cmakedefine HAVE_COPYSIGN + /* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H +#cmakedefine HAVE_DLFCN_H + +/* Define if the fpclassify() function/macro is available. */ +#cmakedefine HAVE_FPCLASSIFY /* Define to 1 if you have the header file. */ -#undef HAVE_GETOPT_H +#cmakedefine HAVE_GETOPT_H /* Define to 1 if you have the `getpid' function. */ -#undef HAVE_GETPID +#cmakedefine HAVE_GETPID /* Define if syscall(SYS_gettid) available. */ #undef HAVE_GETTID_SYSCALL @@ -40,9 +46,6 @@ /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine HAVE_GETTIMEOFDAY -/* Define if the copysign function/macro is available. */ -#cmakedefine HAVE_COPYSIGN - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H @@ -79,6 +82,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H + /* Define to 1 if you have the `time' function. */ #cmakedefine HAVE_TIME @@ -126,26 +132,23 @@ #define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@ /* The size of `unsigned long', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_LONG +#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to C thread-local keyword, or to nothing if this is not supported in your compiler. */ -#define THREADLOCAL +#define THREADLOCAL @THREADLOCAL@ /* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME +#cmakedefine TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define if compiled including C++-based routines */ -#undef WITH_CXX - -/* Define if we have the non-free Nocedal LBFGS code */ -#undef WITH_NOCEDAL +#cmakedefine WITH_CXX /* Define to empty if `const' does not conform to ANSI C. */ #undef const @@ -155,5 +158,3 @@ #ifndef __cplusplus #undef inline #endif - - diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 7e3cc218..00000000 --- a/configure.ac +++ /dev/null @@ -1,448 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(nlopt, 2.5, stevenj@alum.mit.edu) -AC_CONFIG_SRCDIR(api/nlopt.h) -SHARED_VERSION_INFO="9:0:9" # CURRENT:REVISION:AGE - -AM_INIT_AUTOMAKE(1.7) -AM_CONFIG_HEADER(config.h) -AC_CONFIG_MACRO_DIR([m4]) -AM_MAINTAINER_MODE -AC_SUBST(SHARED_VERSION_INFO) -AC_DISABLE_SHARED dnl shared libraries are a PITA, disable by default - -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 - -NLOPT_SUFFIX="" -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) -AC_PROG_CXX -if test "x$with_cxx" = xyes; then - AC_DEFINE([WITH_CXX], 1, [Define if compiled including C++-based routines]) - NLOPT_SUFFIX="_cxx" - CC=$CXX - CFLAGS=$CXXFLAGS -fi -AC_SUBST(NLOPT_SUFFIX) - -AC_ARG_WITH(mthreads, - [AC_HELP_STRING([--with-mthreads], [use -mthreads compiler flag])], - with_mthrads=$withval,with_mthreads=no) -if test "x$with_mthreads" = xyes; then - CFLAGS="$CFLAGS -mthreads" - CXXFLAGS="$CXXFLAGS -mthreads" -fi - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDC -AC_HEADER_TIME -AC_CHECK_HEADERS([unistd.h getopt.h stdint.h]) -AC_C_CONST -AC_C_INLINE -AX_C_THREADLOCAL - -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 -#endif]) - -dnl Checks for libraries and functions -AC_CHECK_LIB(m, sin) -AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time qsort_r getpid]) - -AC_MSG_CHECKING([for gettid syscall]) -AC_TRY_LINK([#include -#include -], [syscall(SYS_gettid);], [ok=yes], [ok=no]) -if test "$ok" = "yes"; then - AC_DEFINE(HAVE_GETTID_SYSCALL,1,[Define if syscall(SYS_gettid) available.]) -fi -AC_MSG_RESULT(${ok}) - -AC_MSG_CHECKING([for isnan]) -AC_TRY_LINK([#include -], [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 -], [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}) - -AC_MSG_CHECKING([for fpclassify]) -AC_TRY_LINK([#include -], [if (!fpclassify(3.14159)) fpclassify(2.7183);], ok=yes, ok=no) -if test "$ok" = "yes"; then - AC_DEFINE(HAVE_FPCLASSIFY,1,[Define if the fpclassify() function/macro is available.]) -fi -AC_MSG_RESULT(${ok}) - -AC_MSG_CHECKING([for copysign]) -AC_TRY_LINK([#include -], [double x = copysign(3.14159, -2.7183);], ok=yes, ok=no) -if test "$ok" = "yes"; then - AC_DEFINE(HAVE_COPYSIGN,1,[Define if the copysign function/macro is available.]) -fi -AC_MSG_RESULT(${ok}) - -dnl ----------------------------------------------------------------------- -dnl SWIG wrappers - -AC_ARG_WITH(guile, - [AC_HELP_STRING([--without-guile], [don't compile Guile plugin])], - with_guile=$withval,with_guile=yes) -AC_ARG_WITH(python, - [AC_HELP_STRING([--without-python], [don't compile Python plugin])], - with_python=$withval,with_python=yes) - -if test "$enable_shared" = no; then - AC_MSG_WARN([Python and Guile wrappers require --enable-shared; disabling]) - GUILE_CONFIG=unknown - have_python=no -else - -if test "x$with_guile" = xno; then - GUILE_CONFIG=unknown -else - -dnl Guile: -AC_ARG_VAR(GUILE_INSTALL_DIR, [where to install Guile plug-ins]) -AC_CHECK_PROG(GUILE_CONFIG, guile-config, guile-config, unknown) -if test "x$GUILE_CONFIG" = "xunknown"; then - AC_MSG_WARN([can't find guile-config, disabling Guile wrapper]) -else - save_CPPFLAGS=$CPPFLAGS - save_LIBS=$LIBS - GUILE_CPPFLAGS=`$GUILE_CONFIG compile` - GUILE_LIBS=`$GUILE_CONFIG link` - CPPFLAGS="$CPPFLAGS $GUILE_CPPFLAGS" - LIBS="$GUILE_LIBS $LIBS" - AC_MSG_CHECKING([if linking to guile works]) - AC_TRY_LINK_FUNC(scm_is_vector, [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) - AC_MSG_WARN(guile-config is broken, disabling Guile wrapper) - GUILE_CONFIG="unknown"]) - CPPFLAGS=$save_CPPFLAGS - LIBS=$save_LIBS -fi -AC_CHECK_PROG(GUILE, guile, guile, unknown) -if test "x$GUILE" = xunknown; then - AC_MSG_WARN([can't find guile, disabling Guile wrapper]) - GUILE_CONFIG=unknown -elif test x"$GUILE_INSTALL_DIR" = "x"; then - AC_CHECK_PROGS(GUILE_CONFIG, guile-config, echo) - AC_MSG_CHECKING(guile prefix) - GUILE_PREFIX=`$GUILE_CONFIG info prefix` - AC_MSG_RESULT($GUILE_PREFIX) - AC_MSG_CHECKING([for Guile installation directory]) - GUILE_INSTALL_DIR=`guile -c '(display (%site-dir))'` - if test "$prefix" != "NONE"; then - # strip guile install path to honor prefix - GUILE_INSTALL_DIR=`echo "$GUILE_INSTALL_DIR" | sed "s|$GUILE_PREFIX|$prefix|g"` - fi - - AC_MSG_RESULT([$GUILE_INSTALL_DIR]) -fi - -fi # with_guile - -if test "x$with_python" = xno; then - have_python=no -else - -dnl Python: -AM_PATH_PYTHON([],[have_python=yes],[have_python=no]) -if test $have_python = yes; then - AC_ARG_VAR([PYTHON_CONFIG], [python-config program]) - AC_PATH_PROGS([PYTHON_CONFIG], [python$PYTHON_VERSION-config python-config], - [unknown], [`dirname $PYTHON`:$PATH]) - AC_MSG_CHECKING([for Python include flags]) - if test "x$PYTHON_CONFIG" = "xunknown"; then - pinc=-I`echo "import distutils.sysconfig; print (distutils.sysconfig.get_python_inc())" | $PYTHON - 2>/dev/null` - test "x$pinc" = "x-I" && pinc="" - else - pinc=`$PYTHON_CONFIG --includes 2>/dev/null` - fi - AC_MSG_RESULT([${pinc:-unknown}]) - PYTHON_INCLUDES="$pinc" - PYTHON_LIBS=`$PYTHON_CONFIG --libs 2>/dev/null` - save_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" - AC_CHECK_HEADER([Python.h], [], [AC_MSG_WARN([disabling Python wrappers]) - have_python=no]) - if test $have_python = yes; then - AC_MSG_CHECKING([for Numpy include directory]) - pinc=`echo "import numpy; print (numpy.get_include())" | $PYTHON - 2>/dev/null` - AC_MSG_RESULT([${pinc:-unknown}]) - test -n "$pinc" && PYTHON_INCLUDES="$PYTHON_INCLUDES -I$pinc" - CPPFLAGS="$save_CPPFLAGS $PYTHON_INCLUDES" - AC_CHECK_HEADER([numpy/arrayobject.h],[],[ - AC_MSG_WARN([disabling Python wrappers]) - have_python=no],[#include ]) - fi - CPPFLAGS=$save_CPPFLAGS -fi - -fi # with_python - -fi # if enable_shared - -AC_SUBST(GUILE_INSTALL_DIR) -AC_SUBST(GUILE_CPPFLAGS) -AC_SUBST(GUILE_LIBS) -AC_SUBST(PYTHON_INCLUDES) -AC_SUBST(PYTHON_LIBS) -AM_CONDITIONAL(WITH_GUILE, test x"$GUILE_CONFIG" != "xunknown") -AM_CONDITIONAL(WITH_PYTHON, test x"$have_python" = "xyes") - -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_ARG_WITH(octave, - [AC_HELP_STRING([--without-octave], [don't compile Octave plugin])], - with_octave=$withval,with_octave=yes) - -AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo) - -if test x"$with_octave" = xno; then - OCT_INSTALL_DIR="" -elif test "$MKOCTFILE" = "echo"; then - AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin]) - OCT_INSTALL_DIR="" -elif test x"$OCT_INSTALL_DIR" = "x"; then - # try to find installation directory - AC_CHECK_PROGS(OCTAVE, octave, echo) - AC_CHECK_PROGS(OCTAVE_CONFIG, octave-config, echo) - - AC_MSG_CHECKING(octave prefix) - OCTAVE_PREFIX=`$OCTAVE_CONFIG --print PREFIX 2> /dev/null` - AC_MSG_RESULT($OCTAVE_PREFIX) - - AC_MSG_CHECKING(where octave plugins go) - OCT_INSTALL_DIR=`$OCTAVE_CONFIG --oct-site-dir 2> /dev/null | grep '/'` - if test -z "$OCT_INSTALL_DIR"; then - OCT_INSTALL_DIR=`$OCTAVE_CONFIG --print OCTFILEDIR 2> /dev/null | grep '/'` - fi - if test -z "$OCT_INSTALL_DIR"; then - OCT_INSTALL_DIR=`echo "path" | $OCTAVE -q 2> /dev/null | grep "/oct/" | head -1` - fi - if test -z "$OCT_INSTALL_DIR"; then - OCT_INSTALL_DIR=`echo "DEFAULT_LOADPATH" | $OCTAVE -q 2> /dev/null | tr ':' '\n' | grep "site/oct" | head -1` - fi - if test -n "$OCT_INSTALL_DIR"; then - if test "$prefix" != "NONE"; then - # strip octave install path to honor prefix - OCT_INSTALL_DIR=`echo "$OCT_INSTALL_DIR" | sed "s|$OCTAVE_PREFIX|$prefix|g"` - fi - AC_MSG_RESULT($OCT_INSTALL_DIR) - else - AC_MSG_RESULT(unknown) - AC_MSG_WARN([can't find where to install octave plugins: won't be able to compile octave plugin]) - fi - - AC_MSG_CHECKING(where octave scripts go) - M_INSTALL_DIR=`$OCTAVE_CONFIG --m-site-dir 2> /dev/null | grep '/'` - if test -z "$M_INSTALL_DIR"; then - M_INSTALL_DIR=`$OCTAVE_CONFIG --print FCNFILEDIR 2> /dev/null | grep '/'` - fi - if test -z "$M_INSTALL_DIR"; then - M_INSTALL_DIR=`echo "path" | $OCTAVE -q 2> /dev/null | grep "/m" | head -1` - fi - if test -z "$M_INSTALL_DIR"; then - M_INSTALL_DIR=`echo "DEFAULT_LOADPATH" | $OCTAVE -q 2> /dev/null | tr ':' '\n' | grep "site/m" | head -1` - fi - if test -n "$M_INSTALL_DIR"; then - if test "$prefix" != "NONE"; then - # strip octave install path to honor prefix - M_INSTALL_DIR=`echo "$M_INSTALL_DIR" | sed "s|$OCTAVE_PREFIX|$prefix|g"` - fi - AC_MSG_RESULT($M_INSTALL_DIR) - else - AC_MSG_RESULT(unknown) - AC_MSG_WARN([can't find where to install octave scripts: won't be able to install octave plugin]) - OCT_INSTALL_DIR="" - fi -elif test x"$M_INSTALL_DIR" = "x"; then # user-specified OCT_INSTALL_DIR - M_INSTALL_DIR=$OCT_INSTALL_DIR -fi - -if test x"$OCT_INSTALL_DIR" != "x"; then -if test "$enable_shared" = no; then - AC_MSG_WARN([mkoctfile requires --enable-shared; won't compile Octave plugin]) - OCT_INSTALL_DIR="" -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) - -dnl ----------------------------------------------------------------------- -dnl Compiling Matlab plug-in - -AC_ARG_WITH(matlab, - [AC_HELP_STRING([--without-matlab], [don't compile Matlab plugin])], - with_matlab=$withval,with_matlab=yes) - -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 x"$with_matlab" = xno; then - MEX_INSTALL_DIR="" -elif test "$MEX" = "echo"; then - AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin]) - MEX_INSTALL_DIR="" -else - AC_MSG_CHECKING([for extension of compiled mex files]) - rm -f conftest* - cat > conftest.c < -void mexFunction(int nlhs, mxArray *plhs[[]], - int nrhs, const mxArray *prhs[[]]) { } -EOF - if $MEX conftest.c >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; 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]) - MEX_INSTALL_DIR="" - MATLAB=echo - fi - - if test x"$MATLAB" != xecho; then - if test "$enable_shared" = no; then - AC_MSG_RESULT(no) - AC_MSG_WARN([mex requires --enable-shared; won't compile Matlab plugin]) - MEX_INSTALL_DIR="" - MATLAB=echo - fi - fi - - if test x"$MATLAB" != xecho; then - # try to find installation directory - if test x"$MEX_INSTALL_DIR" = "x"; then - AC_MSG_CHECKING(for MATLAB mex installation dir) - MEX_INSTALL_DIR=`matlab -nodisplay -nodesktop -nojvm -r 'path;quit' | grep toolbox/local |sed 's,^[[^/]]*,,g' |sort |head -1` - AC_MSG_RESULT($MEX_INSTALL_DIR) - if test x`basename "$MEX_INSTALL_DIR"` != xlocal; then - MEX_INSTALL_DIR="" - fi - if test x"$MEX_INSTALL_DIR" = "x"; then - AC_MSG_WARN([can't find reasonable Matlab installation directory; Matlab plugins will not be compiled unless you manually specify MEX_INSTALL_DIR]) - fi - fi - else - 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) - -dnl ----------------------------------------------------------------------- -dnl Check for broken Solaris HUGE_VAL macro under gcc 3.4.x and similar - -AC_MSG_CHECKING([for working HUGE_VAL]) -AC_TRY_COMPILE([#include ], [double x = -HUGE_VAL;], -[AC_MSG_RESULT([ok])], -[AC_TRY_COMPILE([#include -#ifdef __GNUC__ -#undef HUGE_VAL -#define HUGE_VAL __builtin_huge_val() -#endif], [double x = -HUGE_VAL;], -[AC_MSG_RESULT([__builtin_huge_val()]) -AC_DEFINE(REPLACEMENT_HUGE_VAL,[__builtin_huge_val()], - [replacement for broken HUGE_VAL macro, if needed])], -[AC_MSG_RESULT([unknown]) -AC_MSG_ERROR([broken HUGE_VAL macro with this compiler, unknown workaround])])]) - -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 -Wno-long-long -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 -Wno-long-long -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion" - fi - if test "x$with_cxx" = xyes; then - CFLAGS=$CXXFLAGS - fi -fi -fi - -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.]) - -dnl ----------------------------------------------------------------------- - -AC_CONFIG_FILES([ - Makefile - nlopt.pc - api/Makefile - util/Makefile - octave/Makefile - direct/Makefile - cdirect/Makefile - stogo/Makefile - praxis/Makefile - luksan/Makefile - crs/Makefile - mlsl/Makefile - mma/Makefile - cobyla/Makefile - newuoa/Makefile - neldermead/Makefile - auglag/Makefile - bobyqa/Makefile - isres/Makefile - slsqp/Makefile - esch/Makefile - test/Makefile - swig/Makefile - swig/nlopt.scm -]) - -AC_OUTPUT diff --git a/cquad/Makefile.am b/cquad/Makefile.am deleted file mode 100644 index 9a9016a3..00000000 --- a/cquad/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libcquad.la -libcquad_la_SOURCES = cquad.c cquad.h - -EXTRA_DIST = README diff --git a/crs/Makefile.am b/crs/Makefile.am deleted file mode 100644 index 14ff7cbc..00000000 --- a/crs/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libcrs.la -libcrs_la_SOURCES = crs.c crs.h - -EXTRA_DIST = README diff --git a/direct/Makefile.am b/direct/Makefile.am deleted file mode 100644 index 161dded9..00000000 --- a/direct/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libdirect.la -libdirect_la_SOURCES = DIRect.c direct_wrap.c DIRserial.c DIRsubrout.c \ -direct-internal.h direct.h - -EXTRA_DIST = README AUTHORS COPYING DIRparallel.c tstc.c userguide.pdf diff --git a/esch/Makefile.am b/esch/Makefile.am deleted file mode 100644 index 377c00ff..00000000 --- a/esch/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libesch.la -libesch_la_SOURCES = esch.c esch.h - -EXTRA_DIST = README COPYRIGHT diff --git a/isres/Makefile.am b/isres/Makefile.am deleted file mode 100644 index d8192483..00000000 --- a/isres/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libisres.la -libisres_la_SOURCES = isres.c isres.h - -EXTRA_DIST = README diff --git a/luksan/Makefile.am b/luksan/Makefile.am deleted file mode 100644 index f302a795..00000000 --- a/luksan/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libluksan.la -libluksan_la_SOURCES = plis.c plip.c pnet.c mssubs.c pssubs.c luksan.h - -EXTRA_DIST = README COPYRIGHT plis.txt v999-07.pdf diff --git a/m4/ax_c_threadlocal.m4 b/m4/ax_c_threadlocal.m4 deleted file mode 100644 index 0fdb30e5..00000000 --- a/m4/ax_c_threadlocal.m4 +++ /dev/null @@ -1,47 +0,0 @@ -dnl @synopsis AX_C_THREADLOCAL([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -dnl @summary determine C keyword for threadlocal storage -dnl -dnl This macro tries to discover a C keyword to declare variables -dnl as having thread-local storage. Most commonly, this is either -dnl __thread [gcc] or __declspec(thread) [Windows]. -dnl -dnl On success, it #defines the THREADLOCAL preprocessor symbol to -dnl the appropriate keyword. You would then use it in C code as, e.g.: -dnl THREADLOCAL int myvariable; -dnl -dnl ACTION-IF-FOUND is a list of shell commands to run if an thread-local -dnl keyword is found, and ACTION-IF-NOT-FOUND is a list of commands -dnl to run it if one is not found. If ACTION-IF-FOUND is not specified, -dnl the default action does nothing. -dnl -dnl @version 2010-05-28 -dnl @license GPLWithACException -dnl @author Steven G. Johnson -AC_DEFUN([AX_C_THREADLOCAL], -[AC_ARG_WITH(threadlocal, - [AC_HELP_STRING([--without-threadlocal], [no thread-local storage keyword])], - with_ax_c_threadlocal=$withval, with_ax_c_threadlocal=yes) - AC_CACHE_CHECK([for C thread-local keyword], ax_cv_c_threadlocal, -[if test "x$with_ax_c_threadlocal" = xno; then - ax_cv_c_threadlocal=disabled - else - ax_cv_c_threadlocal=unsupported - AC_LANG_SAVE - AC_LANG_C - for ax_kw in __thread "__declspec(thread)"; do - AC_TRY_COMPILE([], [static $ax_kw int x = 0;], - [ax_cv_c_threadlocal=$ax_kw; break]) - done - AC_LANG_RESTORE - fi -]) - ax_kw="$ax_cv_c_threadlocal" - if test "x$ax_kw" = xunsupported; then ax_kw=""; fi - if test "x$ax_kw" = xdisabled; then ax_kw=""; fi - AC_DEFINE_UNQUOTED(THREADLOCAL, $ax_kw, [Define to C thread-local keyword, or to nothing if this is not supported in your compiler.]) - if test "$ax_cv_c_threadlocal" = unsupported; then - m4_default([$2],:) - else - m4_default([$1],:) - fi -]) diff --git a/mlsl/Makefile.am b/mlsl/Makefile.am deleted file mode 100644 index b019c2c2..00000000 --- a/mlsl/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libmlsl.la -libmlsl_la_SOURCES = mlsl.c mlsl.h - -EXTRA_DIST = README diff --git a/mma/Makefile.am b/mma/Makefile.am deleted file mode 100644 index f453b75a..00000000 --- a/mma/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libmma.la -libmma_la_SOURCES = mma.c ccsa_quadratic.c mma.h - -EXTRA_DIST = README diff --git a/neldermead/Makefile.am b/neldermead/Makefile.am deleted file mode 100644 index 1c9ed8a3..00000000 --- a/neldermead/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libneldermead.la -libneldermead_la_SOURCES = nldrmd.c neldermead.h sbplx.c - -EXTRA_DIST = README diff --git a/newuoa/Makefile.am b/newuoa/Makefile.am deleted file mode 100644 index 74abf1af..00000000 --- a/newuoa/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libnewuoa.la -libnewuoa_la_SOURCES = newuoa.c newuoa.h - -EXTRA_DIST = README README.orig COPYRIGHT diff --git a/nlopt.pc.in b/nlopt.pc.in index 28f051be..81d96299 100644 --- a/nlopt.pc.in +++ b/nlopt.pc.in @@ -1,10 +1,10 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include Name: NLopt Description: nonlinear optimization libary -Version: @VERSION@ +Version: @NLOPT_VERSION_STRING@ Libs: -L${libdir} -lnlopt@NLOPT_SUFFIX@ -lm Cflags: -I${includedir} diff --git a/octave/CMakeLists.txt b/octave/CMakeLists.txt new file mode 100644 index 00000000..54534623 --- /dev/null +++ b/octave/CMakeLists.txt @@ -0,0 +1,25 @@ + +file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/nlopt_optimize_usage.h "#define NLOPT_OPTIMIZE_USAGE \\\n") +file (STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt_optimize.m INPUT_LINES) +foreach (INPUT_LINE ${INPUT_LINES}) + string (REGEX REPLACE "^% " "" INPUT_LINE ${INPUT_LINE}) + string (REGEX REPLACE "^%" "" INPUT_LINE ${INPUT_LINE}) + foreach (repl_expr "tolerance" "help NLOPT_LN_SBPLX" "population") + string (REGEX REPLACE "\"${repl_expr}\"" "${repl_expr}" INPUT_LINE "${INPUT_LINE}") + endforeach () + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt_optimize_usage.h "\"${INPUT_LINE}\\n\" \\\n") +endforeach () +file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt_optimize_usage.h "\n") + +include_directories (${OCTAVE_INCLUDE_DIRS}) +include_directories (${CMAKE_CURRENT_BINARY_DIR}) +octave_add_oct (nlopt_optimize SOURCES nlopt_optimize-oct.cc ${CMAKE_CURRENT_BINARY_DIR}/nlopt_optimize_usage.h LINK_LIBRARIES ${nlopt_lib}) + +file (RELATIVE_PATH PKG_OCTAVE_OCT_SITE_DIR ${OCTAVE_ROOT_DIR} ${OCTAVE_OCT_SITE_DIR}) +install (TARGETS nlopt_optimize DESTINATION ${PKG_OCTAVE_OCT_SITE_DIR}) + +set (MFILES NLOPT_GN_DIRECT.m NLOPT_GN_DIRECT_L.m NLOPT_GN_DIRECT_L_RAND.m NLOPT_GN_DIRECT_NOSCAL.m NLOPT_GN_DIRECT_L_NOSCAL.m NLOPT_GN_DIRECT_L_RAND_NOSCAL.m NLOPT_GN_ORIG_DIRECT.m NLOPT_GN_ORIG_DIRECT_L.m NLOPT_GD_STOGO.m NLOPT_GD_STOGO_RAND.m NLOPT_LD_LBFGS_NOCEDAL.m NLOPT_LD_LBFGS.m NLOPT_LN_PRAXIS.m NLOPT_LD_VAR1.m NLOPT_LD_VAR2.m NLOPT_LD_TNEWTON.m NLOPT_LD_TNEWTON_RESTART.m NLOPT_LD_TNEWTON_PRECOND.m NLOPT_LD_TNEWTON_PRECOND_RESTART.m NLOPT_GN_CRS2_LM.m NLOPT_GN_MLSL.m NLOPT_GD_MLSL.m NLOPT_GN_MLSL_LDS.m NLOPT_GD_MLSL_LDS.m NLOPT_LD_MMA.m NLOPT_LN_COBYLA.m NLOPT_LN_NEWUOA.m NLOPT_LN_NEWUOA_BOUND.m NLOPT_LN_NELDERMEAD.m NLOPT_LN_SBPLX.m NLOPT_LN_AUGLAG.m NLOPT_LD_AUGLAG.m NLOPT_LN_AUGLAG_EQ.m NLOPT_LD_AUGLAG_EQ.m NLOPT_LN_BOBYQA.m NLOPT_GN_ISRES.m NLOPT_AUGLAG.m NLOPT_AUGLAG_EQ.m NLOPT_G_MLSL.m NLOPT_G_MLSL_LDS.m NLOPT_LD_SLSQP.m NLOPT_LD_CCSAQ.m NLOPT_GN_ESCH.m) +set (M_DATA ${MFILES} nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m) + +file (RELATIVE_PATH PKG_OCTAVE_M_SITE_DIR ${OCTAVE_ROOT_DIR} ${OCTAVE_M_SITE_DIR}) +install (FILES ${M_DATA} DESTINATION ${PKG_OCTAVE_M_SITE_DIR}) diff --git a/octave/Makefile.am b/octave/Makefile.am deleted file mode 100644 index 695491cb..00000000 --- a/octave/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/util - -MFILES = NLOPT_GN_DIRECT.m NLOPT_GN_DIRECT_L.m NLOPT_GN_DIRECT_L_RAND.m NLOPT_GN_DIRECT_NOSCAL.m NLOPT_GN_DIRECT_L_NOSCAL.m NLOPT_GN_DIRECT_L_RAND_NOSCAL.m NLOPT_GN_ORIG_DIRECT.m NLOPT_GN_ORIG_DIRECT_L.m NLOPT_GD_STOGO.m NLOPT_GD_STOGO_RAND.m NLOPT_LD_LBFGS_NOCEDAL.m NLOPT_LD_LBFGS.m NLOPT_LN_PRAXIS.m NLOPT_LD_VAR1.m NLOPT_LD_VAR2.m NLOPT_LD_TNEWTON.m NLOPT_LD_TNEWTON_RESTART.m NLOPT_LD_TNEWTON_PRECOND.m NLOPT_LD_TNEWTON_PRECOND_RESTART.m NLOPT_GN_CRS2_LM.m NLOPT_GN_MLSL.m NLOPT_GD_MLSL.m NLOPT_GN_MLSL_LDS.m NLOPT_GD_MLSL_LDS.m NLOPT_LD_MMA.m NLOPT_LN_COBYLA.m NLOPT_LN_NEWUOA.m NLOPT_LN_NEWUOA_BOUND.m NLOPT_LN_NELDERMEAD.m NLOPT_LN_SBPLX.m NLOPT_LN_AUGLAG.m NLOPT_LD_AUGLAG.m NLOPT_LN_AUGLAG_EQ.m NLOPT_LD_AUGLAG_EQ.m NLOPT_LN_BOBYQA.m NLOPT_GN_ISRES.m NLOPT_AUGLAG.m NLOPT_AUGLAG_EQ.m NLOPT_G_MLSL.m NLOPT_G_MLSL_LDS.m NLOPT_LD_SLSQP.m NLOPT_LD_CCSAQ.m NLOPT_GN_ESCH.m - -####################################################################### -# dummy C program to fool automake into making sure that CPPFLAGS etc. -# are all defined -noinst_PROGRAMS = dummy -dummy_SOURCES = dummy.c - -####################################################################### -octdir = $(OCT_INSTALL_DIR) -mdir = $(M_INSTALL_DIR) -if WITH_OCTAVE -oct_DATA = nlopt_optimize.oct -m_DATA = $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m -endif - -nlopt_optimize.oct: nlopt_optimize-oct.cc nlopt_optimize_usage.h $(top_builddir)/.libs/libnlopt@NLOPT_SUFFIX@.la - $(MKOCTFILE) -o $@ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(srcdir)/nlopt_optimize-oct.cc $(LDFLAGS) -L$(top_builddir)/.libs -lnlopt@NLOPT_SUFFIX@ - -BUILT_SOURCES = nlopt_optimize_usage.h -MAINTAINERCLEANFILES = $(BUILT_SOURCES) - -nlopt_optimize_usage.h: $(srcdir)/nlopt_optimize.m - echo "#define NLOPT_OPTIMIZE_USAGE \\" > $@ - sed 's/\"/\\"/g' $(srcdir)/nlopt_optimize.m | sed 's,^% ,\",;s,^%,\",;s,$$,\\n\" \\,' >> $@ - echo "" >> $@ - -####################################################################### -mexdir = $(MEX_INSTALL_DIR) -if WITH_MATLAB -mex_DATA = nlopt_optimize.$(MEXSUFF) $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m -endif - -nlopt_optimize.$(MEXSUFF): nlopt_optimize-mex.c $(top_builddir)/.libs/libnlopt@NLOPT_SUFFIX@.la - $(MEX) -output nlopt_optimize -O $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(srcdir)/nlopt_optimize-mex.c $(LDFLAGS) -L$(top_builddir)/.libs -lnlopt@NLOPT_SUFFIX@ - -####################################################################### - -EXTRA_DIST = nlopt_optimize-oct.cc nlopt_optimize-mex.c $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m nlopt_optimize_usage.h - -CLEANFILES = nlopt_optimize.oct nlopt_optimize.h nlopt_optimize.$(MEXSUFF) nlopt_optimize-oct.o diff --git a/praxis/Makefile.am b/praxis/Makefile.am deleted file mode 100644 index c6c1e214..00000000 --- a/praxis/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libpraxis.la -libpraxis_la_SOURCES = praxis.c praxis.h - -EXTRA_DIST = README diff --git a/slsqp/Makefile.am b/slsqp/Makefile.am deleted file mode 100644 index ff7e8131..00000000 --- a/slsqp/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libslsqp.la -libslsqp_la_SOURCES = slsqp.c slsqp.h - -EXTRA_DIST = README COPYRIGHT diff --git a/stogo/Makefile.am b/stogo/Makefile.am deleted file mode 100644 index 3defc18e..00000000 --- a/stogo/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libstogo.la -libstogo_la_SOURCES = global.cc linalg.cc local.cc stogo.cc tools.cc \ -global.h linalg.h local.h stogo_config.h stogo.h tools.h - -EXTRA_DIST = testros.cc tst.cc tstc.c prog.cc testfun.h rosen.h README \ -paper.pdf techreport.pdf COPYRIGHT diff --git a/subplex/Makefile.am b/subplex/Makefile.am deleted file mode 100644 index bae7d9c8..00000000 --- a/subplex/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/util - -noinst_LTLIBRARIES = libsubplex.la -libsubplex_la_SOURCES = subplex.c subplex.h - -EXTRA_DIST = README diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index d2fa84d5..6eb98737 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -1,21 +1,23 @@ -option (BUILD_PYTHON "build python bindings" ON) -find_package (PythonInterp) -find_package (PythonLibs) - -if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-python.cpp) - find_package (SWIG) +if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-enum-renames.i) + file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/nlopt-enum-renames.i "// AUTOMATICALLY GENERATED -- DO NOT EDIT\n") + file (STRINGS ${CMAKE_SOURCE_DIR}/api/nlopt.h NLOPT_H_LINES REGEX " NLOPT_[A-Z0-9_]+") + foreach (NLOPT_H_LINE ${NLOPT_H_LINES}) + string (REGEX REPLACE ".*NLOPT_([A-Z0-9_]+).*" "%rename(NLOPT_\\1) nlopt::\\1;\n" ENUM_LINE ${NLOPT_H_LINE}) + file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/nlopt-enum-renames.i "${ENUM_LINE}") + endforeach () endif () -if (BUILD_PYTHON AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND (SWIG_FOUND OR (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-python.cpp)) AND BUILD_SHARED_LIBS) - include_directories (${CMAKE_SOURCE_DIR}/api) +if (NUMPY_FOUND AND PYTHONLIBS_FOUND AND (SWIG_FOUND OR (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-python.cpp))) + include_directories (${PYTHON_INCLUDE_DIRS}) + include_directories (${NUMPY_INCLUDE_DIRS}) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-python.cpp) set (SWIG_MODULE_nlopt_REAL_NAME _nlopt) add_library (${SWIG_MODULE_nlopt_REAL_NAME} MODULE nlopt-python.cpp) - target_link_libraries(${SWIG_MODULE_nlopt_REAL_NAME} nlopt) + target_link_libraries(${SWIG_MODULE_nlopt_REAL_NAME} ${nlopt_lib}) target_link_libraries(${SWIG_MODULE_nlopt_REAL_NAME} ${PYTHON_LIBRARIES}) set_target_properties (${SWIG_MODULE_nlopt_REAL_NAME} PROPERTIES PREFIX "") if (NOT CMAKE_SOURCE_DIR MATCHES CMAKE_BINARY_DIR) @@ -24,21 +26,48 @@ if (BUILD_PYTHON AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND (SWIG_FOUND OR else () include (UseSWIG) set_source_files_properties (nlopt.i PROPERTIES CPLUSPLUS ON) - set (SWIG_MODULE_nlopt_EXTRA_DEPS nlopt-python.i numpy.i ${CMAKE_SOURCE_DIR}/api/nlopt.hpp) + set (SWIG_MODULE_nlopt_EXTRA_DEPS nlopt-python.i numpy.i) swig_add_module (nlopt python nlopt.i) - swig_link_libraries (nlopt nlopt) + swig_link_libraries (nlopt ${nlopt_lib}) swig_link_libraries (nlopt ${PYTHON_LIBRARIES}) endif () - execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE ) - - get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) - file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) - - set (PYTHON_MODULE_PATH ${_REL_PYTHON_MODULE_PATH}) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.py DESTINATION ${PYTHON_MODULE_PATH} ) install ( TARGETS ${SWIG_MODULE_nlopt_REAL_NAME} LIBRARY DESTINATION ${PYTHON_MODULE_PATH} ) endif () + + +# guile bindings with gcc only ok with swig >= 2.0.10 +if (GUILE_FOUND AND ((SWIG_FOUND AND SWIG_VERSION VERSION_GREATER 2.0.9) OR (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-guile.cpp))) + include_directories (${GUILE_INCLUDE_DIRS}) + + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-guile.cpp) + set (guile_cpp_source ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-guile.cpp) + else () + file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/GenericConfigureFile.cmake "configure_file (\${INFILE} \${OUTFILE} @ONLY)") + + set (guile_cpp_source ${CMAKE_CURRENT_BINARY_DIR}/nlopt-guile.cpp) + add_custom_command (OUTPUT ${guile_cpp_source} nlopt.scm.in + COMMAND ${SWIG_EXECUTABLE} -I${CMAKE_BINARY_DIR}/api -outdir ${CMAKE_CURRENT_BINARY_DIR} -c++ -guile -scmstub -o ${guile_cpp_source} ${CMAKE_CURRENT_SOURCE_DIR}/nlopt.i + COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/nlopt.scm ${CMAKE_CURRENT_BINARY_DIR}/nlopt.scm.in + COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_CURRENT_BINARY_DIR}/nlopt.scm.in -DOUTFILE=${CMAKE_CURRENT_BINARY_DIR}/nlopt.scm -DNLOPT_SUFFIX=${NLOPT_SUFFIX} -P ${CMAKE_CURRENT_BINARY_DIR}/GenericConfigureFile.cmake) + endif () + + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt.scm.in) + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/nlopt.scm.in ${CMAKE_CURRENT_BINARY_DIR}/nlopt.scm @ONLY) + endif () + + set (SWIG_MODULE_nlopt_guile_REAL_NAME nlopt_guile) + add_library (${SWIG_MODULE_nlopt_guile_REAL_NAME} MODULE ${guile_cpp_source}) + target_link_libraries(${SWIG_MODULE_nlopt_guile_REAL_NAME} ${nlopt_lib}) + target_link_libraries(${SWIG_MODULE_nlopt_guile_REAL_NAME} ${GUILE_LIBRARIES}) + + file (RELATIVE_PATH _REL_GUILE_SITE_PATH ${GUILE_ROOT_DIR} ${GUILE_SITE_DIR}) + set (GUILE_SITE_PATH ${_REL_GUILE_SITE_PATH}) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.scm DESTINATION ${GUILE_SITE_PATH}) + + file (RELATIVE_PATH _REL_GUILE_EXTENSION_PATH ${GUILE_ROOT_DIR} ${GUILE_EXTENSION_DIR}) + set (GUILE_EXTENSION_PATH ${_REL_GUILE_EXTENSION_PATH}) + install (TARGETS ${SWIG_MODULE_nlopt_guile_REAL_NAME} LIBRARY DESTINATION ${GUILE_EXTENSION_PATH}) +endif () diff --git a/swig/Makefile.am b/swig/Makefile.am deleted file mode 100644 index cbba1648..00000000 --- a/swig/Makefile.am +++ /dev/null @@ -1,59 +0,0 @@ -SWIG_SRC = nlopt.i nlopt-exceptions.i nlopt-enum-renames.i -EXTRA_DIST = $(SWIG_SRC) nlopt-guile.i nlopt-python.i nlopt.scm.in nlopt.py numpy.i - -BUILT_SOURCES = nlopt-guile.cpp nlopt-python.cpp nlopt-enum-renames.i nlopt.scm.in - -HDR = $(top_srcdir)/api/nlopt.hpp - -############################################################################## -# Guile wrapper - -libnlopt@NLOPT_SUFFIX@_guile_la_SOURCES = nlopt-guile.cpp -libnlopt@NLOPT_SUFFIX@_guile_la_LIBADD = ../libnlopt@NLOPT_SUFFIX@.la @GUILE_LIBS@ -libnlopt@NLOPT_SUFFIX@_guile_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ -libnlopt@NLOPT_SUFFIX@_guile_la_CPPFLAGS = $(GUILE_CPPFLAGS) -I$(top_srcdir)/api - -guiledir = $(GUILE_INSTALL_DIR) -if WITH_GUILE -guile_DATA = nlopt.scm -guilelib = libnlopt@NLOPT_SUFFIX@_guile.la -endif - -############################################################################## -# Python wrapper - -_nlopt_la_SOURCES = nlopt-python.cpp -_nlopt_la_LIBADD = ../libnlopt@NLOPT_SUFFIX@.la @PYTHON_LIBS@ -_nlopt_la_LDFLAGS = -module -version-info @SHARED_VERSION_INFO@ -_nlopt_la_CPPFLAGS = $(PYTHON_INCLUDES) -I$(top_srcdir)/api -if WITH_PYTHON -python_PYTHON = nlopt.py -pyexec_LTLIBRARIES = _nlopt.la -endif - -############################################################################## - - -lib_LTLIBRARIES = $(guilelib) - -############################################################################## -# Generate wrappers via SWIG: - -if MAINTAINER_MODE - -nlopt-guile.cpp: $(SWIG_SRC) nlopt-guile.i $(HDR) - swig -I$(top_srcdir)/api -outdir $(builddir) -c++ -guile -scmstub -o $@ $(srcdir)/nlopt.i - rm -f nlopt.scm.in - mv nlopt.scm nlopt.scm.in - -nlopt.scm.in: nlopt-guile.cpp - -nlopt-python.cpp: $(SWIG_SRC) nlopt-python.i numpy.i $(HDR) - swig -I$(top_srcdir)/api -outdir $(builddir) -c++ -python -o $@ $(srcdir)/nlopt.i - -nlopt.py: nlopt-python.cpp - -nlopt-enum-renames.i: $(top_srcdir)/api/nlopt.h - (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(top_srcdir)/api/nlopt.h | sed 's/NLOPT_//g' |tr -d ' ' |tr '/' ',' |tr '=' ',' |cut -d, -f1 |while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done; egrep 'NLOPT_[A-Z_]* =' $(top_srcdir)/api/nlopt.h | egrep -v 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' | sed 's/NLOPT_//g' |tr -d ' ' |cut -d'=' -f1 | while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done) > $@ - -endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..4b5ae239 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,33 @@ +add_custom_target (tests) + +# have to add timer.c and mt19937ar.c as symbols are declared extern +add_executable (testopt EXCLUDE_FROM_ALL testfuncs.c testfuncs.h testopt.cpp ${CMAKE_SOURCE_DIR}/util/timer.c ${CMAKE_SOURCE_DIR}/util/mt19937ar.c) +target_link_libraries (testopt ${nlopt_lib}) +add_dependencies (tests testopt) + +foreach (algo_index RANGE 29)# 42 + foreach (obj_index RANGE 1)# 21 + set (enable_ TRUE) + # cxx stogo + if (NOT WITH_CXX) + if (algo_index STREQUAL 8 OR algo_index STREQUAL 9) + set (enable_ FALSE) + endif () + endif () + # L-BFGS + if (algo_index STREQUAL 10) + set (enable_ FALSE) + endif () + if (enable_) + add_test (NAME testopt_algo${algo_index}_obj${obj_index} COMMAND testopt -a ${algo_index} -o ${obj_index}) + endif () + endforeach () +endforeach () + +if (NUMPY_FOUND AND PYTHONLIBS_FOUND AND (SWIG_FOUND OR (EXISTS ${CMAKE_SOURCE_DIR}/swig/nlopt-python.cpp))) + set (PYINSTALLCHECK_ENVIRONMENT "LD_LIBRARY_PATH=${INSTALL_DESTDIR}${INSTALL_LIB_DIR}:$ENV{LD_LIBRARY_PATH}" + "PYTHONPATH=${INSTALL_DESTDIR}${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}${PATH_SEP}$ENV{PYTHONPATH}" + ) + add_test (NAME test_std_python COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_std.py) + set_tests_properties (test_std_python PROPERTIES ENVIRONMENT "${PYINSTALLCHECK_ENVIRONMENT}") +endif () diff --git a/test/Makefile.am b/test/Makefile.am deleted file mode 100644 index f0b3f471..00000000 --- a/test/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/util - -noinst_PROGRAMS = testopt - -testopt_SOURCES = testfuncs.c testfuncs.h testopt.cpp -testopt_LDADD = $(top_builddir)/libnlopt@NLOPT_SUFFIX@.la -EXTRA_DIST = test_std.py - diff --git a/test/testopt.cpp b/test/testopt.cpp index 2400ebee..cfef0e03 100644 --- a/test/testopt.cpp +++ b/test/testopt.cpp @@ -32,6 +32,76 @@ #endif #ifdef HAVE_GETOPT_H # include +#else +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* +* getopt -- +* Parse argc/argv argument vector. +*/ +int + getopt(int nargc, char * const nargv[], const char *ostr) +{ + static char *place = EMSG; /* option letter processing */ + const char *oli; /* option letter list index */ + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-') { /* found "--" */ + ++optind; + place = EMSG; + return (-1); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)printf("illegal option -- %c\n", optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)printf("option requires an argument -- %c\n", optopt); + return (BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} #endif #define USE_FEENABLEEXCEPT 0 diff --git a/util/Makefile.am b/util/Makefile.am deleted file mode 100644 index ca4dff9a..00000000 --- a/util/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/api - -noinst_LTLIBRARIES = libutil.la -libutil_la_SOURCES = mt19937ar.c sobolseq.c soboldata.h timer.c stop.c nlopt-util.h redblack.c redblack.h qsort_r.c rescale.c - -noinst_PROGRAMS = redblack_test -redblack_test_SOURCES = redblack_test.c -redblack_test_LDADD = libutil.la diff --git a/util/timer.c b/util/timer.c index 8019d982..7eb7f291 100644 --- a/util/timer.c +++ b/util/timer.c @@ -22,11 +22,11 @@ #include "nlopt-util.h" -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME # include # include #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include # else # include