1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools toolchain-funcs multilib-minimal
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"
14 LICENSE="|| ( MPL-2.0 GPL-2 LGPL-2.1 )"
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"
19 MULTILIB_CHOST_TOOLS=(
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
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
44 # We must run eautoconf to regenerate configure
47 # make sure it won't find Perl out of Prefix
48 sed -i -e "s/perl5//g" "${S}"/nspr/configure || die
51 sed -i -e 's/\$(MKSHLIB) \$(OBJS)/\$(MKSHLIB) \$(LDFLAGS) \$(OBJS)/g' \
52 "${S}"/nspr/config/rules.mk || die
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
65 --libdir="${EPREFIX}/usr/$(get_libdir)"
67 $(use_enable !debug optimize)
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.
75 # use ABI first, this will work for most cases
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";;
94 # Ancient autoconf needs help finding the right tools.
95 LC_ALL="C" ECONF_SOURCE="${S}/nspr" \
96 ac_cv_path_AR="${AR}" \
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
105 einfo "removing static libraries as upstream has requested!"
106 rm "${ED}"/usr/$(get_libdir)/*.a || die "failed to remove static libraries."
108 # install nspr-config
109 dobin config/nspr-config
111 # Remove stupid files in /usr/bin
112 rm "${ED}"/usr/bin/prerr.properties || die
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