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