blob: 6e33bb066e1ecbd52f1fc4ca3755508677f7d434 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001require perl.inc
2
3# We need gnugrep (for -I)
Brad Bishop316dfdd2018-06-25 12:45:53 -04004DEPENDS = "db grep-native gdbm zlib virtual/crypt"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005
6# Pick up patches from debian
7# http://ftp.de.debian.org/debian/pool/main/p/perl/perl_5.22.0-1.debian.tar.xz
8SRC_URI += " \
9 file://debian/cpan_definstalldirs.diff \
10 file://debian/db_file_ver.diff \
11 file://debian/doc_info.diff \
12 file://debian/enc2xs_inc.diff \
13 file://debian/errno_ver.diff \
14 file://debian/libperl_embed_doc.diff \
15 file://debian/fixes/respect_umask.diff \
16 file://debian/writable_site_dirs.diff \
17 file://debian/extutils_set_libperl_path.diff \
18 file://debian/no_packlist_perllocal.diff \
19 file://debian/prefix_changes.diff \
20 file://debian/instmodsh_doc.diff \
21 file://debian/ld_run_path.diff \
22 file://debian/libnet_config_path.diff \
23 file://debian/mod_paths.diff \
24 file://debian/prune_libs.diff \
25 file://debian/fixes/net_smtp_docs.diff \
26 file://debian/perlivp.diff \
27 file://debian/squelch-locale-warnings.diff \
28 file://debian/skip-upstream-git-tests.diff \
29 file://debian/skip-kfreebsd-crash.diff \
30 file://debian/fixes/document_makemaker_ccflags.diff \
31 file://debian/find_html2text.diff \
32 file://debian/perl5db-x-terminal-emulator.patch \
33 file://debian/cpan-missing-site-dirs.diff \
34 file://debian/fixes/memoize_storable_nstore.diff \
35 file://debian/regen-skip.diff \
36"
37
38SRC_URI += " \
39 file://Makefile.patch \
40 file://Makefile.SH.patch \
41 file://installperl.patch \
42 file://perl-archlib-exp.patch \
43 file://perl-dynloader.patch \
44 file://perl-moreconfig.patch \
45 file://letgcc-find-errno.patch \
46 file://generate-sh.patch \
47 file://native-perlinc.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 file://cross-generate_uudmap.patch \
49 file://fix_bad_rpath.patch \
50 file://dynaloaderhack.patch \
51 file://config.sh \
52 file://config.sh-32 \
53 file://config.sh-32-le \
54 file://config.sh-32-be \
55 file://config.sh-64 \
56 file://config.sh-64-le \
57 file://config.sh-64-be \
58 file://make_ext.pl-fix-regenerate-makefile-failed-while-cc-.patch \
59 file://t-run-switches.t-perl5-perl.patch \
60 file://ext-ODBM_File-hints-linux.pl-link-libgdbm_compat.patch \
61 file://ext-ODBM_File-t-odbm.t-fix-the-path-of-dbmt_common.p.patch \
62 file://perl-PathTools-don-t-filter-out-blib-from-INC.patch \
63 file://perl-errno-generation-gcc5.patch \
64 file://perl-fix-conflict-between-skip_all-and-END.patch \
Brad Bishop316dfdd2018-06-25 12:45:53 -040065 file://perl-5.26.1-guard_old_libcrypt_fix.patch \
66 file://CVE-2017-12883.patch \
67 file://CVE-2017-12837.patch \
Brad Bishop220d5532018-08-14 00:59:39 +010068 file://CVE-2018-6798-1.patch \
69 file://CVE-2018-6798-2.patch \
70 file://CVE-2018-6797.patch \
71 file://CVE-2018-6913.patch \
72 file://CVE-2018-12015.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050073"
74
75# Fix test case issues
76SRC_URI_append_class-target = " \
77 file://test/dist-threads-t-join.t-adjust-ps-option.patch \
78 file://test/ext-DynaLoader-t-DynaLoader.t-fix-calling-dl_findfil.patch \
Brad Bishop6f8dcde2018-10-16 10:47:12 +080079 file://0001-Skip-various-tests-if-PERL_BUILD_PACKAGING-is-set.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050080 "
81
82SRC_URI[md5sum] = "af6a84c7c3e2b8b269c105a5db2f6d53"
83SRC_URI[sha256sum] = "03a77bac4505c270f1890ece75afc7d4b555090b41aa41ea478747e23b2afb3f"
84
85inherit perlnative siteinfo
86
87# Where to find the native perl
88HOSTPERL = "${STAGING_BINDIR_NATIVE}/perl-native/perl${PV}"
89
90# Where to find .so files - use the -native versions not those from the target build
91export PERLHOSTLIB = "${STAGING_LIBDIR_NATIVE}/perl-native/perl/${PV}/"
92
93# Where to find perl @INC/#include files
94# - use the -native versions not those from the target build
95export PERL_LIB = "${STAGING_LIBDIR_NATIVE}/perl-native/perl/${PV}/"
96export PERL_ARCHLIB = "${STAGING_LIBDIR_NATIVE}/perl-native/perl/${PV}/"
97
98EXTRA_OEMAKE = "-e MAKEFLAGS="
99
100# LDFLAGS for shared libraries
101export LDDLFLAGS = "${LDFLAGS} -shared"
102
103LDFLAGS_append = " -fstack-protector"
104
105# We're almost Debian, aren't we?
106CFLAGS += "-DDEBIAN"
107
108do_configure() {
109 # Make hostperl in build directory be the native perl
110 ln -sf ${HOSTPERL} hostperl
111
112 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
113 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" -a -e Makefile ]; then
114 ${MAKE} clean
115 fi
116 find ${S} -name *.so -delete
117 fi
118 if [ -n "${CONFIGURESTAMPFILE}" ]; then
119 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
120 fi
121
122 # Do our work in the cross subdir
123 cd Cross
124
125 # Generate configuration
126 rm -f config.sh-${TARGET_ARCH}-${TARGET_OS}
127 for i in ${WORKDIR}/config.sh \
128 ${WORKDIR}/config.sh-${SITEINFO_BITS} \
129 ${WORKDIR}/config.sh-${SITEINFO_BITS}-${SITEINFO_ENDIANNESS}; do
130 cat $i >> config.sh-${TARGET_ARCH}-${TARGET_OS}
131 done
132
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500133 # Fixups for musl
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500134 if [ "${TARGET_OS}" = "linux-musl" -o "${TARGET_OS}" = "linux-musleabi" -o "${TARGET_OS}" = "linux-muslx32" ]; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500135 sed -i -e "s,\(d_libm_lib_version=\)'define',\1'undef',g" \
136 -e "s,\(d_stdio_ptr_lval=\)'define',\1'undef',g" \
137 -e "s,\(d_stdio_ptr_lval_sets_cnt=\)'define',\1'undef',g" \
138 -e "s,\(d_stdiobase=\)'define',\1'undef',g" \
139 -e "s,\(d_stdstdio=\)'define',\1'undef',g" \
140 -e "s,\(d_getnetbyname_r=\)'define',\1'undef',g" \
141 -e "s,\(d_finitel=\)'define',\1'undef',g" \
142 -e "s,\(getprotobyname_r=\)'define',\1'undef',g" \
143 -e "s,\(getpwent_r=\)'define',\1'undef',g" \
144 -e "s,\(getservent_r=\)'define',\1'undef',g" \
145 -e "s,\(gethostent_r=\)'define',\1'undef',g" \
146 -e "s,\(getnetent_r=\)'define',\1'undef',g" \
147 -e "s,\(getnetbyaddr_r=\)'define',\1'undef',g" \
148 -e "s,\(getprotoent_r=\)'define',\1'undef',g" \
149 -e "s,\(getprotobynumber_r=\)'define',\1'undef',g" \
150 -e "s,\(getgrent_r=\)'define',\1'undef',g" \
151 -e "s,\(i_fcntl=\)'undef',\1'define',g" \
152 -e "s,\(h_fcntl=\)'false',\1'true',g" \
153 -e "s,-fstack-protector,-fno-stack-protector,g" \
154 -e "s,-lnsl,,g" \
155 config.sh-${TARGET_ARCH}-${TARGET_OS}
156 fi
157
158 # Update some paths in the configuration
159 sed -i -e 's,@ARCH@-thread-multi,,g' \
160 -e 's,@ARCH@,${TARGET_ARCH}-${TARGET_OS},g' \
161 -e 's,@STAGINGDIR@,${STAGING_DIR_HOST},g' \
162 -e "s,@INCLUDEDIR@,${STAGING_INCDIR},g" \
163 -e "s,@LIBDIR@,${libdir},g" \
164 -e "s,@BASELIBDIR@,${base_libdir},g" \
165 -e "s,@EXECPREFIX@,${exec_prefix},g" \
166 -e 's,@USRBIN@,${bindir},g' \
167 config.sh-${TARGET_ARCH}-${TARGET_OS}
168
169 case "${TARGET_ARCH}" in
170 x86_64 | powerpc | s390)
171 sed -i -e "s,\(need_va_copy=\)'undef',\1'define',g" \
172 config.sh-${TARGET_ARCH}-${TARGET_OS}
173 ;;
174 arm)
175 sed -i -e "s,\(d_u32align=\)'undef',\1'define',g" \
176 config.sh-${TARGET_ARCH}-${TARGET_OS}
177 ;;
178 esac
179 # These are strewn all over the source tree
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500180 for foo in `grep -I --exclude="*.patch" --exclude="*.diff" --exclude="*.pod" --exclude="README*" --exclude="Glossary" -m1 "/usr/include/.*\.h" ${S}/* -r -l` ${S}/utils/h2xs.PL ; do
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500181 echo Fixing: $foo
182 sed -e 's|\([ "^'\''I]\+\)/usr/include/|\1${STAGING_INCDIR}/|g' -i $foo
183 done
184
185 rm -f config
186 echo "ARCH = ${TARGET_ARCH}" > config
187 echo "OS = ${TARGET_OS}" >> config
188}
189
190do_compile() {
191 # Fix to avoid recursive substitution of path
192 sed -i -e 's|(@libpath, ".*"|(@libpath, "${STAGING_LIBDIR}"|g' cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm
193
194 cd Cross
195 oe_runmake perl LD="${CCLD}"
196}
197
Brad Bishop316dfdd2018-06-25 12:45:53 -0400198do_compile_append_class-target() {
199 # Remove build host references from numerous comments...
200 find "${S}/cpan/Encode" -type f \
201 \( -name '*.exh' -o -name '*.c' -o -name '*.h' \)\
202 -exec sed -i -e 's:${RECIPE_SYSROOT_NATIVE}::g' {} +
203 sed -i -e 's:${RECIPE_SYSROOT}::g' ${S}/perl.h ${S}/pp.h
204 sed -i -e 's:${RECIPE_SYSROOT_NATIVE}/usr/bin/perl-native/perl${PV}.real:/usr/bin/perl${PV}:g' \
205 ${S}/cpan/Compress-Raw-Bzip2/constants.h \
206 ${S}/cpan/Compress-Raw-Zlib/constants.h \
207 ${S}/cpan/IPC-SysV/const-c.inc \
208 ${S}/dist/Time-HiRes/const-c.inc
209}
210
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500211do_install() {
212 #export hostperl="${STAGING_BINDIR_NATIVE}/perl-native/perl${PV}"
213 oe_runmake install DESTDIR=${D}
214 # Add perl pointing at current version
215 ln -sf perl${PV} ${D}${bindir}/perl
216
217 ln -sf perl ${D}/${libdir}/perl5
218
219 # Remove unwanted file and empty directories
220 rm -f ${D}/${libdir}/perl/${PV}/.packlist
221 rmdir ${D}/${libdir}/perl/site_perl/${PV}
222 rmdir ${D}/${libdir}/perl/site_perl
223
224 # Fix up shared library
225 mv ${D}/${libdir}/perl/${PV}/CORE/libperl.so ${D}/${libdir}/libperl.so.${PV}
226 ln -sf libperl.so.${PV} ${D}/${libdir}/libperl.so.5
227 ln -sf ../../../libperl.so.${PV} ${D}/${libdir}/perl/${PV}/CORE/libperl.so
228
229 # target config, used by cpan.bbclass to extract version information
230 install config.sh ${D}${libdir}/perl
231
232 ln -s Config_heavy.pl ${D}${libdir}/perl/${PV}/Config_heavy-target.pl
233}
234
235do_install_append_class-nativesdk () {
236 create_wrapper ${D}${bindir}/perl \
237 PERL5LIB='$PERL5LIB:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl/site_perl/${PV}:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl/vendor_perl/${PV}:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl/${PV}'
238}
239
240PACKAGE_PREPROCESS_FUNCS += "perl_package_preprocess"
241
242perl_package_preprocess () {
243 # Fix up installed configuration
244 sed -i -e "s,${D},,g" \
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500245 -e "s,${DEBUG_PREFIX_MAP},,g" \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500246 -e "s,--sysroot=${STAGING_DIR_HOST},,g" \
247 -e "s,-isystem${STAGING_INCDIR} ,,g" \
248 -e "s,${STAGING_LIBDIR},${libdir},g" \
249 -e "s,${STAGING_BINDIR},${bindir},g" \
250 -e "s,${STAGING_INCDIR},${includedir},g" \
251 -e "s,${STAGING_BINDIR_NATIVE}/perl-native/,${bindir}/,g" \
252 -e "s,${STAGING_BINDIR_NATIVE}/,,g" \
253 -e "s,${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX},${bindir},g" \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400254 -e 's:${RECIPE_SYSROOT}::g' \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500255 ${PKGD}${bindir}/h2xs \
256 ${PKGD}${bindir}/h2ph \
257 ${PKGD}${bindir}/pod2man \
258 ${PKGD}${bindir}/pod2text \
259 ${PKGD}${bindir}/pod2usage \
260 ${PKGD}${bindir}/podchecker \
261 ${PKGD}${bindir}/podselect \
262 ${PKGD}${libdir}/perl/${PV}/CORE/config.h \
263 ${PKGD}${libdir}/perl/${PV}/CORE/perl.h \
264 ${PKGD}${libdir}/perl/${PV}/CORE/pp.h \
265 ${PKGD}${libdir}/perl/${PV}/Config.pm \
266 ${PKGD}${libdir}/perl/${PV}/Config.pod \
267 ${PKGD}${libdir}/perl/${PV}/Config_heavy.pl \
268 ${PKGD}${libdir}/perl/${PV}/ExtUtils/Liblist/Kid.pm \
269 ${PKGD}${libdir}/perl/${PV}/FileCache.pm \
270 ${PKGD}${libdir}/perl/${PV}/pod/*.pod \
271 ${PKGD}${libdir}/perl/config.sh
272}
273
274PACKAGES = "perl-dbg perl perl-misc perl-dev perl-pod perl-doc perl-lib \
275 perl-module-cpan perl-module-cpanplus perl-module-unicore"
276FILES_${PN} = "${bindir}/perl ${bindir}/perl${PV} \
277 ${libdir}/perl/${PV}/Config.pm \
278 ${libdir}/perl/${PV}/strict.pm \
279 ${libdir}/perl/${PV}/warnings.pm \
280 ${libdir}/perl/${PV}/warnings \
281 ${libdir}/perl/${PV}/vars.pm \
282 "
283FILES_${PN}_append_class-nativesdk = " ${bindir}/perl.real"
284RPROVIDES_${PN} += "perl-module-strict perl-module-vars perl-module-config perl-module-warnings \
285 perl-module-warnings-register"
286FILES_${PN}-dev = "${libdir}/perl/${PV}/CORE"
287FILES_${PN}-lib = "${libdir}/libperl.so* \
288 ${libdir}/perl5 \
289 ${libdir}/perl/config.sh \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400290 ${libdir}/perl/${PV}/Config_git.pl \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500291 ${libdir}/perl/${PV}/Config_heavy.pl \
292 ${libdir}/perl/${PV}/Config_heavy-target.pl"
293FILES_${PN}-pod = "${libdir}/perl/${PV}/pod \
294 ${libdir}/perl/${PV}/*.pod \
295 ${libdir}/perl/${PV}/*/*.pod \
296 ${libdir}/perl/${PV}/*/*/*.pod "
297FILES_perl-misc = "${bindir}/*"
298FILES_${PN}-doc = "${libdir}/perl/${PV}/*/*.txt \
299 ${libdir}/perl/${PV}/*/*/*.txt \
300 ${libdir}/perl/${PV}/auto/XS/Typemap \
301 ${libdir}/perl/${PV}/B/assemble \
302 ${libdir}/perl/${PV}/B/cc_harness \
303 ${libdir}/perl/${PV}/B/disassemble \
304 ${libdir}/perl/${PV}/B/makeliblinks \
305 ${libdir}/perl/${PV}/CGI/eg \
306 ${libdir}/perl/${PV}/CPAN/PAUSE2003.pub \
307 ${libdir}/perl/${PV}/CPAN/SIGNATURE \
308 ${libdir}/perl/${PV}/CPANPLUS/Shell/Default/Plugins/HOWTO.pod \
309 ${libdir}/perl/${PV}/Encode/encode.h \
310 ${libdir}/perl/${PV}/ExtUtils/MANIFEST.SKIP \
311 ${libdir}/perl/${PV}/ExtUtils/NOTES \
312 ${libdir}/perl/${PV}/ExtUtils/PATCHING \
313 ${libdir}/perl/${PV}/ExtUtils/typemap \
314 ${libdir}/perl/${PV}/ExtUtils/xsubpp \
315 ${libdir}/perl/${PV}/ExtUtils/Changes_EU-Install \
316 ${libdir}/perl/${PV}/Net/*.eg \
317 ${libdir}/perl/${PV}/unicore/mktables \
318 ${libdir}/perl/${PV}/unicore/mktables.lst \
319 ${libdir}/perl/${PV}/unicore/version "
320
321FILES_perl-module-cpan += "${libdir}/perl/${PV}/CPAN \
322 ${libdir}/perl/${PV}/CPAN.pm"
323FILES_perl-module-cpanplus += "${libdir}/perl/${PV}/CPANPLUS \
324 ${libdir}/perl/${PV}/CPANPLUS.pm"
325FILES_perl-module-unicore += "${libdir}/perl/${PV}/unicore"
326
327# Create a perl-modules package recommending all the other perl
328# packages (actually the non modules packages and not created too)
329ALLOW_EMPTY_perl-modules = "1"
330PACKAGES_append = " perl-modules "
331
332PACKAGESPLITFUNCS_prepend = "split_perl_packages "
333
334python split_perl_packages () {
335 libdir = d.expand('${libdir}/perl/${PV}')
336 do_split_packages(d, libdir, 'auto/([^.]*)/[^/]*\.(so|ld|ix|al)', 'perl-module-%s', 'perl module %s', recursive=True, match_path=True, prepend=False)
337 do_split_packages(d, libdir, 'Module/([^\/]*)\.pm', 'perl-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
338 do_split_packages(d, libdir, 'Module/([^\/]*)/.*', 'perl-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
339 do_split_packages(d, libdir, '(^(?!(CPAN\/|CPANPLUS\/|Module\/|unicore\/|auto\/)[^\/]).*)\.(pm|pl|e2x)', 'perl-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
340
341 # perl-modules should recommend every perl module, and only the
342 # modules. Don't attempt to use the result of do_split_packages() as some
343 # modules are manually split (eg. perl-module-unicore).
344 packages = filter(lambda p: 'perl-module-' in p, d.getVar('PACKAGES').split())
345 d.setVar(d.expand("RRECOMMENDS_${PN}-modules"), ' '.join(packages))
346}
347
Brad Bishop316dfdd2018-06-25 12:45:53 -0400348PACKAGES_DYNAMIC += "^perl-module-.*(?<!\-native)$"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500349PACKAGES_DYNAMIC_class-nativesdk += "^nativesdk-perl-module-.*"
350
351RPROVIDES_perl-lib = "perl-lib"
352
353require perl-rdepends_${PV}.inc
354require perl-ptest.inc
355
356SSTATE_SCAN_FILES += "*.pm *.pod *.h *.pl *.sh"
357
358BBCLASSEXTEND = "nativesdk"