summaryrefslogtreecommitdiff
blob: c4d4fd91cc23e5ceb9b8321a5ea72b8cb038ce9e (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
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-libs/libaio/libaio-0.3.109-r4.ebuild,v 1.11 2013/03/11 07:37:47 ago Exp $

EAPI=5

inherit eutils multilib toolchain-funcs

DESCRIPTION="Asynchronous input/output library that uses the kernels native interface"
HOMEPAGE="http://www.kernel.org/pub/linux/kernel/people/andrea/libaio/ http://lse.sourceforge.net/io/aio.html"
SRC_URI="mirror://kernel/linux/libs/aio/${P}.tar.bz2"

LICENSE="LGPL-2"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 ~m68k ~mips ~ppc ppc64 s390 sh sparc x86 ~amd64-linux ~x86-linux"
IUSE="multilib static-libs test"

EMULTILIB_PKG="true"

S=${WORKDIR}

aio_get_install_abis() {
	use multilib && get_install_abis || echo ${ABI:-default}
}

src_unpack() {
	local OABI=${ABI}
	for ABI in $(aio_get_install_abis)
	do
		mkdir -p "${WORKDIR}"/${ABI} || die
		cd "${WORKDIR}"/${ABI} || die
		unpack ${A}
	done
	ABI=${OABI}
}

src_prepare() {
	local OABI=${ABI}
	for ABI in $(aio_get_install_abis)
	do
		einfo "Preparing ${ABI} ABI ..."
		cd "${WORKDIR}"/${ABI}/${P} || die

		# remove stuff provided by man-pages now
		rm man/{lio_listio,aio_{cancel,error,fsync,init,read,return,suspend,write}}.* || die

		epatch "${FILESDIR}"/${PN}-0.3.109-unify-bits-endian.patch \
			"${FILESDIR}"/${PN}-0.3.109-generic-arch.patch \
			"${FILESDIR}"/${PN}-0.3.106-build.patch \
			"${FILESDIR}"/${PN}-0.3.107-ar-ranlib.patch \
			"${FILESDIR}"/${PN}-0.3.109-install.patch \
			"${FILESDIR}"/${PN}-0.3.109-x32.patch \
			"${FILESDIR}"/${PN}-0.3.109-testcase-8.patch

		declare -a extra_sed
		if ! use static-libs; then
			extra_sed[${#extra_sed[@]}]='-e'
			extra_sed[${#extra_sed[@]}]='/\tinstall .*\/libaio.a/d'
			# Tests require the static library to be built.
			if ! use test; then
				extra_sed[${#extra_sed[@]}]='-e'
				extra_sed[${#extra_sed[@]}]='/^all_targets +=/s/ libaio.a//'
			fi
		fi
		sed -i \
			-e "/^libdir=/s:lib$:$(get_libdir):" \
			-e "/^prefix=/s:/usr:${EPREFIX}/usr:" \
			-e '/:=.*strip.*shell.*git/s:=.*:=:' \
			"${extra_sed[@]}" \
			src/Makefile Makefile || die

		sed -i -e "s:-Werror::g" harness/Makefile || die
	done
	ABI=${OABI}
}

emake_libaio() {
	# The Makefiles need these environments, but multilib_toolchain_setup()
	# does not export anything when there is only one default abi available.
	CC="$(tc-getCC) $(get_abi_CFLAGS)" \
	AR=$(tc-getAR) \
	RANLIB=$(tc-getRANLIB) \
	emake "$@"
}

src_compile() {
	local OABI=${ABI}
	for ABI in $(aio_get_install_abis)
	do
		einfo "Compiling ${ABI} ABI ..."
		cd "${WORKDIR}"/${ABI}/${P} || die
		emake_libaio
	done
	ABI=${OABI}
}

src_test() {
	local OABI=${ABI}
	for ABI in $(aio_get_install_abis)
	do
		einfo "Testing ${ABI} ABI ..."
		cd "${WORKDIR}"/${ABI}/${P}/harness || die
		mkdir testdir || die
		# 'make check' breaks with sandbox, 'make partcheck' works
		emake_libaio partcheck prefix="${S}/src" libdir="${S}/src"
	done
	ABI=${OABI}
}

src_install() {
	local OABI=${ABI}
	for ABI in $(aio_get_install_abis)
	do
		einfo "Installing ${ABI} ABI ..."
		cd "${WORKDIR}"/${ABI}/${P} || die

		# Don't use ED for emake, src_prepare already inserts EPREFIX in the correct
		# place
		emake_libaio install DESTDIR="${D}"

		doman man/*
		dodoc ChangeLog TODO

		# move crap to / for multipath-tools #325355
		CFLAGS="${CFLAGS} $(get_abi_CFLAGS)" gen_usr_ldscript -a aio
	done
	ABI=${OABI}
}