sci-libs/nlopt: Add patch for octave-4.0.0

Gentoo-Bug: 569996
In addition, add patch for underlinking and fix when
building with USE="-octave".

Package-Manager: portage-2.2.26
This commit is contained in:
David Seifert
2016-01-16 15:50:35 +01:00
parent 7329034a0e
commit ba9ea4fa92
3 changed files with 223 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
Fix underlinking issues, caused by missing -lpython27 and -lpthread
--- nlopt-2.4.2/configure.ac
+++ nlopt-2.4.2/configure.ac
@@ -161,33 +161,17 @@
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"
- 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
+ PKG_CHECK_MODULES([PYTHON], [python-2.7])
+ CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
+
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"
+ test -n "$pinc" && PYTHON_INCLUDES="$PYTHON_CFLAGS -I$pinc"
CPPFLAGS="$save_CPPFLAGS $PYTHON_INCLUDES"
AC_CHECK_HEADER([numpy/arrayobject.h],[],[
AC_MSG_WARN([disabling Python wrappers])
have_python=no],[#include <Python.h>])
- fi
- CPPFLAGS=$save_CPPFLAGS
fi
fi # with_python
--- nlopt-2.4.2/swig/Makefile.am
+++ nlopt-2.4.2/swig/Makefile.am
@@ -9,7 +9,7 @@
# 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_LIBADD = -lpthread ../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
@@ -23,7 +23,7 @@
# Python wrapper
_nlopt_la_SOURCES = nlopt-python.cpp
-_nlopt_la_LIBADD = ../libnlopt@NLOPT_SUFFIX@.la
+_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

View File

@@ -0,0 +1,49 @@
Fix issues caused by Octave-4 renaming Octave_map to octave_map
See also
https://bugs.gentoo.org/show_bug.cgi?id=569996
https://github.com/stevengj/nlopt/commit/5326ab410c978f9d8c3cae7e4917f55c10ef2c2e?diff=unified
--- nlopt-2.4.2_old/octave/nlopt_optimize-oct.cc 2014-05-20 20:35:58.000000000 +0200
+++ nlopt-2.4.2/octave/nlopt_optimize-oct.cc 2016-01-09 16:10:53.358491776 +0100
@@ -30,5 +30,5 @@
#include "nlopt_optimize_usage.h"
-static int struct_val_default(Octave_map &m, const std::string& k,
+static int struct_val_default(octave_map &m, const std::string& k,
int dflt)
{
@@ -40,5 +40,5 @@
}
-static double struct_val_default(Octave_map &m, const std::string& k,
+static double struct_val_default(octave_map &m, const std::string& k,
double dflt)
{
@@ -50,5 +50,5 @@
}
-static Matrix struct_val_default(Octave_map &m, const std::string& k,
+static Matrix struct_val_default(octave_map &m, const std::string& k,
Matrix &dflt)
{
@@ -141,5 +141,5 @@
#define CHECK1(cond, msg) if (!(cond)) { fprintf(stderr, msg "\n\n"); nlopt_destroy(opt); nlopt_destroy(local_opt); return NULL; }
-nlopt_opt make_opt(Octave_map &opts, int n)
+nlopt_opt make_opt(octave_map &opts, int n)
{
nlopt_opt opt = NULL, local_opt = NULL;
@@ -196,5 +196,5 @@
&& (opts.contents("local_optimizer"))(0).is_map(),
"opt.local_optimizer must be a structure");
- Octave_map local_opts = (opts.contents("local_optimizer"))(0).map_value();
+ octave_map local_opts = (opts.contents("local_optimizer"))(0).map_value();
CHECK1((local_opt = make_opt(local_opts, n)),
"error initializing local optimizer");
@@ -217,5 +217,5 @@
CHECK(args(0).is_map(), "opt must be structure")
- Octave_map opts = args(0).map_value();
+ octave_map opts = args(0).map_value();
CHECK(args(1).is_real_matrix() || args(1).is_real_scalar(),

View File

@@ -0,0 +1,112 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=5
PYTHON_COMPAT=( python2_7 )
AUTOTOOLS_AUTORECONF=1
inherit python-r1 autotools-utils
DESCRIPTION="Non-linear optimization library"
HOMEPAGE="http://ab-initio.mit.edu/nlopt/"
SRC_URI="${HOMEPAGE}/${P}.tar.gz"
LICENSE="LGPL-2.1 MIT"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
SLOT="0"
IUSE="cxx guile octave python static-libs"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
DEPEND="
guile? ( dev-scheme/guile:* )
octave? ( sci-mathematics/octave )
python? ( dev-python/numpy[${PYTHON_USEDEP}] )"
RDEPEND="${DEPEND}"
PATCHES=(
"${FILESDIR}"/${PN}-2.3-pkgconfig.patch
"${FILESDIR}"/${PN}-2.3-as-needed.patch
"${FILESDIR}"/${P}-fix-dynamic-underlinking.patch
)
src_prepare() {
# fix #569996 due to renaming of Octave_map class
has_version ">=sci-mathematics/octave-4.0" && \
epatch "${FILESDIR}/${P}-octave-4-map.patch"
autotools-utils_src_prepare
use cxx && BUILD_CXX="${S}_cxx"
use python && python_copy_sources
}
src_configure() {
local myeconfargs=(
$(use_with octave)
)
if use octave; then
export OCT_INSTALL_DIR="$(octave-config -p LOCALOCTFILEDIR)"
export M_INSTALL_DIR="$(octave-config -p LOCALFCNFILEDIR)"
else
export MKOCTFILE=None
fi
myeconfargs+=(
$(use_with guile)
)
if use python; then
python_foreach_impl run_in_build_dir autotools-utils_src_configure
else
autotools-utils_src_configure
fi
if use cxx; then
myeconfargs+=( --with-cxx --without-octave --without-python )
BUILD_DIR="${BUILD_CXX}" autotools-utils_src_configure
fi
}
src_compile() {
if use python; then
python_foreach_impl run_in_build_dir autotools-utils_src_compile
else
autotools-utils_src_compile
fi
use cxx && BUILD_DIR="${BUILD_CXX}" autotools-utils_src_compile
#-C "${BUILD_DIR}_cxx"
}
src_test() {
do_test() {
local a f
cd "${BUILD_DIR}"/test
for a in {1..7}; do
for f in {5..9}; do
./testopt -a $a -o $f || die "algorithm $a function $f failed"
done
done
}
if use python; then
python_foreach_impl run_in_build_dir do_test
else
do_test
fi
cd "${BUILD_CXX}"/test
for a in {1..9}; do
for f in {5..9}; do
./testopt -a $a -o $f || die "algorithm $a function $f failed"
done
done
}
src_install() {
# build cxx first so the c lib overwrites the pc file
use cxx && BUILD_DIR="${BUILD_CXX}" autotools-utils_src_install
if use python; then
python_foreach_impl run_in_build_dir autotools-utils_src_install
else
autotools-utils_src_install
fi
local r
for r in */README; do newdoc ${r} README.$(dirname ${r}); done
}