|
| 1 | +# Copyright 1999-2020 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=7 |
| 5 | + |
| 6 | +inherit eutils toolchain-funcs |
| 7 | + |
| 8 | +MY_PN=acpica-unix |
| 9 | +MY_P="${MY_PN}-${PV}" |
| 10 | +MY_TESTS_P="${MY_PN/ca/tests}-${PV}" |
| 11 | + |
| 12 | +DESCRIPTION="Intel ACPI Source Language (ASL) compiler" |
| 13 | +HOMEPAGE="https://www.acpica.org/downloads/" |
| 14 | +SRC_URI=" |
| 15 | + http://www.acpica.org/sites/acpica/files/${MY_P}.tar.gz |
| 16 | + test? ( http://www.acpica.org/sites/acpica/files/${MY_TESTS_P}.tar.gz )" |
| 17 | + |
| 18 | +LICENSE="iASL" |
| 19 | +SLOT="0" |
| 20 | +KEYWORDS="~amd64 ~arm64 ~ppc ~x86" |
| 21 | +IUSE="test" |
| 22 | +RESTRICT="!test? ( test )" |
| 23 | + |
| 24 | +BDEPEND=" |
| 25 | + sys-devel/bison |
| 26 | + sys-devel/flex" |
| 27 | + |
| 28 | +S="${WORKDIR}/${MY_P}" |
| 29 | + |
| 30 | +PATCHES=( "${FILESDIR}"/${PN}-20200326-Makefile.patch ) |
| 31 | + |
| 32 | +pkg_setup() { |
| 33 | + if use test && has test ${FEATURES}; then |
| 34 | + ewarn 'You have selected USE="test". This will install the test results' |
| 35 | + ewarn "into /usr/share/${PF}/, compressed as a tarball." |
| 36 | + ewarn 'The tests themselves will only rarely die, but the test results' |
| 37 | + ewarn 'are interesting for arch testing. The tests may take quite some' |
| 38 | + ewarn 'time to complete.' |
| 39 | + fi |
| 40 | +} |
| 41 | + |
| 42 | +src_prepare() { |
| 43 | + default |
| 44 | + |
| 45 | + find "${S}" -type f -name 'Makefile*' -print0 | \ |
| 46 | + xargs -0 -I '{}' \ |
| 47 | + sed -r -e 's:-\<Werror\>::g' -e "s:/usr:${EPREFIX}/usr:g" \ |
| 48 | + -i '{}' \ |
| 49 | + || die |
| 50 | +} |
| 51 | + |
| 52 | +src_configure() { |
| 53 | + tc-export CC |
| 54 | + |
| 55 | + # BITS is tied to ARCH - please set appropriately if you add new keywords |
| 56 | + if [[ $ARCH == @(amd64|amd64-fbsd) ]] ; then |
| 57 | + export BITS=64 |
| 58 | + else |
| 59 | + export BITS=32 |
| 60 | + fi |
| 61 | +} |
| 62 | + |
| 63 | +src_compile() { |
| 64 | + emake -C generate/unix BITS="${BITS}" |
| 65 | +} |
| 66 | + |
| 67 | +src_test() { |
| 68 | + aslts_test |
| 69 | + #The aapits test currently fails, missing include probably. |
| 70 | + #aapits_test |
| 71 | +} |
| 72 | + |
| 73 | +src_install() { |
| 74 | + cd generate/unix || die |
| 75 | + emake install DESTDIR="${D}" BITS=${BITS} |
| 76 | + default |
| 77 | + #local bin |
| 78 | + #for bin in $(<"${T}"/binlist) ; do |
| 79 | + # dobin "${T}"/${bin} |
| 80 | + #done |
| 81 | + dodoc "${S}"/changes.txt |
| 82 | + newdoc "${S}"/source/compiler/readme.txt compiler-readme.txt |
| 83 | + newdoc "${S}"/generate/unix/readme.txt unix-readme.txt |
| 84 | + newdoc "${S}"/generate/lint/readme.txt lint-readme.txt |
| 85 | + newdoc "${S}"/source/compiler/new_table.txt compiler-new_table.txt |
| 86 | + |
| 87 | + if use test && has test ${FEATURES}; then |
| 88 | + tb="${T}"/testresults.tar.bz2 |
| 89 | + export ASLTSDIR="$(<"${T}"/asltdir)" |
| 90 | + ebegin "Creating Test Tarball" |
| 91 | + tar -cjf "${tb}" -C "${ASLTSDIR}"/tmp/RESULTS . || die "tar failed" |
| 92 | + eend $? |
| 93 | + insinto /usr/share/${PF} |
| 94 | + doins ${tb} |
| 95 | + fi |
| 96 | +} |
| 97 | + |
| 98 | +aslts_test() { |
| 99 | + export ASL="${S}"/generate/unix/bin/iasl \ |
| 100 | + acpibin="${S}"/generate/unix/bin/acpibin \ |
| 101 | + acpiexec="${S}"/generate/unix/bin/acpiexec \ |
| 102 | + ASLTSDIR="${WORKDIR}/${MY_TESTS_P}"/tests/aslts |
| 103 | + export PATH="${PATH}:${ASLTSDIR}/bin" |
| 104 | + echo "$ASLTSDIR" >"${T}"/asltdir |
| 105 | + cd "${ASLTSDIR}" || die |
| 106 | + edos2unix $(find . -type 'f') |
| 107 | + make install || die "make install aslts test failed" |
| 108 | + chmod +x $(find bin/ ! -regex 'ERROR_OPCODES|HOW_TO_USE|README' ) || die "chmod bin +x failed" |
| 109 | + |
| 110 | + #The below Do commands runs the tests twice and then dies if the results aren't |
| 111 | + #Identical. |
| 112 | + Do 1 || die "failed Do 1" |
| 113 | + Do 2 || die "failed Do 2" |
| 114 | +} |
| 115 | + |
| 116 | +aapits_test() { |
| 117 | + mv "${WORKDIR}/${MY_TESTS_P}/tests/aapits" "${S}/tools/" || die "mv failed" |
| 118 | + cd "${S}/tools/aapits" || die "cannot find ${S}/tools/aapits" |
| 119 | + edos2unix $(find . -type 'f') |
| 120 | + chmod +x $(find bin/ | sed -r -e '/\/[A-Z_]+$/d') || die "chmod bin +x failed" |
| 121 | + make || die "make in aapits failed" |
| 122 | + cd asl || die "cd asl failed" |
| 123 | + make || die "make in asl failed" |
| 124 | + cd ../bin || die |
| 125 | + ./aapitsrun || die "aapitsrun failed" |
| 126 | +} |
0 commit comments