summaryrefslogtreecommitdiff
blob: 46b0736f53745e01105aa4db8c5eeb7c6ec31972 (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
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI="2"

inherit eutils toolchain-funcs

MY_P="${PN}2-070721"

DESCRIPTION="Small yet efficient SAT solver with reference paper"
HOMEPAGE="http://minisat.se/Main.html"
SRC_URI="http://minisat.se/downloads/${MY_P}.zip
	doc? ( http://minisat.se/downloads/MiniSat.pdf )"

SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
LICENSE="MIT"

IUSE="debug doc extended-solver"

DEPEND="sys-libs/zlib"
RDEPEND="${DEPEND}"

S=${WORKDIR}/${PN}

pkg_setup() {
	if use debug; then
		myconf="d"
		myext="debug"
	else
		myconf="r"
		myext="release"
	fi

	if use extended-solver; then
		mydir="simp"
	else
		mydir="core"
	fi

	tc-export CXX

	if has_version ">=sci-mathematics/minisat-2.2.0" ; then
		elog ""
		elog "The minisat2 2.1 and 2.2 ABIs are not compatible and there"
		elog "is currently no slotting.  Please mask it yourself (eg, in"
		elog "packages.mask) if you need to use the 2.1x version."
		elog ""
		epause 5
	fi
}

src_prepare() {
	sed -i \
		-e "s|-O3|${CFLAGS} ${LDFLAGS}|" \
		-e "s|@\$(CXX)|\$(CXX)|" \
		mtl/template.mk || die
}

src_compile() {
	export MROOT="${S}"
	emake -C ${mydir} "$myconf" || die

	if ! use debug; then
		LIB="${PN}" emake -C ${mydir} lib || die
	else
		LIB="${PN}" emake -C ${mydir} libd || die
	fi
}

src_install() {
	# somewhat brute-force, but so is the build setup...

	insinto /usr/include/${PN}2/mtl
	doins mtl/*.h || die

	insinto /usr/include/${PN}2/core
	doins core/Solver*.h || die

	insinto /usr/include/${PN}2/simp
	doins simp/Simp*.h || die

	if ! use debug; then
		newbin ${mydir}/${PN}_${myext} ${PN} || die
		dolib.a ${mydir}/lib${PN}.a || die
	else
		newbin ${mydir}/${PN}_${myext} ${PN} || die
		newlib.a ${mydir}/lib${PN}_${myext}.a lib${PN}.a || die
	fi

	dodoc README || die
	if use doc; then
		dodoc "${DISTDIR}"/MiniSat.pdf || die
	fi
}