6a8b7503dd91f57294b22af55c9823f52a8d1323
[gentoo.git] / media-sound / mpg123 / mpg123-1.23.8.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6 inherit flag-o-matic toolchain-funcs libtool multilib-minimal
7
8 DESCRIPTION="a realtime MPEG 1.0/2.0/2.5 audio player for layers 1, 2 and 3"
9 HOMEPAGE="http://www.mpg123.org/"
10 SRC_URI="http://www.mpg123.org/download/${P}.tar.bz2"
11
12 LICENSE="GPL-2 LGPL-2.1"
13 SLOT="0"
14 KEYWORDS="alpha amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x86-solaris"
15 IUSE="cpu_flags_x86_3dnow cpu_flags_x86_3dnowext alsa altivec coreaudio int-quality ipv6 jack cpu_flags_x86_mmx nas oss portaudio pulseaudio sdl cpu_flags_x86_sse"
16
17 # No MULTILIB_USEDEP here since we only build libmpg123 for non native ABIs.
18 RDEPEND="app-eselect/eselect-mpg123
19         || ( dev-libs/libltdl:0 <sys-devel/libtool-2.4.3-r2:2 )
20         alsa? ( media-libs/alsa-lib )
21         jack? ( media-sound/jack-audio-connection-kit )
22         nas? ( media-libs/nas )
23         portaudio? ( media-libs/portaudio )
24         pulseaudio? ( media-sound/pulseaudio )
25         sdl? ( media-libs/libsdl )
26         abi_x86_32? (
27                 !<=app-emulation/emul-linux-x86-soundlibs-20130224-r9
28                 !app-emulation/emul-linux-x86-soundlibs[-abi_x86_32(-)]
29         )"
30 DEPEND="${RDEPEND}
31         sys-devel/libtool
32         virtual/pkgconfig"
33
34 DOCS=( AUTHORS ChangeLog NEWS NEWS.libmpg123 README )
35
36 pkg_setup() {
37         # Build fails without -D_GNU_SOURCE like this:
38         # error: ‘struct hostent’ has no member named ‘h_addr’
39         append-cflags -D_GNU_SOURCE
40 }
41
42 src_prepare() {
43         default
44         elibtoolize # for Darwin bundles
45 }
46
47 multilib_src_configure() {
48         local _audio=dummy
49         local _output=dummy
50         local _cpu=generic_fpu
51
52         if $(multilib_is_native_abi) ; then
53                 for flag in nas portaudio sdl oss jack alsa pulseaudio coreaudio; do
54                         if use ${flag}; then
55                                 _audio+=" ${flag/pulseaudio/pulse}"
56                                 _output=${flag/pulseaudio/pulse}
57                         fi
58                 done
59         fi
60
61         use altivec && _cpu=altivec
62
63         if [[ $(tc-arch) == amd64 || ${ARCH} == x64-* ]]; then
64                 use cpu_flags_x86_sse && _cpu=x86-64
65         elif use x86 && gcc-specs-pie ; then
66                 # Don't use any mmx, 3dnow, sse and 3dnowext #bug 164504
67                 _cpu=generic_fpu
68         elif use x86-macos ; then
69                 # ASM doesn't work quite as expected with the Darwin linker
70                 _cpu=generic_fpu
71         else
72                 use cpu_flags_x86_mmx && _cpu=mmx
73                 use cpu_flags_x86_3dnow && _cpu=3dnow
74                 use cpu_flags_x86_sse && _cpu=x86
75                 use cpu_flags_x86_3dnowext && _cpu=x86
76         fi
77
78         local myconf=""
79         multilib_is_native_abi || myconf="${myconf} --disable-modules"
80
81         ECONF_SOURCE="${S}" econf \
82                 --with-optimization=0 \
83                 --with-audio="${_audio}" \
84                 --with-default-audio=${_output} \
85                 --with-cpu=${_cpu} \
86                 --enable-network \
87                 $(use_enable ipv6) \
88                 --enable-int-quality=$(usex int-quality) \
89                 ${myconf}
90
91         if ! $(multilib_is_native_abi) ; then
92                 sed -i -e 's:src doc:src/libmpg123:' Makefile || die
93         fi
94 }
95
96 multilib_src_install_all() {
97         einstalldocs
98         mv "${ED}"/usr/bin/mpg123{,-mpg123}
99         find "${ED}" -name '*.la' -exec sed -i -e "/^dependency_libs/s:=.*:='':" {} +
100 }
101
102 pkg_postinst() {
103         eselect mpg123 update ifunset
104 }
105
106 pkg_postrm() {
107         eselect mpg123 update ifunset
108 }