blob: 88a1c9665a699c7b2195e3e0541cee1f6f70d8a9 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001SUMMARY = "Perl scripting language"
2HOMEPAGE = "http://www.perl.org/"
3SECTION = "devel"
4LICENSE = "Artistic-1.0 | GPL-1.0+"
5LIC_FILES_CHKSUM = "file://Copying;md5=5b122a36d0f6dc55279a0ebc69f3c60b \
6 file://Artistic;md5=71a4d5d9acc18c0952a6df2218bb68da \
7 "
8
9
10SRC_URI = "https://www.cpan.org/src/5.0/perl-${PV}.tar.gz;name=perl \
11 https://github.com/arsv/perl-cross/releases/download/1.3.2/perl-cross-1.3.2.tar.gz;name=perl-cross \
12 file://perl-rdepends.txt \
13 file://0001-configure_tool.sh-do-not-quote-the-argument-to-comma.patch \
14 file://0001-ExtUtils-MakeMaker-add-LDFLAGS-when-linking-binary-m.patch \
15 file://0001-Somehow-this-module-breaks-through-the-perl-wrapper-.patch \
16 file://errno_ver.diff \
17 file://native-perlinc.patch \
18 file://0001-perl-cross-add-LDFLAGS-when-linking-libperl.patch \
19 file://perl-dynloader.patch \
20 file://0001-configure_path.sh-do-not-hardcode-prefix-lib-as-libr.patch \
21 file://0001-enc2xs-Add-environment-variable-to-suppress-comments.patch \
22 file://0002-Constant-Fix-up-shebang.patch \
23 file://0001-PATCH-perl-134117-Close-DATA-in-loc_tools.pl.patch \
24 file://determinism.patch \
25 "
26SRC_URI_append_class-native = " \
27 file://perl-configpm-switch.patch \
28"
29SRC_URI_append_class-target = " \
30 file://encodefix.patch \
31"
32
33SRC_URI[perl.sha256sum] = "66db7df8a91979eb576fac91743644da878244cf8ee152f02cd6f5cd7a731689"
34SRC_URI[perl-cross.sha256sum] = "defa12f0ad7be0b6c48b4f76e2fb5b37c1b37fbeb6e9ebe938279cd539a0c20c"
35
36S = "${WORKDIR}/perl-${PV}"
37
38inherit upstream-version-is-even update-alternatives
39
40DEPENDS += "zlib virtual/crypt"
41
42PERL_LIB_VER = "${@'.'.join(d.getVar('PV').split('.')[0:2])}.0"
43
44PACKAGECONFIG ??= "bdb gdbm"
45PACKAGECONFIG[bdb] = ",-Ui_db,db"
46PACKAGECONFIG[gdbm] = ",-Ui_gdbm,gdbm"
47
48# Don't generate comments in enc2xs output files. They are not reproducible
49export ENC2XS_NO_COMMENTS = "1"
50
51do_unpack_append() {
52 bb.build.exec_func('do_copy_perlcross', d)
53}
54
55do_copy_perlcross() {
56 cp -rfp ${WORKDIR}/perl-cross*/* ${S}
57}
58
59do_configure_class-target() {
60 ./configure --prefix=${prefix} --libdir=${libdir} \
61 --target=${TARGET_SYS} \
62 -Duseshrplib \
63 -Dsoname=libperl.so.5 \
64 -Dvendorprefix=${prefix} \
65 -Darchlibexp=${STAGING_LIBDIR}/perl5/${PV}/${TARGET_ARCH}-linux \
66 ${PACKAGECONFIG_CONFARGS}
67
68 #perl.c uses an ARCHLIB_EXP define to generate compile-time code that
69 #adds the archlibexp path to @INC during run-time initialization of a
70 #new perl interpreter.
71
72 #Because we've changed this value in a temporary way to make it
73 #possible to use ExtUtils::Embed in the target build (the temporary
74 #value in config.sh gets re-stripped out during packaging), the
75 #ARCHLIB_EXP value that gets generated still uses the temporary version
76 #instead of the original expected version (i.e. becauses it's in the
77 #generated config.h, it doesn't get stripped out during packaging like
78 #the others in config.sh).
79
80 sed -i -e "s,${STAGING_LIBDIR},${libdir},g" config.h
81}
82
83do_configure_class-nativesdk() {
84 ./configure --prefix=${prefix} \
85 --target=${TARGET_SYS} \
86 -Duseshrplib \
87 -Dsoname=libperl.so.5 \
88 -Dvendorprefix=${prefix} \
89 -Darchlibexp=${STAGING_LIBDIR}/perl5/${PV}/${TARGET_ARCH}-linux \
90 ${PACKAGECONFIG_CONFARGS}
91
92 # See the comment above
93 sed -i -e "s,${STAGING_LIBDIR},${libdir},g" config.h
94}
95
96do_configure_class-native() {
97 ./configure --prefix=${prefix} \
98 -Dbin=${bindir}/perl-native \
99 -Duseshrplib \
100 -Dsoname=libperl.so.5 \
101 -Dvendorprefix=${prefix} \
102 -Ui_xlocale \
103 ${PACKAGECONFIG_CONFARGS}
104}
105
106do_configure_append() {
107 if [ -n "$SOURCE_DATE_EPOCH" ]; then
108 PERL_BUILD_DATE="$(${PYTHON} -c "\
109from datetime import datetime, timezone; \
110print(datetime.fromtimestamp($SOURCE_DATE_EPOCH, timezone.utc).strftime('%a %b %d %H:%M:%S %Y')) \
111 ")"
112 echo "#define PERL_BUILD_DATE \"$PERL_BUILD_DATE\"" >> config.h
113 fi
114}
115
116do_compile() {
117 oe_runmake
118 # This isn't generated reliably so delete and re-generate.
119 # https://github.com/arsv/perl-cross/issues/86
120
121 if [ -e pod/perltoc.pod ]; then
122 bbnote Rebuilding perltoc.pod
123 rm -f pod/perltoc.pod
124 oe_runmake pod/perltoc.pod
125 fi
126}
127
128do_install() {
129 oe_runmake 'DESTDIR=${D}' install
130
131 install -d ${D}${libdir}/perl5
132 install -d ${D}${libdir}/perl5/${PV}/
133 install -d ${D}${libdir}/perl5/${PV}/ExtUtils/
134
135 # Save native config
136 install config.sh ${D}${libdir}/perl5
137 install lib/Config.pm ${D}${libdir}/perl5/${PV}/
138 install lib/ExtUtils/typemap ${D}${libdir}/perl5/${PV}/ExtUtils/
139
140 # Fix up shared library
141 rm ${D}/${libdir}/perl5/${PV}/*/CORE/libperl.so
142 ln -sf ../../../../libperl.so.${PERL_LIB_VER} $(echo ${D}/${libdir}/perl5/${PV}/*/CORE)/libperl.so
143}
144
145do_install_append_class-target() {
146 # This is used to substitute target configuration when running native perl via perl-configpm-switch.patch
147 ln -s Config_heavy.pl ${D}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_heavy-target.pl
148
149 # This contains host-specific information used for building miniperl (a helper executable built with host compiler)
150 # and therefore isn't reproducible. I believe the file isn't actually needed on target.
151 rm ${D}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/CORE/xconfig.h
152}
153
154do_install_append_class-nativesdk() {
155 # This is used to substitute target configuration when running native perl via perl-configpm-switch.patch
156 ln -s Config_heavy.pl ${D}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_heavy-target.pl
157
158 create_wrapper ${D}${bindir}/perl \
Andrew Geisslerd25ed322020-06-27 00:28:28 -0500159 PERL5LIB='$PERL5LIB:${SDKPATHNATIVE}/${libdir_nativesdk}/perl5/site_perl/${PV}:${SDKPATHNATIVE}/${libdir_nativesdk}/perl5/vendor_perl/${PV}:${SDKPATHNATIVE}/${libdir_nativesdk}/perl5/${PV}'
Andrew Geissler82c905d2020-04-13 13:39:40 -0500160}
161
162do_install_append_class-native () {
163 # Those wrappers mean that perl installed from sstate (which may change
164 # path location) works and that in the nativesdk case, the SDK can be
165 # installed to a different location from the one it was built for.
166 create_wrapper ${D}${bindir}/perl-native/perl PERL5LIB='$PERL5LIB:${STAGING_LIBDIR}/perl5/site_perl/${PV}:${STAGING_LIBDIR}/perl5/vendor_perl/${PV}:${STAGING_LIBDIR}/perl5/${PV}'
167
168 # Use /usr/bin/env nativeperl for the perl script.
169 for f in `grep -Il '#! *${bindir}/perl' ${D}/${bindir}/*`; do
170 sed -i -e 's|${bindir}/perl|/usr/bin/env nativeperl|' $f
171 done
172}
173
174PACKAGE_PREPROCESS_FUNCS += "perl_package_preprocess"
175
176perl_package_preprocess () {
177 # Fix up installed configuration
178 sed -i -e "s,${D},,g" \
179 -e "s,${DEBUG_PREFIX_MAP},,g" \
180 -e "s,--sysroot=${STAGING_DIR_HOST},,g" \
181 -e "s,-isystem${STAGING_INCDIR} ,,g" \
182 -e "s,${STAGING_LIBDIR},${libdir},g" \
183 -e "s,${STAGING_BINDIR},${bindir},g" \
184 -e "s,${STAGING_INCDIR},${includedir},g" \
185 -e "s,${STAGING_BINDIR_NATIVE}/perl-native/,${bindir}/,g" \
186 -e "s,${STAGING_BINDIR_NATIVE}/,,g" \
187 -e "s,${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX},${bindir},g" \
188 -e 's:${RECIPE_SYSROOT}::g' \
189 ${PKGD}${bindir}/h2xs.perl \
190 ${PKGD}${bindir}/h2ph.perl \
191 ${PKGD}${bindir}/pod2man.perl \
192 ${PKGD}${bindir}/pod2text.perl \
193 ${PKGD}${bindir}/pod2usage.perl \
194 ${PKGD}${bindir}/podchecker.perl \
195 ${PKGD}${bindir}/podselect.perl \
196 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/CORE/config.h \
197 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/CORE/perl.h \
198 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/CORE/pp.h \
199 ${PKGD}${libdir}/perl5/${PV}/Config.pm \
200 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config.pm \
201 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config.pod \
202 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_git.pl \
203 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_heavy.pl \
204 ${PKGD}${libdir}/perl5/${PV}/ExtUtils/Liblist/Kid.pm \
205 ${PKGD}${libdir}/perl5/${PV}/FileCache.pm \
206 ${PKGD}${libdir}/perl5/${PV}/pod/*.pod \
207 ${PKGD}${libdir}/perl5/config.sh
208}
209
210inherit update-alternatives
211
212ALTERNATIVE_PRIORITY = "100"
213
214ALTERNATIVE_${PN}-misc = "corelist cpan enc2xs encguess h2ph h2xs instmodsh json_pp libnetcfg \
215 piconv pl2pm pod2html pod2man pod2text pod2usage podchecker podselect \
216 prove ptar ptardiff ptargrep shasum splain xsubpp zipdetails"
217ALTERNATIVE_LINK_NAME[corelist] = "${bindir}/corelist"
218ALTERNATIVE_LINK_NAME[cpan] = "${bindir}/cpan"
219ALTERNATIVE_LINK_NAME[enc2xs] = "${bindir}/enc2xs"
220ALTERNATIVE_LINK_NAME[encguess] = "${bindir}/encguess"
221ALTERNATIVE_LINK_NAME[h2ph] = "${bindir}/h2ph"
222ALTERNATIVE_LINK_NAME[h2xs] = "${bindir}/h2xs"
223ALTERNATIVE_LINK_NAME[instmodsh] = "${bindir}/instmodsh"
224ALTERNATIVE_LINK_NAME[json_pp] = "${bindir}/json_pp"
225ALTERNATIVE_LINK_NAME[libnetcfg] = "${bindir}/libnetcfg"
226ALTERNATIVE_LINK_NAME[piconv] = "${bindir}/piconv"
227ALTERNATIVE_LINK_NAME[pl2pm] = "${bindir}/pl2pm"
228ALTERNATIVE_LINK_NAME[pod2html] = "${bindir}/pod2html"
229ALTERNATIVE_LINK_NAME[pod2man] = "${bindir}/pod2man"
230ALTERNATIVE_LINK_NAME[pod2text] = "${bindir}/pod2text"
231ALTERNATIVE_LINK_NAME[pod2usage] = "${bindir}/pod2usage"
232ALTERNATIVE_LINK_NAME[podchecker] = "${bindir}/podchecker"
233ALTERNATIVE_LINK_NAME[podselect] = "${bindir}/podselect"
234ALTERNATIVE_LINK_NAME[prove] = "${bindir}/prove"
235ALTERNATIVE_LINK_NAME[ptar] = "${bindir}/ptar"
236ALTERNATIVE_LINK_NAME[ptardiff] = "${bindir}/ptardiff"
237ALTERNATIVE_LINK_NAME[ptargrep] = "${bindir}/ptargrep"
238ALTERNATIVE_LINK_NAME[shasum] = "${bindir}/shasum"
239ALTERNATIVE_LINK_NAME[splain] = "${bindir}/splain"
240ALTERNATIVE_LINK_NAME[xsubpp] = "${bindir}/xsubpp"
241ALTERNATIVE_LINK_NAME[zipdetails] = "${bindir}/zipdetails"
242
243require perl-ptest.inc
244
245FILES_${PN} = "${bindir}/perl ${bindir}/perl.real ${bindir}/perl${PV} ${libdir}/libperl.so* \
246 ${libdir}/perl5/site_perl \
247 ${libdir}/perl5/${PV}/Config.pm \
248 ${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config.pm \
249 ${libdir}/perl5/${PV}/*/Config_git.pl \
250 ${libdir}/perl5/${PV}/*/Config_heavy-target.pl \
251 ${libdir}/perl5/config.sh \
252 ${libdir}/perl5/${PV}/strict.pm \
253 ${libdir}/perl5/${PV}/warnings.pm \
254 ${libdir}/perl5/${PV}/warnings \
255 ${libdir}/perl5/${PV}/vars.pm \
256 ${libdir}/perl5/site_perl \
257 ${libdir}/perl5/${PV}/ExtUtils/MANIFEST.SKIP \
258 ${libdir}/perl5/${PV}/ExtUtils/xsubpp \
259 ${libdir}/perl5/${PV}/ExtUtils/typemap \
260 "
261RPROVIDES_${PN} += "perl-module-strict perl-module-vars perl-module-config perl-module-warnings \
262 perl-module-warnings-register"
263
264FILES_${PN}-staticdev_append = " ${libdir}/perl5/${PV}/*/CORE/libperl.a"
265
266FILES_${PN}-dev_append = " ${libdir}/perl5/${PV}/*/CORE"
267
268FILES_${PN}-doc_append = " ${libdir}/perl5/${PV}/Unicode/Collate/*.txt \
269 ${libdir}/perl5/${PV}/*/.packlist \
270 ${libdir}/perl5/${PV}/Encode/encode.h \
271 "
272PACKAGES += "${PN}-misc"
273
274FILES_${PN}-misc = "${bindir}/*"
275
276PACKAGES += "${PN}-pod"
277
278FILES_${PN}-pod = "${libdir}/perl5/${PV}/pod \
279 ${libdir}/perl5/${PV}/*.pod \
280 ${libdir}/perl5/${PV}/*/*.pod \
281 ${libdir}/perl5/${PV}/*/*/*.pod \
282 ${libdir}/perl5/${PV}/*/*/*/*.pod \
283 "
284
285PACKAGES += "${PN}-module-cpan ${PN}-module-unicore"
286
287FILES_${PN}-module-cpan += "${libdir}/perl5/${PV}/CPAN \
288 "
289FILES_${PN}-module-unicore += "${libdir}/perl5/${PV}/unicore"
290
291ALTERNATIVE_PRIORITY = "40"
292ALTERNATIVE_${PN}-doc = "Thread.3"
293ALTERNATIVE_LINK_NAME[Thread.3] = "${mandir}/man3/Thread.3"
294
295# Create a perl-modules package recommending all the other perl
296# packages (actually the non modules packages and not created too)
297ALLOW_EMPTY_${PN}-modules = "1"
298PACKAGES += "${PN}-modules "
299
300PACKAGESPLITFUNCS_prepend = "split_perl_packages "
301
302python split_perl_packages () {
303 libdir = d.expand('${libdir}/perl5/${PV}')
304 do_split_packages(d, libdir, r'.*/auto/([^.]*)/[^/]*\.(so|ld|ix|al)', '${PN}-module-%s', 'perl module %s', recursive=True, match_path=True, prepend=False)
305 do_split_packages(d, libdir, r'.*linux/([^\/]*)\.pm', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
306 do_split_packages(d, libdir, r'Module/([^\/]*)\.pm', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
307 do_split_packages(d, libdir, r'Module/([^\/]*)/.*', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
308 do_split_packages(d, libdir, r'.*linux/([^\/].*)\.(pm|pl|e2x)', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
Andrew Geisslerd25ed322020-06-27 00:28:28 -0500309 do_split_packages(d, libdir, r'(^(?!(CPAN\/|CPANPLUS\/|Module\/|unicore\/|.*linux\/)[^\/]).*)\.(pm|pl|e2x)', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500310
311 # perl-modules should recommend every perl module, and only the
312 # modules. Don't attempt to use the result of do_split_packages() as some
313 # modules are manually split (eg. perl-module-unicore).
314 packages = filter(lambda p: 'perl-module-' in p, d.getVar('PACKAGES').split())
315 d.setVar(d.expand("RRECOMMENDS_${PN}-modules"), ' '.join(packages))
316
317 # Read the pre-generated dependency file, and use it to set module dependecies
318 for line in open(d.expand("${WORKDIR}") + '/perl-rdepends.txt').readlines():
319 splitline = line.split()
320 if bb.data.inherits_class('native', d):
321 module = splitline[0] + '-native'
322 depends = "perl-native"
323 else:
324 module = splitline[0].replace("RDEPENDS_perl", "RDEPENDS_${PN}")
325 depends = splitline[2].strip('"').replace("perl-module", "${PN}-module")
326 d.appendVar(d.expand(module), " " + depends)
327}
328
329python() {
330 if d.getVar('CLASSOVERRIDE') == "class-target":
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500331 d.setVar("PACKAGES_DYNAMIC", "^${MLPREFIX}perl-module-.*(?<!native)$")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500332 elif d.getVar('CLASSOVERRIDE') == "class-native":
333 d.setVar("PACKAGES_DYNAMIC", "^perl-module-.*-native$")
334 elif d.getVar('CLASSOVERRIDE') == "class-nativesdk":
335 d.setVar("PACKAGES_DYNAMIC", "^nativesdk-perl-module-.*")
336}
337
338RDEPENDS_${PN}-misc += "perl perl-modules"
339RDEPENDS_${PN}-pod += "perl"
340
341BBCLASSEXTEND = "native nativesdk"
342
343SSTATE_SCAN_FILES += "*.pm *.pod *.h *.pl *.sh"
344
345do_create_rdepends_inc() {
346 cd ${WORKDIR}
347 cat <<'EOPREAMBLE' > ${WORKDIR}/perl-rdepends.inc
348
349# Some additional dependencies that the above doesn't manage to figure out
350RDEPENDS_${PN}-module-file-spec += "${PN}-module-file-spec-unix"
351RDEPENDS_${PN}-module-math-bigint += "${PN}-module-math-bigint-calc"
352RDEPENDS_${PN}-module-thread-queue += "${PN}-module-attributes"
353RDEPENDS_${PN}-module-overload += "${PN}-module-overloading"
354
355# Generated depends list beyond this line
356EOPREAMBLE
357 test -e packages-split.new && rm -rf packages-split.new
358 cp -r packages-split packages-split.new && cd packages-split.new
359 find . -name \*.pm | xargs sed -i '/^=head/,/^=cut/d'
360 egrep -r "^\s*(\<use .*|\<require .*);?" perl-module-* --include="*.pm" | \
361 sed "s/\/.*\.pm: */ += /g;s/[\"\']//g;s/;.*/\"/g;s/+= .*\(require\|use\)\> */+= \"perl-module-/g;s/CPANPLUS::.*/cpanplus/g;s/CPAN::.*/cpan/g;s/::/-/g;s/ [^+\"].*//g;s/_/-/g;s/\.pl\"$/\"/;s/\"\?\$/\"/;s/(//;" | tr [:upper:] [:lower:] | \
362 awk '{if ($3 != "\x22"$1"\x22"){ print $0}}'| \
363 grep -v -e "\-vms\-" -e module-5 -e "^$" -e "\\$" -e your -e tk -e autoperl -e html -e http -e parse-cpan -e perl-ostype -e ndbm-file -e module-mac -e fcgi -e lwp -e dbd -e dbix | \
364 sort -u | \
365 sed 's/^/RDEPENDS_/;s/perl-module-/${PN}-module-/g;s/module-\(module-\)/\1/g;s/\(module-load\)-conditional/\1/g;s/encode-configlocal/&-pm/;' | \
366 egrep -wv '=>|module-a|module-apache.?|module-apr|module-authen-sasl|module-b-asmdata|module-convert-ebcdic|module-devel-size|module-digest-perl-md5|module-dumpvalue|module-extutils-constant-aaargh56hash|module-extutils-xssymset|module-file-bsdglob|module-for|module-it|module-io-socket-inet6|module-io-socket-ssl|module-io-string|module-ipc-system-simple|module-lexical|module-local-lib|metadata|module-modperl-util|module-pluggable-object|module-test-builder-io-scalar|module-test2|module-text-unidecode|module-unicore|module-win32|objects\sload|syscall.ph|systeminfo.ph|%s' | \
367 egrep -wv '=>|module-algorithm-diff|module-carp|module-c<extutils-mm-unix>|module-encode-hanextra|module-extutils-makemaker-version-regex|module-file-spec|module-io-compress-lzma|module-locale-maketext-lexicon|module-log-agent|module-meta-notation|module-net-localcfg|module-net-ping-external|module-b-deparse|module-scalar-util|module-some-module|module-symbol|module-uri|module-win32api-file' >> ${WORKDIR}/perl-rdepends.generated
368 cp ${WORKDIR}/perl-rdepends.generated ${THISDIR}/files/perl-rdepends.txt
369}
370
371# bitbake perl -c create_rdepends_inc
372addtask do_create_rdepends_inc
373
374SYSROOT_PREPROCESS_FUNCS += "perl_sysroot_create_wrapper"
375
376perl_sysroot_create_wrapper () {
377 mkdir -p ${SYSROOT_DESTDIR}${bindir}
378 # Create a wrapper that /usr/bin/env perl will use to get perl-native.
379 # This MUST live in the normal bindir.
380 cat > ${SYSROOT_DESTDIR}${bindir}/nativeperl << EOF
381#!/bin/sh
382realpath=\`readlink -fn \$0\`
383exec \`dirname \$realpath\`/perl-native/perl "\$@"
384EOF
385 chmod 0755 ${SYSROOT_DESTDIR}${bindir}/nativeperl
386 cat ${SYSROOT_DESTDIR}${bindir}/nativeperl
387}