1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils alternatives flag-o-matic toolchain-funcs multilib multiprocessing
10 PATCH_BASE="perl-5.24.2-patches-${PATCH_VER}"
12 PERL_OLDVERSEN="5.24.1 5.24.0"
16 MY_P="perl-${PV/_rc/-RC}"
19 DESCRIPTION="Larry Wall's Practical Extraction and Report Language"
22 mirror://cpan/src/5.0/${MY_P}.tar.xz
23 mirror://cpan/authors/id/${DIST_AUTHOR:0:1}/${DIST_AUTHOR:0:2}/${DIST_AUTHOR}/${MY_P}.tar.xz
24 https://github.com/gentoo-perl/perl-patchset/releases/download/${PATCH_BASE}/${PATCH_BASE}.tar.xz
25 mirror://gentoo/${PATCH_BASE}.tar.xz
26 https://dev.gentoo.org/~kentnl/distfiles/${PATCH_BASE}.tar.xz
27 https://github.com/arsv/perl-cross/releases/download/${CROSS_VER}/perl-cross-${CROSS_VER}.tar.gz
29 HOMEPAGE="http://www.perl.org/"
31 LICENSE="|| ( Artistic GPL-1+ )"
33 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
34 IUSE="berkdb debug doc gdbm ithreads"
37 berkdb? ( sys-libs/db:= )
38 gdbm? ( >=sys-libs/gdbm-1.8.3 )
43 !prefix? ( elibc_FreeBSD? ( sys-freebsd/freebsd-mk-defs ) )
46 >=app-admin/perl-cleaner-2.5
47 >=virtual/perl-File-Path-2.130.0
48 >=virtual/perl-File-Temp-0.230.400-r2
49 >=virtual/perl-Data-Dumper-2.154.0
50 virtual/perl-Test-Harness
52 # bug 390719, bug 523624, bug 620304
53 # virtual/perl-Test-Harness is here for the bundled ExtUtils::MakeMaker
55 S="${WORKDIR}/${MY_P}"
58 src_remove_dual perl-core/Archive-Tar 2.40.100_rc ptar ptardiff ptargrep
59 src_remove_dual perl-core/CPAN 2.110.100_rc cpan
60 src_remove_dual perl-core/Digest-SHA 5.950.100_rc shasum
61 src_remove_dual perl-core/Encode 2.800.100_rc enc2xs piconv
62 src_remove_dual perl-core/ExtUtils-MakeMaker 7.100.200_rc instmodsh
63 src_remove_dual perl-core/ExtUtils-ParseXS 3.310.0 xsubpp
64 src_remove_dual perl-core/IO-Compress 2.69.1_rc zipdetails
65 src_remove_dual perl-core/JSON-PP 2.273.0.100_rc json_pp
66 src_remove_dual perl-core/Module-CoreList 5.201.707.152.400_rc corelist
67 src_remove_dual perl-core/Pod-Parser 1.630.0 pod2usage podchecker podselect
68 src_remove_dual perl-core/Pod-Perldoc 3.250.300_rc perldoc
69 src_remove_dual perl-core/Test-Harness 3.360.100_rc prove
70 src_remove_dual perl-core/podlators 4.70.0 pod2man pod2text
71 src_remove_dual_man perl-core/podlators 4.70.0 /usr/share/man/man1/perlpodstyle.1
76 if [[ -z "${REPLACING_VERSIONS}" ]]; then
79 # doesn't matter if there's multiple copies, it still needs a rebuild
80 # if the string is anything other than "5.CURRENTMAJOR"
81 elif [[ "${REPLACING_VERSIONS%.*}" != "${PV%.*}" ]]; then
83 ewarn "UPDATE THE PERL MODULES:"
84 ewarn "After updating dev-lang/perl the installed Perl modules"
85 ewarn "have to be re-installed. In most cases, this is done automatically"
86 ewarn "by the package manager, but subsequent steps are still recommended"
87 ewarn "to ensure system consistency."
89 ewarn "You should start with a depclean to remove any unused perl dependencies"
90 ewarn "that may confuse portage in future. Regular depcleans are also encouraged"
91 ewarn "as part of your regular update cycle, as that will keep perl upgrades working."
92 ewarn "Recommended: emerge --depclean -va"
94 ewarn "You should then call perl-cleaner to clean up any old files and trigger any"
95 ewarn "remaining rebuilds portage may have missed."
96 ewarn "Use: perl-cleaner --all"
99 # Reinstall w/ USE Change
100 elif ( use ithreads && ! has_version dev-lang/perl[ithreads] ) || \
101 ( ! use ithreads && has_version dev-lang/perl[ithreads] ) || \
102 ( use debug && ! has_version dev-lang/perl[debug] ) || \
103 ( ! use debug && has_version dev-lang/perl[debug] ) ; then
105 ewarn "TOGGLED USE-FLAGS WARNING:"
106 ewarn "You changed one of the use-flags ithreads or debug."
107 ewarn "You must rebuild all perl-modules installed."
108 ewarn "Use: perl-cleaner --modules ; perl-cleaner --force --libperl"
114 *-freebsd*) osname="freebsd" ;;
115 *-dragonfly*) osname="dragonfly" ;;
116 *-netbsd*) osname="netbsd" ;;
117 *-openbsd*) osname="openbsd" ;;
118 *-darwin*) osname="darwin" ;;
119 *-interix*) osname="interix" ;;
120 *-aix*) osname="aix" ;;
121 *-cygwin*) osname="cygwin" ;;
125 myarch="${CHOST%%-*}-${osname}"
129 if use ithreads ; then
134 LIBPERL="libperl$(get_libname ${MY_PV} )"
135 PRIV_LIB="/usr/$(get_libdir)/perl5/${MY_PV}"
136 ARCH_LIB="/usr/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading}"
137 SITE_LIB="/usr/local/$(get_libdir)/perl5/${MY_PV}"
138 SITE_ARCH="/usr/local/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading}"
139 VENDOR_LIB="/usr/$(get_libdir)/perl5/vendor_perl/${MY_PV}"
140 VENDOR_ARCH="/usr/$(get_libdir)/perl5/vendor_perl/${MY_PV}/${myarch}${mythreading}"
145 src_remove_dual_file() {
150 case "${EBUILD_PHASE:-none}" in
153 alternatives_auto_makesym "${i}" "${i}-[0-9]*"
158 if [[ -f ${EROOT}${i} && ! -h ${EROOT}${i} ]] ; then
159 has_version ${pkg} && ewarn "You must reinstall ${pkg} !"
166 if ! [[ -f "${ED}"${i} ]] ; then
167 ewarn "${i} does not exist!"
170 mv "${ED}"${i}{,-${ver}-${P}} || die
176 src_remove_dual_man() {
181 case "${EBUILD_PHASE:-none}" in
184 ff=`echo "${EROOT}${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}}"*`
185 ff=${ff##*${i#${i%.[0-9]}}}
186 alternatives_auto_makesym "${i}${ff}" "${i%.[0-9]}-[0-9]*"
191 if ! [[ -f "${ED}"${i} ]] ; then
192 ewarn "${i} does not exist!"
195 mv "${ED}"${i} "${ED}"${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}} || die
207 src_remove_dual_file "${pkg}" "${ver}" "/usr/bin/${i}"
208 src_remove_dual_man "${pkg}" "${ver}" "/usr/share/man/man1/${i}.1"
212 src_prepare_update_patchlevel_h() {
213 # Copied and modified from debian:
214 # Copyright 2011 Niko Tyni
215 # This program is free software; you can redistribute it and/or modify
216 # it under the same terms as Perl itself.
217 local patchdir="${WORKDIR}/patches"
219 local patchoutput="patchlevel-gentoo.h"
221 [[ -f ${patchdir}/series ]] || return 0
225 patchname=$(echo $patch | sed 's/\.diff$//')
226 < $patchdir/$patch sed -e '/^Subject:/ { N; s/\n / / }' | sed -n -e '
228 # massage the patch headers
229 s|^Bug: .*https\?://rt\.perl\.org/.*id=\(.*\).*|[perl #\1]|; tprepend;
230 s|^Bug: .*https\?://rt\.cpan\.org/.*id=\(.*\).*|[rt.cpan.org #\1]|; tprepend;
231 s|^Bug-Gentoo: ||; tprepend;
232 s/^\(Subject\|Description\): //; tappend;
233 s|^Origin: .*http://perl5\.git\.perl\.org/perl\.git/commit\(diff\)\?/\(.......\).*|[\2]|; tprepend;
235 # post-process at the end of input
237 # include the version number in the patchlevel.h description (if available)
238 s/List packaged patches/&'" for ${PF}(#${PATCH_VER})"'/;
240 # escape any backslashes and double quotes
241 s|\\|\\\\|g; s|"|\\"|g;
244 s|^|\t,"'"$prefix$patchname"' - |;
250 # stop all processing
252 # label: append to the hold space
254 # label: prepend to the hold space
257 done < "${WORKDIR}"/patches/series > "${S}/${patchoutput}"
258 echo "${patchoutput}" >> "${S}/MANIFEST"
264 einfo "Applying patches from ${MY_P}-${PATCH_VER} ..."
265 while read patch ; do
266 EPATCH_SINGLE_MSG=" ${patch} ..."
267 epatch "${WORKDIR}"/patches/${patch}
268 done < "${WORKDIR}"/patches/series
270 src_prepare_update_patchlevel_h
272 if tc-is-cross-compiler; then
273 cp -a ../perl-cross-${CROSS_VER}/* . || die
276 -e 's/(15 + $CLEANUP)/(13 + $CLEANUP)/' \
277 cnf/diffs/perl5-${PV}/makemaker-test.patch || die
280 -e 's/MakeMaker\.pm .*/MakeMaker.pm bf9174c70a0e50ff2fee4552c7df89b37d292da1/' \
281 -e 's/MM_Unix\.pm .*/MM_Unix.pm b0ec308fe2d7dcfcef5732880db0fae1f4ea80fa/' \
282 cnf/diffs/perl5-${PV}/customized.patch || die
285 -e 's|^lib/unicore/CombiningClass.pl pod/perluniprops.pod:|lib/unicore/CombiningClass.pl pod/perluniprops.pod: $(CONFIGPM)|' \
293 if ! tc-is-static-only ; then
294 ln -s ${LIBPERL} libperl$(get_libname ${SHORT_PV}) || die
295 ln -s ${LIBPERL} libperl$(get_libname ) || die
299 sed -i "s:INC => .*:INC => \"-I${EROOT}usr/include/gdbm\":g" \
300 ext/NDBM_File/Makefile.PL || die
307 # the myconf array is declared in src_configure
308 myconf=( "${myconf[@]}" "$@" )
315 [[ ${COLUMNS:-1} -ge 1 ]] || unset COLUMNS # bug #394091
317 # some arches and -O do not mix :)
318 use ppc && replace-flags -O? -O1
320 # Perl has problems compiling with -Os in your flags with glibc
321 use elibc_uclibc || replace-flags "-Os" "-O2"
323 # This flag makes compiling crash in interesting ways
324 filter-flags "-malign-double"
327 use ppc && filter-flags "-mpowerpc-gpopt"
329 # Fixes bug #143895 on gcc-4.1.1
330 filter-flags "-fsched2-use-superblocks"
332 use sparc && myconf -Ud_longdbl
335 export BZIP2_INCLUDE=${EROOT}/usr/include
336 export BZIP2_LIB=${EROOT}/usr/$(get_libdir)
338 export BUILD_ZLIB=False
339 export ZLIB_INCLUDE=${EROOT}/usr/include
340 export ZLIB_LIB=${EROOT}/usr/$(get_libdir)
342 # allow either gdbm to provide ndbm (in <gdbm/ndbm.h>) or db1
354 has_version '=sys-libs/db-1*' && myndbm='D'
357 myconf "-${myndbm}i_ndbm" "-${mygdbm}i_gdbm" "-${mydb}i_db"
359 if use alpha && [[ "$(tc-getCC)" = "ccc" ]] ; then
360 ewarn "Perl will not be built with berkdb support, use gcc if you needed it..."
361 myconf -Ui_db -Ui_ndbm
364 use ithreads && myconf -Dusethreads
369 elif [[ ${CFLAGS} == *-g* ]] ; then
370 myconf -DDEBUGGING=-g
372 myconf -DDEBUGGING=none
375 if [[ -n ${PERL_OLDVERSEN} ]] ; then
376 local inclist=$(for v in ${PERL_OLDVERSEN}; do echo -n "${v}/${myarch}${mythreading} ${v} "; done )
377 myconf -Dinc_version_list="${inclist}"
380 [[ ${ELIBC} == "FreeBSD" ]] && myconf "-Dlibc=/usr/$(get_libdir)/libc.a"
382 # Make sure we can do the final link #523730, need to set deployment
383 # target to override hardcoded 10.3 which breaks on modern OSX
384 [[ ${CHOST} == *-darwin* ]] && \
385 myconf "-Dld=env MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} $(tc-getCC)"
387 # Prefix: the host system needs not to follow Gentoo multilib stuff, and in
388 # Prefix itself we don't do multilib either, so make sure perl can find
389 # something compatible.
391 # Set a hook to check for each detected library whether it actually works.
393 ( echo 'main(){}' > '${T}'/conftest.c &&
394 $(tc-getCC) -o '${T}'/conftest '${T}'/conftest.c -l\$thislib >/dev/null 2>/dev/null
397 # Use all host paths that might contain useful stuff, the hook above will filter out bad choices.
398 local paths="/lib/*-linux-gnu /usr/lib/*-linux-gnu /lib64 /lib/64 /usr/lib64 /usr/lib/64 /lib32 /usr/lib32 /lib /usr/lib"
399 myconf "-Dlibpth=${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir) ${paths}"
400 elif [[ $(get_libdir) != "lib" ]] ; then
401 # We need to use " and not ', as the written config.sh use ' ...
402 myconf "-Dlibpth=/usr/local/$(get_libdir) /$(get_libdir) /usr/$(get_libdir)"
405 # don't try building ODBM, bug #354453
406 disabled_extensions="ODBM_File"
409 # workaround for bug #157774: don't try building GDBM related stuff with USE="-gdbm"
410 disabled_extensions="${disabled_extensions} GDBM_File NDBM_File"
413 myconf -Dnoextensions="${disabled_extensions}"
415 [[ -n "${EXTRA_ECONF}" ]] && ewarn During Perl build, EXTRA_ECONF=${EXTRA_ECONF}
416 # allow fiddling via EXTRA_ECONF, bug 558070
417 eval "local -a EXTRA_ECONF=(${EXTRA_ECONF})"
421 -Darchname="${myarch}" \
423 -Doptimize="${CFLAGS}" \
424 -Dldflags="${LDFLAGS}" \
425 -Dprefix="${EPREFIX}"'/usr' \
426 -Dsiteprefix="${EPREFIX}"'/usr/local' \
427 -Dvendorprefix="${EPREFIX}"'/usr' \
428 -Dscriptdir="${EPREFIX}"'/usr/bin' \
429 -Dprivlib="${EPREFIX}${PRIV_LIB}" \
430 -Darchlib="${EPREFIX}${ARCH_LIB}" \
431 -Dsitelib="${EPREFIX}${SITE_LIB}" \
432 -Dsitearch="${EPREFIX}${SITE_ARCH}" \
433 -Dvendorlib="${EPREFIX}${VENDOR_LIB}" \
434 -Dvendorarch="${EPREFIX}${VENDOR_ARCH}" \
435 -Dman1dir="${EPREFIX}"/usr/share/man/man1 \
436 -Dman3dir="${EPREFIX}"/usr/share/man/man3 \
437 -Dsiteman1dir="${EPREFIX}"/usr/local/man/man1 \
438 -Dsiteman3dir="${EPREFIX}"/usr/local/man/man3 \
439 -Dvendorman1dir="${EPREFIX}"/usr/share/man/man1 \
440 -Dvendorman3dir="${EPREFIX}"/usr/share/man/man3 \
443 -Dlibperl="${LIBPERL}" \
444 -Dlocincpth="${EPREFIX}"'/usr/include ' \
445 -Dglibpth="${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir)"' ' \
449 -Dmyhostname='localhost' \
450 -Dperladmin='root@localhost' \
452 -Dsh="${EPREFIX}"/bin/sh \
453 -Dtargetsh="${EPREFIX}"/bin/sh \
458 if tc-is-cross-compiler; then
460 --target="${CHOST}" \
461 --build="${CBUILD}" \
463 -Dinstallusrbinperl='undef' \
464 -Dusevendorprefix='define' \
466 || die "Unable to configure"
470 -Dinstallprefix="${EPREFIX}"'/usr' \
471 -Dinstallusrbinperl='n' \
473 || die "Unable to configure"
478 export NO_GENTOO_NETWORK_TESTS=1;
479 if [[ ${EUID} == 0 ]] ; then
480 ewarn "Test fails with a sandbox error (#328793) if run as root. Skipping tests..."
483 use elibc_uclibc && export MAKEOPTS+=" -j1"
484 TEST_JOBS="$(makeopts_jobs)" make test_harness || die "test failed"
489 local coredir="${ARCH_LIB}/CORE"
491 emake DESTDIR="${D}" install
493 rm -f "${ED}/usr/bin/perl${MY_PV}"
494 ln -s perl "${ED}"/usr/bin/perl${MY_PV} || die
496 if ! tc-is-static-only ; then
497 dolib.so "${ED}"${coredir}/${LIBPERL}
498 rm -f "${ED}"${coredir}/${LIBPERL}
499 ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname ${SHORT_PV}) || die
500 ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname) || die
501 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/${LIBPERL} || die
502 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/libperl$(get_libname ${SHORT_PV}) || die
503 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/libperl$(get_libname) || die
506 rm -rf "${ED}"/usr/share/man/man3 || die "Unable to remove module man pages"
508 # This removes ${D} from Config.pm
509 for i in $(find "${D}" -iname "Config.pm" ) ; do
510 einfo "Removing ${D} from ${i}..."
511 sed -i -e "s:${D}::" "${i}" || die "Sed failed"
514 dodoc Changes* README AUTHORS
518 # We expect errors, warnings, and such with the following.
520 dodir /usr/share/doc/${PF}/html
521 LD_LIBRARY_PATH=. ./perl installhtml \
523 --podpath='lib:ext:pod:vms' \
525 --htmldir="${ED}/usr/share/doc/${PF}/html"
528 [[ -d ${ED}/usr/local ]] && rm -r "${ED}"/usr/local
540 if [[ "${ROOT}" = "/" ]] ; then
542 INC=$(perl -e 'for $line (@INC) { next if $line eq "."; next if $line =~ m/'${SHORT_PV}'|etc|local|perl$/; print "$line\n" }')
543 einfo "Removing old .ph files"
544 for DIR in ${INC} ; do
545 if [[ -d "${DIR}" ]] ; then
546 for file in $(find "${DIR}" -name "*.ph" -type f ) ; do
552 # Silently remove the now empty dirs
553 for DIR in ${INC} ; do
554 if [[ -d "${DIR}" ]] ; then
555 find "${DIR}" -depth -type d -print0 | xargs -0 -r rmdir &> /dev/null