metadata.xml: popuplate CPE entries for better CVE tracking
[gentoo.git] / dev-libs / nspr / nspr-4.20.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit autotools toolchain-funcs multilib-minimal
7
8 MIN_PV="$(ver_cut 2)"
9
10 DESCRIPTION="Netscape Portable Runtime"
11 HOMEPAGE="http://www.mozilla.org/projects/nspr/"
12 SRC_URI="https://archive.mozilla.org/pub/nspr/releases/v${PV}/src/${P}.tar.gz"
13
14 LICENSE="|| ( MPL-2.0 GPL-2 LGPL-2.1 )"
15 SLOT="0"
16 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~m68k ~mips ppc ppc64 s390 ~sh sparc x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
17 IUSE="debug"
18
19 MULTILIB_CHOST_TOOLS=(
20         /usr/bin/nspr-config
21 )
22
23 PATCHES=(
24         "${FILESDIR}"/${PN}-4.7.0-prtime.patch
25         "${FILESDIR}"/${PN}-4.7.1-solaris.patch
26         "${FILESDIR}"/${PN}-4.10.6-solaris.patch
27         "${FILESDIR}"/${PN}-4.8.4-darwin-install_name.patch
28         "${FILESDIR}"/${PN}-4.8.9-link-flags.patch
29         # We do not need to pass -L$libdir via nspr-config --libs
30         "${FILESDIR}"/${PN}-4.9.5_nspr_config.patch
31 )
32
33 src_prepare() {
34         cd "${S}"/nspr || die
35
36         default
37
38         # rename configure.in to configure.ac for new autotools compatibility
39         if [[ -e "${S}"/nspr/configure.in ]] ; then
40                 einfo "Renaming configure.in to configure.ac"
41                 mv "${S}"/nspr/configure.{in,ac} || die
42         fi
43
44         # We must run eautoconf to regenerate configure
45         eautoconf
46
47         # make sure it won't find Perl out of Prefix
48         sed -i -e "s/perl5//g" "${S}"/nspr/configure || die
49
50         # Respect LDFLAGS
51         sed -i -e 's/\$(MKSHLIB) \$(OBJS)/\$(MKSHLIB) \$(LDFLAGS) \$(OBJS)/g' \
52                 "${S}"/nspr/config/rules.mk || die
53 }
54
55 multilib_src_configure() {
56         # We use the standard BUILD_xxx but nspr uses HOST_xxx
57         tc-export_build_env BUILD_CC
58         export HOST_CC=${BUILD_CC} HOST_CFLAGS=${BUILD_CFLAGS} HOST_LDFLAGS=${BUILD_LDFLAGS}
59         tc-export AR CC CXX RANLIB
60         [[ ${CBUILD} != ${CHOST} ]] \
61                 && export CROSS_COMPILE=1 \
62                 || unset CROSS_COMPILE
63
64         local myconf=(
65                 --libdir="${EPREFIX}/usr/$(get_libdir)"
66                 $(use_enable debug)
67                 $(use_enable !debug optimize)
68         )
69
70         # The configure has some fancy --enable-{{n,x}32,64bit} switches
71         # that trigger some code conditional to platform & arch. This really
72         # matters for the few common arches (x86, ppc) but we pass a little
73         # more of them to be future-proof.
74
75         # use ABI first, this will work for most cases
76         case "${ABI}" in
77                 alpha|arm|hppa|m68k|o32|ppc|s390|sh|sparc|x86) ;;
78                 n32) myconf+=( --enable-n32 );;
79                 x32) myconf+=( --enable-x32 );;
80                 s390x|*64) myconf+=( --enable-64bit );;
81                 default) # no abi actually set, fall back to old check
82                         einfo "Running a short build test to determine 64bit'ness"
83                         echo > "${T}"/test.c || die
84                         ${CC} ${CFLAGS} ${CPPFLAGS} -c "${T}"/test.c -o "${T}"/test.o || die
85                         case $(file "${T}"/test.o) in
86                                 *32-bit*x86-64*) myconf+=( --enable-x32 );;
87                                 *64-bit*|*ppc64*|*x86_64*) myconf+=( --enable-64bit );;
88                                 *32-bit*|*ppc*|*i386*) ;;
89                                 *) die "Failed to detect whether your arch is 64bits or 32bits, disable distcc if you're using it, please";;
90                         esac ;;
91                 *) ;;
92         esac
93
94         # Ancient autoconf needs help finding the right tools.
95         LC_ALL="C" ECONF_SOURCE="${S}/nspr" \
96         ac_cv_path_AR="${AR}" \
97         econf "${myconf[@]}"
98 }
99
100 multilib_src_install() {
101         # Their build system is royally confusing, as usual
102         MINOR_VERSION=${MIN_PV} # Used for .so version
103         emake DESTDIR="${D}" install
104
105         einfo "removing static libraries as upstream has requested!"
106         rm "${ED}"/usr/$(get_libdir)/*.a || die "failed to remove static libraries."
107
108         # install nspr-config
109         dobin config/nspr-config
110
111         # Remove stupid files in /usr/bin
112         rm "${ED}"/usr/bin/prerr.properties || die
113
114         # This is used only to generate prerr.c and prerr.h at build time.
115         # No other projects use it, and we don't want to depend on perl.
116         # Talked to upstream and they agreed w/punting.
117         rm "${ED}"/usr/bin/compile-et.pl || die
118 }