1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils alternatives flag-o-matic toolchain-funcs multilib multiprocessing
15 MY_P="perl-${PV/_rc/-RC}"
18 DESCRIPTION="Larry Wall's Practical Extraction and Report Language"
21 mirror://cpan/src/5.0/${MY_P}.tar.bz2
22 mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MY_P}.tar.bz2
23 mirror://gentoo/${MY_P}-patches-${PATCH_VER}.tar.xz
24 https://dev.gentoo.org/~dilfridge/distfiles/${MY_P}-patches-${PATCH_VER}.tar.xz
26 HOMEPAGE="http://www.perl.org/"
28 LICENSE="|| ( Artistic GPL-1+ )"
30 KEYWORDS="~alpha ~amd64 ~amd64-fbsd ~amd64-linux ~arm ~arm64 ~hppa ~hppa-hpux ~ia64 ~ia64-hpux ~ia64-linux ~m68k ~m68k-mint ~mips ~ppc ~ppc64 ~ppc-aix ~ppc-macos ~s390 ~sh ~sparc ~sparc64-solaris ~sparc-solaris ~x64-freebsd ~x64-macos ~x64-solaris ~x86 ~x86-fbsd ~x86-freebsd ~x86-interix ~x86-linux ~x86-macos ~x86-solaris"
31 IUSE="berkdb debug doc gdbm ithreads"
34 berkdb? ( sys-libs/db:* )
35 gdbm? ( >=sys-libs/gdbm-1.8.3 )
40 !prefix? ( elibc_FreeBSD? ( sys-freebsd/freebsd-mk-defs ) )
43 >=app-admin/perl-cleaner-2.5
44 >=virtual/perl-File-Temp-0.230.400-r2
45 >=virtual/perl-Data-Dumper-2.154.0
46 virtual/perl-Test-Harness
48 # bug 390719, bug 523624
49 # virtual/perl-Test-Harness is here for the bundled ExtUtils::MakeMaker
51 S="${WORKDIR}/${MY_P}"
54 src_remove_dual perl-core/Archive-Tar 2.40.0 ptar ptardiff ptargrep
55 src_remove_dual perl-core/Digest-SHA 5.950.0 shasum
56 src_remove_dual perl-core/CPAN 2.110.0 cpan
57 src_remove_dual perl-core/Encode 2.800.0 enc2xs piconv
58 src_remove_dual perl-core/ExtUtils-MakeMaker 7.100.100_rc instmodsh
59 src_remove_dual perl-core/ExtUtils-ParseXS 3.310.0 xsubpp
60 src_remove_dual perl-core/IO-Compress 2.69.0 zipdetails
61 src_remove_dual perl-core/JSON-PP 2.273.0 json_pp
62 src_remove_dual perl-core/Module-CoreList 5.201.605.60 corelist
63 src_remove_dual perl-core/Pod-Parser 1.630.0 pod2usage podchecker podselect
64 src_remove_dual perl-core/Pod-Perldoc 3.250.200_rc perldoc
65 src_remove_dual perl-core/Test-Harness 3.360.0 prove
66 src_remove_dual perl-core/podlators 4.70.0 pod2man pod2text
67 src_remove_dual_man perl-core/podlators 4.70.0 /usr/share/man/man1/perlpodstyle.1
71 if has_version "<dev-lang/perl-${SHORT_PV}" ; then
73 ewarn "UPDATE THE PERL MODULES:"
74 ewarn "After updating dev-lang/perl the installed Perl modules"
75 ewarn "have to be re-installed. In most cases, this is done automatically"
76 ewarn "by the package manager, but subsequent steps are still recommended"
77 ewarn "to ensure system consistency."
79 ewarn "You should start with a depclean to remove any unused perl dependencies"
80 ewarn "that may confuse portage in future. Regular depcleans are also encouraged"
81 ewarn "as part of your regular update cycle, as that will keep perl upgrades working."
82 ewarn "Recommended: emerge --depclean -va"
84 ewarn "You should then call perl-cleaner to clean up any old files and trigger any"
85 ewarn "remaining rebuilds portage may have missed."
86 ewarn "Use: perl-cleaner --all"
87 elif has_version dev-lang/perl ; then
88 if ( use ithreads && ! has_version dev-lang/perl[ithreads] ) || \
89 ( ! use ithreads && has_version dev-lang/perl[ithreads] ) || \
90 ( use debug && ! has_version dev-lang/perl[debug] ) || \
91 ( ! use debug && has_version dev-lang/perl[debug] ) ; then
93 ewarn "TOGGLED USE-FLAGS WARNING:"
94 ewarn "You changed one of the use-flags ithreads or debug."
95 ewarn "You must rebuild all perl-modules installed."
96 ewarn "Use: perl-cleaner --modules ; perl-cleaner --force --libperl"
103 *-freebsd*) osname="freebsd" ;;
104 *-dragonfly*) osname="dragonfly" ;;
105 *-netbsd*) osname="netbsd" ;;
106 *-openbsd*) osname="openbsd" ;;
107 *-darwin*) osname="darwin" ;;
108 *-interix*) osname="interix" ;;
109 *-aix*) osname="aix" ;;
110 *-cygwin*) osname="cygwin" ;;
114 myarch="${CHOST%%-*}-${osname}"
118 if use ithreads ; then
123 LIBPERL="libperl$(get_libname ${MY_PV} )"
124 PRIV_LIB="/usr/$(get_libdir)/perl5/${MY_PV}"
125 ARCH_LIB="/usr/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading}"
126 SITE_LIB="/usr/local/$(get_libdir)/perl5/${MY_PV}"
127 SITE_ARCH="/usr/local/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading}"
128 VENDOR_LIB="/usr/$(get_libdir)/perl5/vendor_perl/${MY_PV}"
129 VENDOR_ARCH="/usr/$(get_libdir)/perl5/vendor_perl/${MY_PV}/${myarch}${mythreading}"
134 src_remove_dual_file() {
139 case "${EBUILD_PHASE:-none}" in
142 alternatives_auto_makesym "${i}" "${i}-[0-9]*"
147 if [[ -f ${EROOT}${i} && ! -h ${EROOT}${i} ]] ; then
148 has_version ${pkg} && ewarn "You must reinstall ${pkg} !"
155 if ! [[ -f "${ED}"${i} ]] ; then
156 ewarn "${i} does not exist!"
159 mv "${ED}"${i}{,-${ver}-${P}} || die
165 src_remove_dual_man() {
170 case "${EBUILD_PHASE:-none}" in
173 ff=`echo "${EROOT}${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}}"*`
174 ff=${ff##*${i#${i%.[0-9]}}}
175 alternatives_auto_makesym "${i}${ff}" "${i%.[0-9]}-[0-9]*"
180 if ! [[ -f "${ED}"${i} ]] ; then
181 ewarn "${i} does not exist!"
184 mv "${ED}"${i} "${ED}"${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}} || die
196 src_remove_dual_file "${pkg}" "${ver}" "/usr/bin/${i}"
197 src_remove_dual_man "${pkg}" "${ver}" "/usr/share/man/man1/${i}.1"
201 src_prepare_update_patchlevel_h() {
202 # Copied and modified from debian:
203 # Copyright 2011 Niko Tyni
204 # This program is free software; you can redistribute it and/or modify
205 # it under the same terms as Perl itself.
206 local patchdir="${WORKDIR}/patches"
208 local patchoutput="patchlevel-gentoo.h"
210 [[ -f ${patchdir}/series ]] || return 0
214 patchname=$(echo $patch | sed 's/\.diff$//')
215 < $patchdir/$patch sed -e '/^Subject:/ { N; s/\n / / }' | sed -n -e '
217 # massage the patch headers
218 s|^Bug: .*https\?://rt\.perl\.org/.*id=\(.*\).*|[perl #\1]|; tprepend;
219 s|^Bug: .*https\?://rt\.cpan\.org/.*id=\(.*\).*|[rt.cpan.org #\1]|; tprepend;
220 s|^Bug-Gentoo: ||; tprepend;
221 s/^\(Subject\|Description\): //; tappend;
222 s|^Origin: .*http://perl5\.git\.perl\.org/perl\.git/commit\(diff\)\?/\(.......\).*|[\2]|; tprepend;
224 # post-process at the end of input
226 # include the version number in the patchlevel.h description (if available)
227 s/List packaged patches/&'" for ${PF}(#${PATCH_VER})"'/;
229 # escape any backslashes and double quotes
230 s|\\|\\\\|g; s|"|\\"|g;
233 s|^|\t,"'"$prefix$patchname"' - |;
239 # stop all processing
241 # label: append to the hold space
243 # label: prepend to the hold space
246 done < "${WORKDIR}"/patches/series > "${S}/${patchoutput}"
247 echo "${patchoutput}" >> "${S}/MANIFEST"
253 einfo "Applying patches from ${MY_P}-${PATCH_VER} ..."
254 while read patch ; do
255 EPATCH_SINGLE_MSG=" ${patch} ..."
256 epatch "${WORKDIR}"/patches/${patch}
257 done < "${WORKDIR}"/patches/series
259 src_prepare_update_patchlevel_h
261 if ! tc-is-static-only ; then
262 ln -s ${LIBPERL} libperl$(get_libname ${SHORT_PV}) || die
263 ln -s ${LIBPERL} libperl$(get_libname ) || die
270 # the myconf array is declared in src_configure
271 myconf=( "${myconf[@]}" "$@" )
278 [[ ${COLUMNS:-1} -ge 1 ]] || unset COLUMNS # bug #394091
280 # some arches and -O do not mix :)
281 use ppc && replace-flags -O? -O1
283 # Perl has problems compiling with -Os in your flags with glibc
284 use elibc_uclibc || replace-flags "-Os" "-O2"
286 # This flag makes compiling crash in interesting ways
287 filter-flags "-malign-double"
290 use ppc && filter-flags "-mpowerpc-gpopt"
292 # Fixes bug #143895 on gcc-4.1.1
293 filter-flags "-fsched2-use-superblocks"
295 use sparc && myconf -Ud_longdbl
298 export BZIP2_INCLUDE=${EPREFIX}/usr/include
299 export BZIP2_LIB=${EPREFIX}/usr/$(get_libdir)
301 export BUILD_ZLIB=False
302 export ZLIB_INCLUDE=${EPREFIX}/usr/include
303 export ZLIB_LIB=${EPREFIX}/usr/$(get_libdir)
305 # allow either gdbm to provide ndbm (in <gdbm/ndbm.h>) or db1
315 has_version '=sys-libs/db-1*' && myndbm='D'
318 myconf "-${myndbm}i_ndbm" "-${mygdbm}i_gdbm" "-${mydb}i_db"
320 if use alpha && [[ "$(tc-getCC)" = "ccc" ]] ; then
321 ewarn "Perl will not be built with berkdb support, use gcc if you needed it..."
322 myconf -Ui_db -Ui_ndbm
325 use ithreads && myconf -Dusethreads
330 elif [[ ${CFLAGS} == *-g* ]] ; then
331 myconf -DDEBUGGING=-g
333 myconf -DDEBUGGING=none
336 if [[ -n ${PERL_OLDVERSEN} ]] ; then
337 local inclist=$(for v in ${PERL_OLDVERSEN}; do echo -n "${v}/${myarch}${mythreading} ${v} "; done )
338 myconf -Dinc_version_list="${inclist}"
341 [[ ${ELIBC} == "FreeBSD" ]] && myconf "-Dlibc=/usr/$(get_libdir)/libc.a"
343 # Make sure we can do the final link #523730, need to set deployment
344 # target to override hardcoded 10.3 which breaks on modern OSX
345 [[ ${CHOST} == *-darwin* ]] && \
346 myconf "-Dld=env MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} $(tc-getCC)"
348 # Prefix: the host system needs not to follow Gentoo multilib stuff, and in
349 # Prefix itself we don't do multilib either, so make sure perl can find
350 # something compatible.
352 # Set a hook to check for each detected library whether it actually works.
354 ( echo 'main(){}' > '${T}'/conftest.c &&
355 $(tc-getCC) -o '${T}'/conftest '${T}'/conftest.c -l\$thislib >/dev/null 2>/dev/null
358 # Use all host paths that might contain useful stuff, the hook above will filter out bad choices.
359 local paths="/lib/*-linux-gnu /usr/lib/*-linux-gnu /lib64 /lib/64 /usr/lib64 /usr/lib/64 /lib32 /usr/lib32 /lib /usr/lib"
360 myconf "-Dlibpth=${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir) ${paths}"
361 elif [[ $(get_libdir) != "lib" ]] ; then
362 # We need to use " and not ', as the written config.sh use ' ...
363 myconf "-Dlibpth=/usr/local/$(get_libdir) /$(get_libdir) /usr/$(get_libdir)"
366 # don't try building ODBM, bug #354453
367 disabled_extensions="ODBM_File"
370 # workaround for bug #157774: don't try building GDBM related stuff with USE="-gdbm"
371 disabled_extensions="${disabled_extensions} GDBM_File NDBM_File"
374 myconf -Dnoextensions="${disabled_extensions}"
379 -Darchname="${myarch}" \
381 -Doptimize="${CFLAGS}" \
382 -Dldflags="${LDFLAGS}" \
383 -Dprefix="${EPREFIX}"'/usr' \
384 -Dinstallprefix="${EPREFIX}"'/usr' \
385 -Dsiteprefix="${EPREFIX}"'/usr/local' \
386 -Dvendorprefix="${EPREFIX}"'/usr' \
387 -Dscriptdir="${EPREFIX}"'/usr/bin' \
388 -Dprivlib="${EPREFIX}${PRIV_LIB}" \
389 -Darchlib="${EPREFIX}${ARCH_LIB}" \
390 -Dsitelib="${EPREFIX}${SITE_LIB}" \
391 -Dsitearch="${EPREFIX}${SITE_ARCH}" \
392 -Dvendorlib="${EPREFIX}${VENDOR_LIB}" \
393 -Dvendorarch="${EPREFIX}${VENDOR_ARCH}" \
394 -Dman1dir="${EPREFIX}"/usr/share/man/man1 \
395 -Dman3dir="${EPREFIX}"/usr/share/man/man3 \
396 -Dsiteman1dir="${EPREFIX}"/usr/local/man/man1 \
397 -Dsiteman3dir="${EPREFIX}"/usr/local/man/man3 \
398 -Dvendorman1dir="${EPREFIX}"/usr/share/man/man1 \
399 -Dvendorman3dir="${EPREFIX}"/usr/share/man/man3 \
402 -Dlibperl="${LIBPERL}" \
403 -Dlocincpth="${EPREFIX}"'/usr/include ' \
404 -Dglibpth="${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir)"' ' \
408 -Dmyhostname='localhost' \
409 -Dperladmin='root@localhost' \
410 -Dinstallusrbinperl='n' \
412 -Dsh="${EPREFIX}"/bin/sh \
413 -Dtargetsh="${EPREFIX}"/bin/sh \
415 "${myconf[@]}" || die "Unable to configure"
419 export NO_GENTOO_NETWORK_TESTS=1;
420 if [[ ${EUID} == 0 ]] ; then
421 ewarn "Test fails with a sandbox error (#328793) if run as root. Skipping tests..."
424 use elibc_uclibc && export MAKEOPTS+=" -j1"
425 TEST_JOBS="$(makeopts_jobs)" make test_harness || die "test failed"
430 local coredir="${ARCH_LIB}/CORE"
432 emake DESTDIR="${D}" install
434 rm -f "${ED}/usr/bin/perl${MY_PV}"
435 ln -s perl "${ED}"/usr/bin/perl${MY_PV} || die
437 if ! tc-is-static-only ; then
438 dolib.so "${ED}"${coredir}/${LIBPERL}
439 rm -f "${ED}"${coredir}/${LIBPERL}
440 ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname ${SHORT_PV}) || die
441 ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname) || die
442 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/${LIBPERL} || die
443 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/libperl$(get_libname ${SHORT_PV}) || die
444 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/libperl$(get_libname) || die
447 rm -rf "${ED}"/usr/share/man/man3 || die "Unable to remove module man pages"
449 # This removes ${D} from Config.pm
450 for i in $(find "${D}" -iname "Config.pm" ) ; do
451 einfo "Removing ${D} from ${i}..."
452 sed -i -e "s:${D}::" "${i}" || die "Sed failed"
455 dodoc Changes* README AUTHORS
459 # We expect errors, warnings, and such with the following.
461 dodir /usr/share/doc/${PF}/html
462 LD_LIBRARY_PATH=. ./perl installhtml \
464 --podpath='lib:ext:pod:vms' \
466 --htmldir="${ED}/usr/share/doc/${PF}/html"
469 [[ -d ${ED}/usr/local ]] && rm -r "${ED}"/usr/local
477 if [[ "${ROOT}" = "/" ]] ; then
479 INC=$(perl -e 'for $line (@INC) { next if $line eq "."; next if $line =~ m/'${SHORT_PV}'|etc|local|perl$/; print "$line\n" }')
480 einfo "Removing old .ph files"
481 for DIR in ${INC} ; do
482 if [[ -d "${DIR}" ]] ; then
483 for file in $(find "${DIR}" -name "*.ph" -type f ) ; do
489 # Silently remove the now empty dirs
490 for DIR in ${INC} ; do
491 if [[ -d "${DIR}" ]] ; then
492 find "${DIR}" -depth -type d -print0 | xargs -0 -r rmdir &> /dev/null