aboutsummaryrefslogtreecommitdiff
blob: 5cd59202ba92f1148aba5119bed83eacf64f7722 (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
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit flag-o-matic toolchain-funcs

DESCRIPTION="Multi Criteria CUDF Solver"
HOMEPAGE="https://www.i3s.unice.fr/~cpjm/misc/mccs.html"
SRC_URI="
	https://www.i3s.unice.fr/~cpjm/misc/${P}-srcs.tgz
	http://deb.debian.org/debian/pool/main/m/mccs/${PN}_${PV}-9.debian.tar.xz
"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64"
IUSE="glpk lpsolve"

DEPEND="
	glpk? ( sci-mathematics/glpk )
	lpsolve? ( sci-mathematics/lpsolve )
"
RDEPEND="
	${DEPEND}
	sci-libs/coinor-cbc
"

BDEPEND="
	dev-util/quilt
	sys-devel/bison
	app-alternatives/yacc
"

src_prepare() {
	export QUILT_PATCHES="${WORKDIR}/debian/patches"
	export QUILT_SERIES="${QUILT_PATCHES}/series"
	quilt push -a || die
	eapply "${FILESDIR}/${P}-respect-flags.patch"
	eapply "${FILESDIR}/${P}-glpk.patch"
	eapply "${FILESDIR}/${P}-fix-Wl.patch"
	eapply "${FILESDIR}/${P}-respect-AR.patch"
	eapply_user

	if use glpk; then
		sed \
			-e "s|#USEGLPK=1|USEGLPK=1|g" \
			-e "s|GLPKDIR=/usr/lib|GLPKDIR=/usr/$(get_libdir)|g" \
			-i make.local || die
	fi
	if use lpsolve; then
		sed -e "s|LPSOLVEDIR=/usr/lib|LPSOLVEDIR=/usr/$(get_libdir)|g" -i make.local || die
	else
		sed -e "s|USELPSOLVE=1|#USELPSOLVE=1|g" -i make.local || die
	fi
}

src_compile() {
	tc-export AR CXX
	append-cxxflags "-std=c++14"
	MAKEOPTS="-j1" emake libccudf.so
	MAKEOPTS="-j1" emake mccs
}

src_install() {
	dodoc README CHANGES
	dodoc -r examples

	insinto /usr/share/cudf/solvers
	doins "${FILESDIR}/mccs-cbc"
	use lpsolve && doins "${FILESDIR}/mccs-lpsolve"

	dobin sciplp cbclp wbopb mccs
	exeinto "/usr/libexec/${PN}"
	doexe solve{paranoid,trendy}
	dolib.so libccudf.so
}