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 you should still call perl-cleaner to"
77 ewarn "make sure your system is consistent."
78 ewarn "Use: perl-cleaner --all"
79 elif has_version dev-lang/perl ; then
80 if ( use ithreads && ! has_version dev-lang/perl[ithreads] ) || \
81 ( ! use ithreads && has_version dev-lang/perl[ithreads] ) || \
82 ( use debug && ! has_version dev-lang/perl[debug] ) || \
83 ( ! use debug && has_version dev-lang/perl[debug] ) ; then
85 ewarn "TOGGLED USE-FLAGS WARNING:"
86 ewarn "You changed one of the use-flags ithreads or debug."
87 ewarn "You must rebuild all perl-modules installed."
88 ewarn "Use: perl-cleaner --modules ; perl-cleaner --force --libperl"
95 *-freebsd*) osname="freebsd" ;;
96 *-dragonfly*) osname="dragonfly" ;;
97 *-netbsd*) osname="netbsd" ;;
98 *-openbsd*) osname="openbsd" ;;
99 *-darwin*) osname="darwin" ;;
100 *-interix*) osname="interix" ;;
101 *-aix*) osname="aix" ;;
102 *-cygwin*) osname="cygwin" ;;
106 myarch="${CHOST%%-*}-${osname}"
110 if use ithreads ; then
115 LIBPERL="libperl$(get_libname ${MY_PV} )"
116 PRIV_LIB="/usr/$(get_libdir)/perl5/${MY_PV}"
117 ARCH_LIB="/usr/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading}"
118 SITE_LIB="/usr/local/$(get_libdir)/perl5/${MY_PV}"
119 SITE_ARCH="/usr/local/$(get_libdir)/perl5/${MY_PV}/${myarch}${mythreading}"
120 VENDOR_LIB="/usr/$(get_libdir)/perl5/vendor_perl/${MY_PV}"
121 VENDOR_ARCH="/usr/$(get_libdir)/perl5/vendor_perl/${MY_PV}/${myarch}${mythreading}"
126 src_remove_dual_file() {
131 case "${EBUILD_PHASE:-none}" in
134 alternatives_auto_makesym "${i}" "${i}-[0-9]*"
139 if [[ -f ${EROOT}${i} && ! -h ${EROOT}${i} ]] ; then
140 has_version ${pkg} && ewarn "You must reinstall ${pkg} !"
147 if ! [[ -f "${ED}"${i} ]] ; then
148 ewarn "${i} does not exist!"
151 mv "${ED}"${i}{,-${ver}-${P}} || die
157 src_remove_dual_man() {
162 case "${EBUILD_PHASE:-none}" in
165 ff=`echo "${EROOT}${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}}"*`
166 ff=${ff##*${i#${i%.[0-9]}}}
167 alternatives_auto_makesym "${i}${ff}" "${i%.[0-9]}-[0-9]*"
172 if ! [[ -f "${ED}"${i} ]] ; then
173 ewarn "${i} does not exist!"
176 mv "${ED}"${i} "${ED}"${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}} || die
188 src_remove_dual_file "${pkg}" "${ver}" "/usr/bin/${i}"
189 src_remove_dual_man "${pkg}" "${ver}" "/usr/share/man/man1/${i}.1"
193 src_prepare_update_patchlevel_h() {
194 # Copied and modified from debian:
195 # Copyright 2011 Niko Tyni
196 # This program is free software; you can redistribute it and/or modify
197 # it under the same terms as Perl itself.
198 local patchdir="${WORKDIR}/patches"
200 local patchoutput="patchlevel-gentoo.h"
202 [[ -f ${patchdir}/series ]] || return 0
206 patchname=$(echo $patch | sed 's/\.diff$//')
207 < $patchdir/$patch sed -e '/^Subject:/ { N; s/\n / / }' | sed -n -e '
209 # massage the patch headers
210 s|^Bug: .*https\?://rt\.perl\.org/.*id=\(.*\).*|[perl #\1]|; tprepend;
211 s|^Bug: .*https\?://rt\.cpan\.org/.*id=\(.*\).*|[rt.cpan.org #\1]|; tprepend;
212 s|^Bug-Gentoo: ||; tprepend;
213 s/^\(Subject\|Description\): //; tappend;
214 s|^Origin: .*http://perl5\.git\.perl\.org/perl\.git/commit\(diff\)\?/\(.......\).*|[\2]|; tprepend;
216 # post-process at the end of input
218 # include the version number in the patchlevel.h description (if available)
219 s/List packaged patches/&'" for ${PF}(#${PATCH_VER})"'/;
221 # escape any backslashes and double quotes
222 s|\\|\\\\|g; s|"|\\"|g;
225 s|^|\t,"'"$prefix$patchname"' - |;
231 # stop all processing
233 # label: append to the hold space
235 # label: prepend to the hold space
238 done < "${WORKDIR}"/patches/series > "${S}/${patchoutput}"
239 echo "${patchoutput}" >> "${S}/MANIFEST"
245 einfo "Applying patches from ${MY_P}-${PATCH_VER} ..."
246 while read patch ; do
247 EPATCH_SINGLE_MSG=" ${patch} ..."
248 epatch "${WORKDIR}"/patches/${patch}
249 done < "${WORKDIR}"/patches/series
251 src_prepare_update_patchlevel_h
253 if ! tc-is-static-only ; then
254 ln -s ${LIBPERL} libperl$(get_libname ${SHORT_PV}) || die
255 ln -s ${LIBPERL} libperl$(get_libname ) || die
262 # the myconf array is declared in src_configure
263 myconf=( "${myconf[@]}" "$@" )
270 [[ ${COLUMNS:-1} -ge 1 ]] || unset COLUMNS # bug #394091
272 # some arches and -O do not mix :)
273 use ppc && replace-flags -O? -O1
275 # Perl has problems compiling with -Os in your flags with glibc
276 use elibc_uclibc || replace-flags "-Os" "-O2"
278 # This flag makes compiling crash in interesting ways
279 filter-flags "-malign-double"
282 use ppc && filter-flags "-mpowerpc-gpopt"
284 # Fixes bug #143895 on gcc-4.1.1
285 filter-flags "-fsched2-use-superblocks"
287 use sparc && myconf -Ud_longdbl
290 export BZIP2_INCLUDE=${EPREFIX}/usr/include
291 export BZIP2_LIB=${EPREFIX}/usr/$(get_libdir)
293 export BUILD_ZLIB=False
294 export ZLIB_INCLUDE=${EPREFIX}/usr/include
295 export ZLIB_LIB=${EPREFIX}/usr/$(get_libdir)
297 # allow either gdbm to provide ndbm (in <gdbm/ndbm.h>) or db1
307 has_version '=sys-libs/db-1*' && myndbm='D'
310 myconf "-${myndbm}i_ndbm" "-${mygdbm}i_gdbm" "-${mydb}i_db"
312 if use alpha && [[ "$(tc-getCC)" = "ccc" ]] ; then
313 ewarn "Perl will not be built with berkdb support, use gcc if you needed it..."
314 myconf -Ui_db -Ui_ndbm
317 use ithreads && myconf -Dusethreads
322 elif [[ ${CFLAGS} == *-g* ]] ; then
323 myconf -DDEBUGGING=-g
325 myconf -DDEBUGGING=none
328 if [[ -n ${PERL_OLDVERSEN} ]] ; then
329 local inclist=$(for v in ${PERL_OLDVERSEN}; do echo -n "${v}/${myarch}${mythreading} ${v} "; done )
330 myconf -Dinc_version_list="${inclist}"
333 [[ ${ELIBC} == "FreeBSD" ]] && myconf "-Dlibc=/usr/$(get_libdir)/libc.a"
335 # Make sure we can do the final link #523730, need to set deployment
336 # target to override hardcoded 10.3 which breaks on modern OSX
337 [[ ${CHOST} == *-darwin* ]] && \
338 myconf "-Dld=env MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} $(tc-getCC)"
340 # Prefix: the host system needs not to follow Gentoo multilib stuff, and in
341 # Prefix itself we don't do multilib either, so make sure perl can find
342 # something compatible.
344 # Set a hook to check for each detected library whether it actually works.
346 ( echo 'main(){}' > '${T}'/conftest.c &&
347 $(tc-getCC) -o '${T}'/conftest '${T}'/conftest.c -l\$thislib >/dev/null 2>/dev/null
350 # Use all host paths that might contain useful stuff, the hook above will filter out bad choices.
351 local paths="/lib/*-linux-gnu /usr/lib/*-linux-gnu /lib64 /lib/64 /usr/lib64 /usr/lib/64 /lib32 /usr/lib32 /lib /usr/lib"
352 myconf "-Dlibpth=${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir) ${paths}"
353 elif [[ $(get_libdir) != "lib" ]] ; then
354 # We need to use " and not ', as the written config.sh use ' ...
355 myconf "-Dlibpth=/usr/local/$(get_libdir) /$(get_libdir) /usr/$(get_libdir)"
358 # don't try building ODBM, bug #354453
359 disabled_extensions="ODBM_File"
362 # workaround for bug #157774: don't try building GDBM related stuff with USE="-gdbm"
363 disabled_extensions="${disabled_extensions} GDBM_File NDBM_File"
366 myconf -Dnoextensions="${disabled_extensions}"
371 -Darchname="${myarch}" \
373 -Doptimize="${CFLAGS}" \
374 -Dldflags="${LDFLAGS}" \
375 -Dprefix="${EPREFIX}"'/usr' \
376 -Dinstallprefix="${EPREFIX}"'/usr' \
377 -Dsiteprefix="${EPREFIX}"'/usr/local' \
378 -Dvendorprefix="${EPREFIX}"'/usr' \
379 -Dscriptdir="${EPREFIX}"'/usr/bin' \
380 -Dprivlib="${EPREFIX}${PRIV_LIB}" \
381 -Darchlib="${EPREFIX}${ARCH_LIB}" \
382 -Dsitelib="${EPREFIX}${SITE_LIB}" \
383 -Dsitearch="${EPREFIX}${SITE_ARCH}" \
384 -Dvendorlib="${EPREFIX}${VENDOR_LIB}" \
385 -Dvendorarch="${EPREFIX}${VENDOR_ARCH}" \
386 -Dman1dir="${EPREFIX}"/usr/share/man/man1 \
387 -Dman3dir="${EPREFIX}"/usr/share/man/man3 \
388 -Dsiteman1dir="${EPREFIX}"/usr/local/man/man1 \
389 -Dsiteman3dir="${EPREFIX}"/usr/local/man/man3 \
390 -Dvendorman1dir="${EPREFIX}"/usr/share/man/man1 \
391 -Dvendorman3dir="${EPREFIX}"/usr/share/man/man3 \
394 -Dlibperl="${LIBPERL}" \
395 -Dlocincpth="${EPREFIX}"'/usr/include ' \
396 -Dglibpth="${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir)"' ' \
400 -Dmyhostname='localhost' \
401 -Dperladmin='root@localhost' \
402 -Dinstallusrbinperl='n' \
404 -Dsh="${EPREFIX}"/bin/sh \
405 -Dtargetsh="${EPREFIX}"/bin/sh \
407 "${myconf[@]}" || die "Unable to configure"
411 export NO_GENTOO_NETWORK_TESTS=1;
412 if [[ ${EUID} == 0 ]] ; then
413 ewarn "Test fails with a sandbox error (#328793) if run as root. Skipping tests..."
416 use elibc_uclibc && export MAKEOPTS+=" -j1"
417 TEST_JOBS="$(makeopts_jobs)" make test_harness || die "test failed"
422 local coredir="${ARCH_LIB}/CORE"
424 emake DESTDIR="${D}" install
426 rm -f "${ED}/usr/bin/perl${MY_PV}"
427 ln -s perl "${ED}"/usr/bin/perl${MY_PV} || die
429 if ! tc-is-static-only ; then
430 dolib.so "${ED}"${coredir}/${LIBPERL}
431 rm -f "${ED}"${coredir}/${LIBPERL}
432 ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname ${SHORT_PV}) || die
433 ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname) || die
434 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/${LIBPERL} || die
435 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/libperl$(get_libname ${SHORT_PV}) || die
436 ln -sf ../../../../../$(get_libdir)/${LIBPERL} "${ED}"${coredir}/libperl$(get_libname) || die
439 rm -rf "${ED}"/usr/share/man/man3 || die "Unable to remove module man pages"
441 # This removes ${D} from Config.pm
442 for i in $(find "${D}" -iname "Config.pm" ) ; do
443 einfo "Removing ${D} from ${i}..."
444 sed -i -e "s:${D}::" "${i}" || die "Sed failed"
447 dodoc Changes* README AUTHORS
451 # We expect errors, warnings, and such with the following.
453 dodir /usr/share/doc/${PF}/html
454 LD_LIBRARY_PATH=. ./perl installhtml \
456 --podpath='lib:ext:pod:vms' \
458 --htmldir="${ED}/usr/share/doc/${PF}/html"
461 [[ -d ${ED}/usr/local ]] && rm -r "${ED}"/usr/local
469 if [[ "${ROOT}" = "/" ]] ; then
471 INC=$(perl -e 'for $line (@INC) { next if $line eq "."; next if $line =~ m/'${SHORT_PV}'|etc|local|perl$/; print "$line\n" }')
472 einfo "Removing old .ph files"
473 for DIR in ${INC} ; do
474 if [[ -d "${DIR}" ]] ; then
475 for file in $(find "${DIR}" -name "*.ph" -type f ) ; do
481 # Silently remove the now empty dirs
482 for DIR in ${INC} ; do
483 if [[ -d "${DIR}" ]] ; then
484 find "${DIR}" -depth -type d -print0 | xargs -0 -r rmdir &> /dev/null