commit:     01f1676c357e17cfde5abb0ccca96766e69bbe6f
Author:     Alfred Wingate <parona <AT> protonmail <DOT> com>
AuthorDate: Tue Aug 27 15:11:51 2024 +0000
Commit:     Arsen Arsenović <arsen <AT> gentoo <DOT> org>
CommitDate: Wed Sep 18 13:06:41 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=01f1676c

sci-libs/nlopt: switch to new guile mechanism

Signed-off-by: Alfred Wingate <parona <AT> protonmail.com>
Signed-off-by: Arsen Arsenović <arsen <AT> gentoo.org>

 profiles/package.mask                  |   1 +
 sci-libs/nlopt/nlopt-2.7.1-r100.ebuild | 115 +++++++++++++++++++++++++++++++++
 2 files changed, 116 insertions(+)

diff --git a/profiles/package.mask b/profiles/package.mask
index e96b57254b33..c7ffd7860231 100644
--- a/profiles/package.mask
+++ b/profiles/package.mask
@@ -392,6 +392,7 @@ dev-scheme/guile:3.0
 >=sci-electronics/geda-1.10.2-r100
 >=sci-electronics/gwave-20190116-r100
 >=sci-libs/linux-gpib-4.3.6-r100
+>=sci-libs/nlopt-2.7.1-r100
 
 # Eli Schwartz <[email protected]> (2024-08-15)
 # Abandoned upstream since 2011, unmaintained in gentoo since 2017. Tons of

diff --git a/sci-libs/nlopt/nlopt-2.7.1-r100.ebuild 
b/sci-libs/nlopt/nlopt-2.7.1-r100.ebuild
new file mode 100644
index 000000000000..55bc5573894b
--- /dev/null
+++ b/sci-libs/nlopt/nlopt-2.7.1-r100.ebuild
@@ -0,0 +1,115 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+GUILE_COMPAT=( 2-2 3-0 )
+PYTHON_COMPAT=( python3_{10..12} )
+FORTRAN_NEEDED="test"
+
+inherit python-r1 cmake guile-single fortran-2
+
+DESCRIPTION="Non-linear optimization library"
+HOMEPAGE="https://github.com/stevengj/nlopt";
+SRC_URI="https://github.com/stevengj/nlopt/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="LGPL-2.1 MIT"
+KEYWORDS="~amd64 ~arm64 ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
+SLOT="0"
+IUSE="cxx guile octave python test"
+REQUIRED_USE="guile? ( ${GUILE_REQUIRED_USE} ) python? ( 
${PYTHON_REQUIRED_USE} )"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+       guile? ( ${GUILE_DEPS} )
+       octave? ( >=sci-mathematics/octave-6:= )
+       python? (
+               ${PYTHON_DEPS}
+               dev-python/numpy[${PYTHON_USEDEP}]
+       )
+       "
+DEPEND="${RDEPEND}"
+BDEPEND="python? ( dev-lang/swig )"
+
+src_prepare() {
+       cmake_src_prepare
+
+       use guile && guile_bump_sources
+       use python && python_copy_sources
+}
+
+src_configure() {
+       # MATLAB detection causes problems (as in bug 826774) if we don't
+       # explicitly disable it.
+       local mycmakeargs=(
+               -DNLOPT_CXX=$(usex cxx)
+               -DNLOPT_FORTRAN=$(usex test)
+               -DNLOPT_GUILE=$(usex guile)
+               -DNLOPT_OCTAVE=$(usex octave)
+               -DNLOPT_MATLAB=OFF
+               -DNLOPT_PYTHON=OFF
+               -DNLOPT_SWIG=$(usex python)
+               -DNLOPT_TESTS=$(usex test)
+       )
+
+       cmake_src_configure
+
+       if use python; then
+               python_configure() {
+                       local mycmakeargs=(
+                               ${mycmakeargs[@]}
+                               -DNLOPT_PYTHON=ON
+                               -DINSTALL_PYTHON_DIR="$(python_get_sitedir)"
+                       )
+
+                       cmake_src_configure
+               }
+
+               python_foreach_impl run_in_build_dir python_configure
+       fi
+}
+
+src_compile() {
+       cmake_src_compile
+
+       if use python; then
+               python_foreach_impl run_in_build_dir cmake_src_compile
+       fi
+}
+
+src_test() {
+       do_test() {
+               local a f
+               cd "${BUILD_DIR}"/test
+               for a in {1..$(usex cxx 9 7)}; do
+                       for f in {5..9}; do
+                               ./testopt -a $a -o $f || die "algorithm $a 
function $f failed"
+                       done
+               done
+       }
+
+       do_test
+
+       if use python; then
+               python_foreach_impl run_in_build_dir do_test
+       fi
+}
+
+nlopt_install() {
+       cmake_src_install
+       python_optimize
+}
+
+src_install() {
+       cmake_src_install
+
+       guile_unstrip_ccache
+       if use python; then
+               python_foreach_impl run_in_build_dir nlopt_install
+       fi
+
+       local r
+       for r in */README; do
+               newdoc ${r} README.$(dirname ${r})
+       done
+}

Reply via email to