--- perl-5.8.8-r8.ebuild 2009-12-10 16:06:04.000000000 -0500 +++ perl-5.8.8-r9.ebuild 2010-02-02 19:24:17.951340377 -0500 @@ -41,6 +41,14 @@ PDEPEND=">=app-admin/perl-cleaner-1.03" +# Cross-compiled build can't use a bootstrapped miniperl so +# it uses native perl. +if tc-is-cross-compiler; then + export HOSTPERL="/usr/bin/perl${PV}" +else + export HOSTPERL='./perl' +fi + dual_scripts() { src_remove_dual_scripts perl-core/Encode 2.12 enc2xs piconv src_remove_dual_scripts perl-core/PodParser 1.32 pod2usage podchecker podselect @@ -63,6 +71,14 @@ epause 5 fi + if tc-is-cross-compiler ; then + ewarn "It appears you are cross-compiling ${PN}." + ewarn "You must have libperl-${PV} (>=libperl-5.8.8-r3) and" + ewarn "perl-${PV} (>=perl-5.8.8-r9) installed on your" + ewarn "native build system or this build might fail." + epause 5 + fi + if [[ ! -f "${ROOT}/usr/$(get_libdir)/${LIBPERL}" ]] then # Make sure we have libperl installed ... @@ -172,6 +188,25 @@ # Respect CFLAGS even for linking when done with compiler epatch "${FILESDIR}"/${P}-ccld-cflags.patch + + # Check the environment for {PERL_LIB}, {PERL_ARCHLIB} + # and {PERL_INC} and use relative headers + epatch "${FILESDIR}"/native-perlinc.patch + + # Dynamically load modules from ${PERLHOSTLIB} to + # use while compiling + epatch "${FILESDIR}"/perl-dynloader.patch + + # Use Config_heavy.pl from ${PERL_ARCHLIB} + epatch "${FILESDIR}"/perl-configpm-switch.patch + + if tc-is-cross-compiler; then + # Use ${HOSTPERL}, not miniperl, for cross-compiling + epatch "${FILESDIR}"/Makefile.SH.patch + + epatch "${FILESDIR}"/perl-moreconfig.patch + epatch "${FILESDIR}"/letgcc-find-errno.patch + fi } myconf() { @@ -283,30 +318,43 @@ myconf "-Dlibpth=/usr/local/$(get_libdir) /$(get_libdir) /usr/$(get_libdir)" fi - sh Configure -des \ - -Darchname="${myarch}" \ - -Dcccdlflags='-fPIC' \ - -Dccdlflags='-rdynamic' \ - -Dcc="$(tc-getCC)" \ - -Dprefix='/usr' \ - -Dvendorprefix='/usr' \ - -Dsiteprefix='/usr' \ - -Dlocincpth=' ' \ - -Doptimize="${CFLAGS}" \ - -Duselargefiles \ - -Dd_semctl_semun \ - -Dscriptdir=/usr/bin \ - -Dman1dir=/usr/share/man/man1 \ - -Dman3dir=/usr/share/man/man3 \ - -Dinstallman1dir=/usr/share/man/man1 \ - -Dinstallman3dir=/usr/share/man/man3 \ - -Dman1ext='1' \ - -Dman3ext='3pm' \ - -Dinc_version_list="$inclist" \ - -Dcf_by='Gentoo' \ - -Ud_csh \ - -Dusenm \ - "${myconf[@]}" || die "Unable to configure" + if tc-is-cross-compiler; then + # ${S}/config.sh is generated from config-bits. + # Bash substitution is used to alter options for each build + + source "${FILESDIR}"/config-bits || die "sourcing of config-bits failed" + make_configsh || die "make_configsh failed" + + sed -i -e "s|/usr/include|${ROOT}usr/include|g" \ + "${S}"/ext/Errno/Errno_pm.PL || die "sed of ${S}/ext/Errno/Errno_pm.PL failed" + + sh Configure -S $(use debug && echo '-DDEBUGGING') || die "Unable to configure" + else + sh Configure -des \ + -Darchname="${myarch}" \ + -Dcccdlflags='-fPIC' \ + -Dccdlflags='-rdynamic' \ + -Dcc="$(tc-getCC)" \ + -Dprefix='/usr' \ + -Dvendorprefix='/usr' \ + -Dsiteprefix='/usr' \ + -Dlocincpth=' ' \ + -Doptimize="${CFLAGS}" \ + -Duselargefiles \ + -Dd_semctl_semun \ + -Dscriptdir=/usr/bin \ + -Dman1dir=/usr/share/man/man1 \ + -Dman3dir=/usr/share/man/man3 \ + -Dinstallman1dir=/usr/share/man/man1 \ + -Dinstallman3dir=/usr/share/man/man3 \ + -Dman1ext='1' \ + -Dman3ext='3pm' \ + -Dinc_version_list="$inclist" \ + -Dcf_by='Gentoo' \ + -Ud_csh \ + -Dusenm \ + "${myconf[@]}" || die "Unable to configure" + fi } src_compile() { @@ -317,6 +365,34 @@ src_configure emake -j1 || die "Unable to make" + + if tc-is-cross-compiler; then + # Cross-compile build uses host library + export PERLHOSTLIB="$(${HOSTPERL} -V:archlib | cut -d \' -f 2)" + + emake -j1 more || die "Unable to make more" + + mkdir -p "${S}"/fake_config_library || die "Unable to mkdir ${S}/fake_config_library" + cp -f "${S}"/lib/Config.pm "${S}"/fake_config_library \ + || die "Unable to copy ${S}/lib/Config.pm" + + emake -j1 more2 "PERLRUN=${HOSTPERL} \ + -I${S}/fake_config_library -MConfig" || die "Unable to make more2" + emake -j1 more3 "PERLRUN=${HOSTPERL} \ + -I${S}/fake_config_library -MConfig" || die "Unable to make more3" + emake -j1 more4 "PERLRUN=${HOSTPERL} \ + -I${S}/fake_config_library -MConfig" || die "Unable to make more4" + + rm -rf "${S}"/install_me_here || die "Unable to remove ${S}/install_me_here" + + for f in `find "${S}"/lib -name install_me_here` ; do + cp -r "${f}"/* "${S}"/install_me_here/ || die "Unable to copy ${f}/*" + done + + for f in `find "${S}"/lib -name install_me_here` ; do + rm -rf "${f}" || die "Unable to remove ${f}" + done + fi } src_test() { @@ -328,6 +404,10 @@ export LC_ALL="C" + # Cross-compile build uses host library + tc-is-cross-compiler && \ + export PERLHOSTLIB="$(${HOSTPERL} -V:archlib | cut -d \' -f 2)" + # Need to do this, else apps do not link to dynamic version of # the library ... local coredir="/usr/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading}/CORE" @@ -351,7 +431,7 @@ cp -f utils/h2ph utils/h2ph_patched epatch "${FILESDIR}"/${PN}-h2ph-ansi-header.patch - LD_LIBRARY_PATH=. ./perl -Ilib utils/h2ph_patched \ + LD_LIBRARY_PATH=. ${HOSTPERL} -Ilib utils/h2ph_patched \ -a -d "${D}"/usr/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading} <