summaryrefslogtreecommitdiff
blob: 3f50341da805ba37b1ef5e794f5010b7d4b47ac8 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/iasl/iasl-20111123.ebuild,v 1.1 2011/12/11 19:05:42 robbat2 Exp $

EAPI=4

inherit toolchain-funcs flag-o-matic eutils

MY_PN=acpica-unix
MY_P=${MY_PN}-${PV}
MY_TESTS_P=${MY_PN/ca/tests}-${PV}
DESCRIPTION="Intel ACPI Source Language (ASL) compiler"
HOMEPAGE="http://www.intel.com/technology/iapc/acpi/"
SRC_URI="http://www.acpica.org/download/${MY_P}.tar.gz
	test? ( http://www.acpica.org/download/${MY_TESTS_P}.tar.gz )"

LICENSE="iASL"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86 ~x86-fbsd"
IUSE="test"

DEPEND="sys-devel/bison
	sys-devel/flex"
RDEPEND=""

S=${WORKDIR}/${MY_P}

pkg_setup() {
	if use test
	then
		ewarn 'You have selected USE="test". This will install the test results'
		ewarn "into /usr/share/${PF}/, compressed as a tarball."
		ewarn 'The tests themselves will only rarely die, but the test results'
		ewarn 'are interesting for arch testing. The tests may take quite some'
		ewarn 'time to complete.'
	fi
}

src_prepare() {
	epatch "${FILESDIR}/${PN}-20110922-as-needed.patch"
	epatch "${FILESDIR}/${PN}-20110922-locale.patch"
	epatch "${FILESDIR}/${PN}-20110922-parallelmake-001.patch"
	epatch "${FILESDIR}/${PN}-20110922-parallelmake-002.patch"
	epatch "${FILESDIR}/${PN}-20110922-parallelmake-003.patch"

	find "${S}" -type f -name 'Makefile*' -print0 | \
		xargs -0 -I '{}' \
		sed -r -e 's:-\<Werror\>::g' -i '{}' \
		|| die
}

src_configure() {
	:
}

src_compile() {
	local target bin

	for target in compiler tools/acpi{bin,exec,help,names,src,xtract}
	do
		einfo "Compiling in ${target}/"
		cd "${S}"/${target}
		case "${target}" in
			compiler) bin=iasl;;
			*) bin=${target#*/};;
		esac

		emake CC="$(tc-getCC)" || die "emake in ${target} failed"
		einfo "Finished compiling ${target}"

		mv ${bin} "${T}" || die "mv ${bin} failed"
		einfo "Finished moving ${bin}"

		make clean || die "make clean in ${target} failed"
		einfo "Finished cleaning ${target}"

		echo ${bin} >>"${T}"/binlist
	done
	einfo "$(<"${T}"/binlist)"
}

src_test() {
	aslts_test
	#aapits_test
	#The aapits test currently fails, missing include probably.
}

src_install() {
	local bin
	for bin in $(<"${T}"/binlist) ; do
		dobin "${T}"/${bin}
	done
	dodoc README changes.txt
	if use test ; then
		tb="${T}"/testresults.tar.bz2
		export ASLTSDIR="$(<"${T}"/asltdir)"
		ebegin "Creating Test Tarball"
		tar -cjf "${tb}" -C "${ASLTSDIR}"/tmp/RESULTS .  || die "tar failed"
		eend $?
		dodir /usr/share/${PF}
		insinto /usr/share/${PF}
		doins ${tb} || die "doins testresults.tar.bz2 failed"
	fi

}

aslts_test() {
	export	ASL="${T}"/iasl \
		acpiexec="${T}"/acpiexec \
		ASLTSDIR="${WORKDIR}/${MY_TESTS_P}"/tests/aslts
	export	PATH="${PATH}:${ASLTSDIR}/bin"
	echo "$ASLTSDIR" >"${T}"/asltdir
	cd "${ASLTSDIR}"
	edos2unix $(find . -type 'f')
	make install || die "make install aslts test failed"
	chmod +x $(find bin/ ! -regex 'ERROR_OPCODES|HOW_TO_USE|README' ) || die "chmod bin +x failed"

	#The below Do commands runs the tests twice and then dies if the results aren't
	#Identical.
	Do 1 || die "failed Do 1"
	Do 2 || die "failed Do 2"
}

aapits_test() {
	mv "${WORKDIR}/${MY_TESTS_P}/tests/aapits" "${S}/tools/" || die "mv failed"
	cd "${S}/tools/aapits" || die "cannot find ${S}/tools/aapits"
	edos2unix $(find . -type 'f')
	chmod +x $(find bin/ | sed  -r -e '/\/[A-Z_]+$/d') || die "chmod bin +x failed"
	make || die "make in aapits failed"
	cd asl || die "cd asl failed"
	make || die "make in asl failed"
	cd ../bin
	./aapitsrun || die "aapitsrun failed"
}