blob: 538051367347678cedc183d145a0447ffc64d24c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{9..10} )
FORTRAN_NEEDED="test"
inherit python-r1 cmake 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 x86 ~amd64-linux ~x86-linux"
SLOT="0"
IUSE="cxx guile octave python test"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
RESTRICT="!test? ( test )"
RDEPEND="
guile? ( dev-scheme/guile:* )
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 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
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
}
|