blob: b18a6b691318af95cbcc967241fe1b8252c5f624 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001SUMMARY = "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 \
Brad Bishop15ae2502019-06-18 21:44:24 -040011 https://github.com/arsv/perl-cross/releases/download/1.3/perl-cross-1.3.tar.gz;name=perl-cross \
Brad Bishopc342db32019-05-15 21:57:59 -040012 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 \
Brad Bishop15ae2502019-06-18 21:44:24 -040021 file://fix-setgroup.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040022 "
23SRC_URI_append_class-native = " \
24 file://perl-configpm-switch.patch \
25"
26
Brad Bishop15ae2502019-06-18 21:44:24 -040027SRC_URI[perl.md5sum] = "9770584cdf9b5631c38097645ce33549"
28SRC_URI[perl.sha256sum] = "851213c754d98ccff042caa40ba7a796b2cee88c5325f121be5cbb61bbf975f2"
29SRC_URI[perl-cross.md5sum] = "4dda3daf9c4fe42b3d6a5dd052852a48"
30SRC_URI[perl-cross.sha256sum] = "49edea1ea2cd6c5c47386ca71beda8d150c748835781354dbe7f75b1df27e703"
Brad Bishopc342db32019-05-15 21:57:59 -040031
32S = "${WORKDIR}/perl-${PV}"
33
34inherit upstream-version-is-even
35
36DEPENDS += "db gdbm zlib virtual/crypt"
37
38PERL_LIB_VER = "${@'.'.join(d.getVar('PV').split('.')[0:2])}.0"
39
40do_unpack_append() {
41 bb.build.exec_func('do_copy_perlcross', d)
42}
43
44do_copy_perlcross() {
Brad Bishop15ae2502019-06-18 21:44:24 -040045 cp -rfp ${WORKDIR}/perl-cross*/* ${S}
Brad Bishopc342db32019-05-15 21:57:59 -040046}
47
48do_configure_class-target() {
49 ./configure --prefix=${prefix} --libdir=${libdir} \
50 --target=${TARGET_SYS} \
51 -Duseshrplib \
52 -Dsoname=libperl.so.5 \
53 -Dvendorprefix=${prefix} \
54 -Darchlibexp=${STAGING_LIBDIR}/perl5/${PV}/${TARGET_ARCH}-linux
55
56 #perl.c uses an ARCHLIB_EXP define to generate compile-time code that
57 #adds the archlibexp path to @INC during run-time initialization of a
58 #new perl interpreter.
59
60 #Because we've changed this value in a temporary way to make it
61 #possible to use ExtUtils::Embed in the target build (the temporary
62 #value in config.sh gets re-stripped out during packaging), the
63 #ARCHLIB_EXP value that gets generated still uses the temporary version
64 #instead of the original expected version (i.e. becauses it's in the
65 #generated config.h, it doesn't get stripped out during packaging like
66 #the others in config.sh).
67
68 sed -i -e "s,${STAGING_LIBDIR},${libdir},g" config.h
69}
70
71do_configure_class-nativesdk() {
72 ./configure --prefix=${prefix} \
73 --target=${TARGET_SYS} \
74 -Duseshrplib \
75 -Dsoname=libperl.so.5 \
76 -Dvendorprefix=${prefix} \
77 -Darchlibexp=${STAGING_LIBDIR}/perl5/${PV}/${TARGET_ARCH}-linux
78
79 # See the comment above
80 sed -i -e "s,${STAGING_LIBDIR},${libdir},g" config.h
81}
82
83do_configure_class-native() {
84 ./configure --prefix=${prefix} \
85 -Dbin=${bindir}/perl-native \
86 -Duseshrplib \
87 -Dsoname=libperl.so.5 \
88 -Dvendorprefix=${prefix} \
89 -Ui_xlocale
90}
91
Brad Bishop15ae2502019-06-18 21:44:24 -040092do_configure_append() {
93 if [ -n "$SOURCE_DATE_EPOCH" ]; then
94 PERL_BUILD_DATE="$(${PYTHON} -c "\
95from datetime import datetime, timezone; \
96print(datetime.fromtimestamp($SOURCE_DATE_EPOCH, timezone.utc).strftime('%a %b %d %H:%M:%S %Y')) \
97 ")"
98 echo "#define PERL_BUILD_DATE \"$PERL_BUILD_DATE\"" >> config.h
99 fi
100}
101
Brad Bishopc342db32019-05-15 21:57:59 -0400102do_compile() {
103 oe_runmake
104}
105
106do_install() {
107 oe_runmake 'DESTDIR=${D}' install
108
109 install -d ${D}${libdir}/perl5
110 install -d ${D}${libdir}/perl5/${PV}/
111 install -d ${D}${libdir}/perl5/${PV}/ExtUtils/
112
113 # Save native config
114 install config.sh ${D}${libdir}/perl5
115 install lib/Config.pm ${D}${libdir}/perl5/${PV}/
116 install lib/ExtUtils/typemap ${D}${libdir}/perl5/${PV}/ExtUtils/
117
118 # Fix up shared library
119 rm ${D}/${libdir}/perl5/${PV}/*/CORE/libperl.so
120 ln -sf ../../../../libperl.so.${PERL_LIB_VER} $(echo ${D}/${libdir}/perl5/${PV}/*/CORE)/libperl.so
121}
122
123do_install_append_class-target() {
124 # This is used to substitute target configuration when running native perl via perl-configpm-switch.patch
125 ln -s Config_heavy.pl ${D}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_heavy-target.pl
126
127}
128
129do_install_append_class-nativesdk() {
130 # This is used to substitute target configuration when running native perl via perl-configpm-switch.patch
131 ln -s Config_heavy.pl ${D}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_heavy-target.pl
132
133 create_wrapper ${D}${bindir}/perl \
134 PERL5LIB='$PERL5LIB:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl5/site_perl/${PV}:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl5/vendor_perl/${PV}:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl5/${PV}'
135}
136
137do_install_append_class-native () {
138 # Those wrappers mean that perl installed from sstate (which may change
139 # path location) works and that in the nativesdk case, the SDK can be
140 # installed to a different location from the one it was built for.
141 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}'
142
143 # Use /usr/bin/env nativeperl for the perl script.
144 for f in `grep -Il '#! *${bindir}/perl' ${D}/${bindir}/*`; do
145 sed -i -e 's|${bindir}/perl|/usr/bin/env nativeperl|' $f
146 done
147}
148
149PACKAGE_PREPROCESS_FUNCS += "perl_package_preprocess"
150
151perl_package_preprocess () {
152 # Fix up installed configuration
153 sed -i -e "s,${D},,g" \
154 -e "s,${DEBUG_PREFIX_MAP},,g" \
155 -e "s,--sysroot=${STAGING_DIR_HOST},,g" \
156 -e "s,-isystem${STAGING_INCDIR} ,,g" \
157 -e "s,${STAGING_LIBDIR},${libdir},g" \
158 -e "s,${STAGING_BINDIR},${bindir},g" \
159 -e "s,${STAGING_INCDIR},${includedir},g" \
160 -e "s,${STAGING_BINDIR_NATIVE}/perl-native/,${bindir}/,g" \
161 -e "s,${STAGING_BINDIR_NATIVE}/,,g" \
162 -e "s,${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX},${bindir},g" \
163 -e 's:${RECIPE_SYSROOT}::g' \
164 ${PKGD}${bindir}/h2xs \
165 ${PKGD}${bindir}/h2ph \
166 ${PKGD}${bindir}/pod2man \
167 ${PKGD}${bindir}/pod2text \
168 ${PKGD}${bindir}/pod2usage \
169 ${PKGD}${bindir}/podchecker \
170 ${PKGD}${bindir}/podselect \
171 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/CORE/config.h \
172 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/CORE/perl.h \
173 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/CORE/pp.h \
174 ${PKGD}${libdir}/perl5/${PV}/Config.pm \
175 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config.pm \
176 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config.pod \
Brad Bishop15ae2502019-06-18 21:44:24 -0400177 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_git.pl \
Brad Bishopc342db32019-05-15 21:57:59 -0400178 ${PKGD}${libdir}/perl5/${PV}/${TARGET_ARCH}-linux/Config_heavy.pl \
179 ${PKGD}${libdir}/perl5/${PV}/ExtUtils/Liblist/Kid.pm \
180 ${PKGD}${libdir}/perl5/${PV}/FileCache.pm \
181 ${PKGD}${libdir}/perl5/${PV}/pod/*.pod \
182 ${PKGD}${libdir}/perl5/config.sh
183}
184
185require perl-ptest.inc
186
187FILES_${PN} = "${bindir}/perl ${bindir}/perl.real ${bindir}/perl${PV} ${libdir}/libperl.so* \
188 ${libdir}/perl5/site_perl \
189 ${libdir}/perl5/${PV}/Config.pm \
Brad Bishop15ae2502019-06-18 21:44:24 -0400190 ${libdir}/perl5/${PV}/*/Config_git.pl \
Brad Bishopc342db32019-05-15 21:57:59 -0400191 ${libdir}/perl5/${PV}/*/Config_heavy-target.pl \
192 ${libdir}/perl5/config.sh \
193 ${libdir}/perl5/${PV}/strict.pm \
194 ${libdir}/perl5/${PV}/warnings.pm \
195 ${libdir}/perl5/${PV}/warnings \
196 ${libdir}/perl5/${PV}/vars.pm \
197 ${libdir}/perl5/site_perl \
198 "
199RPROVIDES_${PN} += "perl-module-strict perl-module-vars perl-module-config perl-module-warnings \
200 perl-module-warnings-register"
201
202FILES_${PN}-staticdev_append = " ${libdir}/perl5/${PV}/*/CORE/libperl.a"
203
204FILES_${PN}-dev_append = " ${libdir}/perl5/${PV}/*/CORE"
205
206FILES_${PN}-doc_append = " ${libdir}/perl5/${PV}/Unicode/Collate/*.txt \
207 ${libdir}/perl5/${PV}/*/.packlist \
208 ${libdir}/perl5/${PV}/ExtUtils/MANIFEST.SKIP \
209 ${libdir}/perl5/${PV}/ExtUtils/xsubpp \
210 ${libdir}/perl5/${PV}/ExtUtils/typemap \
211 ${libdir}/perl5/${PV}/Encode/encode.h \
212 "
213PACKAGES += "${PN}-misc"
214
215FILES_${PN}-misc = "${bindir}/*"
216
217PACKAGES += "${PN}-pod"
218
219FILES_${PN}-pod = "${libdir}/perl5/${PV}/pod \
220 ${libdir}/perl5/${PV}/*.pod \
221 ${libdir}/perl5/${PV}/*/*.pod \
222 ${libdir}/perl5/${PV}/*/*/*.pod \
223 ${libdir}/perl5/${PV}/*/*/*/*.pod \
224 "
225
226PACKAGES += "${PN}-module-cpan ${PN}-module-unicore"
227
228FILES_${PN}-module-cpan += "${libdir}/perl5/${PV}/CPAN \
229 "
230FILES_${PN}-module-unicore += "${libdir}/perl5/${PV}/unicore"
231
232# Create a perl-modules package recommending all the other perl
233# packages (actually the non modules packages and not created too)
234ALLOW_EMPTY_${PN}-modules = "1"
235PACKAGES += "${PN}-modules "
236
237PACKAGESPLITFUNCS_prepend = "split_perl_packages "
238
239python split_perl_packages () {
240 libdir = d.expand('${libdir}/perl5/${PV}')
241 do_split_packages(d, libdir, r'.*/auto/([^.]*)/[^/]*\.(so|ld|ix|al)', '${PN}-module-%s', 'perl module %s', recursive=True, match_path=True, prepend=False)
242 do_split_packages(d, libdir, r'.*linux/([^\/]*)\.pm', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
243 do_split_packages(d, libdir, r'Module/([^\/]*)\.pm', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
244 do_split_packages(d, libdir, r'Module/([^\/]*)/.*', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
245 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)
246 do_split_packages(d, libdir, r'(^(?!(CPAN\/|CPANPLUS\/|Module\/|unicore\/)[^\/]).*)\.(pm|pl|e2x)', '${PN}-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
247
248 # perl-modules should recommend every perl module, and only the
249 # modules. Don't attempt to use the result of do_split_packages() as some
250 # modules are manually split (eg. perl-module-unicore).
251 packages = filter(lambda p: 'perl-module-' in p, d.getVar('PACKAGES').split())
252 d.setVar(d.expand("RRECOMMENDS_${PN}-modules"), ' '.join(packages))
253
254 # Read the pre-generated dependency file, and use it to set module dependecies
255 for line in open(d.expand("${WORKDIR}") + '/perl-rdepends.txt').readlines():
256 splitline = line.split()
257 module = splitline[0].replace("RDEPENDS_perl", "RDEPENDS_${PN}")
258 depends = splitline[2].strip('"').replace("perl-module", "${PN}-module")
259 d.appendVar(d.expand(module), " " + depends)
260}
261
262PACKAGES_DYNAMIC_class-target += "^perl-module-.*"
263PACKAGES_DYNAMIC_class-nativesdk += "^nativesdk-perl-module-.*"
264
265RDEPENDS_${PN}-misc += "perl perl-modules"
266RDEPENDS_${PN}-pod += "perl"
267
268BBCLASSEXTEND = "native nativesdk"
269
270SSTATE_SCAN_FILES += "*.pm *.pod *.h *.pl *.sh"
271
272do_create_rdepends_inc() {
273 cd ${WORKDIR}
274 cat <<'EOPREAMBLE' > ${WORKDIR}/perl-rdepends.inc
275
276# Some additional dependencies that the above doesn't manage to figure out
277RDEPENDS_${PN}-module-file-spec += "${PN}-module-file-spec-unix"
278RDEPENDS_${PN}-module-math-bigint += "${PN}-module-math-bigint-calc"
279RDEPENDS_${PN}-module-thread-queue += "${PN}-module-attributes"
280RDEPENDS_${PN}-module-overload += "${PN}-module-overloading"
281
282# Generated depends list beyond this line
283EOPREAMBLE
284 test -e packages-split.new && rm -rf packages-split.new
285 cp -r packages-split packages-split.new && cd packages-split.new
286 find . -name \*.pm | xargs sed -i '/^=head/,/^=cut/d'
287 egrep -r "^\s*(\<use .*|\<require .*);?" perl-module-* --include="*.pm" | \
288 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:] | \
289 awk '{if ($3 != "\x22"$1"\x22"){ print $0}}'| \
290 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 | \
291 sort -u | \
292 sed 's/^/RDEPENDS_/;s/perl-module-/${PN}-module-/g;s/module-\(module-\)/\1/g;s/\(module-load\)-conditional/\1/g;s/encode-configlocal/&-pm/;' | \
293 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' | \
294 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
295 cp ${WORKDIR}/perl-rdepends.generated ${THISDIR}/files/perl-rdepends.txt
296}
297
298# bitbake perl -c create_rdepends_inc
299addtask do_create_rdepends_inc
300
301SYSROOT_PREPROCESS_FUNCS += "perl_sysroot_create_wrapper"
302
303perl_sysroot_create_wrapper () {
304 mkdir -p ${SYSROOT_DESTDIR}${bindir}
305 # Create a wrapper that /usr/bin/env perl will use to get perl-native.
306 # This MUST live in the normal bindir.
307 cat > ${SYSROOT_DESTDIR}${bindir}/nativeperl << EOF
308#!/bin/sh
309realpath=\`readlink -fn \$0\`
310exec \`dirname \$realpath\`/perl-native/perl "\$@"
311EOF
312 chmod 0755 ${SYSROOT_DESTDIR}${bindir}/nativeperl
313 cat ${SYSROOT_DESTDIR}${bindir}/nativeperl
314}
315