blob: a644970192557df84c6302acb374a6ec43181d32 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001require perl.inc
2
3# We need gnugrep (for -I)
4DEPENDS = "db grep-native gdbm zlib virtual/crypt"
5
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 \
48 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 \
65 file://perl-5.26.1-guard_old_libcrypt_fix.patch \
66 file://CVE-2018-12015.patch \
67 file://0001-ExtUtils-MM_Unix.pm-fix-race-issues.patch \
68"
69
70# Fix test case issues
71SRC_URI_append_class-target = " \
72 file://test/dist-threads-t-join.t-adjust-ps-option.patch \
73 file://test/ext-DynaLoader-t-DynaLoader.t-fix-calling-dl_findfil.patch \
74 file://0001-Skip-various-tests-if-PERL_BUILD_PACKAGING-is-set.patch \
75 "
76
77SRC_URI[md5sum] = "04622bc4d3941dc7eb571c52b7c02993"
78SRC_URI[sha256sum] = "7f080287ff64750270689843ae945f02159a33cb8f2fc910248c15befba5db84"
79
80inherit perlnative siteinfo
81
82# Where to find the native perl
83HOSTPERL = "${STAGING_BINDIR_NATIVE}/perl-native/perl${PV}"
84
85# Where to find .so files - use the -native versions not those from the target build
86export PERLHOSTLIB = "${STAGING_LIBDIR_NATIVE}/perl-native/perl/${PV}/"
87
88# Where to find perl @INC/#include files
89# - use the -native versions not those from the target build
90export PERL_LIB = "${STAGING_LIBDIR_NATIVE}/perl-native/perl/${PV}/"
91export PERL_ARCHLIB = "${STAGING_LIBDIR_NATIVE}/perl-native/perl/${PV}/"
92
93EXTRA_OEMAKE = "-e MAKEFLAGS="
94
95# LDFLAGS for shared libraries
96export LDDLFLAGS = "${LDFLAGS} -shared"
97
98LDFLAGS_append = " -fstack-protector"
99
100# We're almost Debian, aren't we?
101CFLAGS += "-DDEBIAN"
102
103do_configure() {
104 # Make hostperl in build directory be the native perl
105 ln -sf ${HOSTPERL} hostperl
106
107 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
108 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" -a -e Makefile ]; then
109 ${MAKE} clean
110 fi
111 find ${S} -name *.so -delete
112 fi
113 if [ -n "${CONFIGURESTAMPFILE}" ]; then
114 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
115 fi
116
117 # Do our work in the cross subdir
118 cd Cross
119
120 # Generate configuration
121 rm -f config.sh-${TARGET_ARCH}-${TARGET_OS}
122 for i in ${WORKDIR}/config.sh \
123 ${WORKDIR}/config.sh-${SITEINFO_BITS} \
124 ${WORKDIR}/config.sh-${SITEINFO_BITS}-${SITEINFO_ENDIANNESS}; do
125 cat $i >> config.sh-${TARGET_ARCH}-${TARGET_OS}
126 done
127
128 # Fixups for musl
129 if [ "${TARGET_OS}" = "linux-musl" -o "${TARGET_OS}" = "linux-musleabi" -o "${TARGET_OS}" = "linux-muslx32" ]; then
130 sed -i -e "s,\(d_libm_lib_version=\)'define',\1'undef',g" \
131 -e "s,\(d_stdio_ptr_lval=\)'define',\1'undef',g" \
132 -e "s,\(d_stdio_ptr_lval_sets_cnt=\)'define',\1'undef',g" \
133 -e "s,\(d_stdiobase=\)'define',\1'undef',g" \
134 -e "s,\(d_stdstdio=\)'define',\1'undef',g" \
135 -e "s,\(d_getnetbyname_r=\)'define',\1'undef',g" \
136 -e "s,\(d_finitel=\)'define',\1'undef',g" \
137 -e "s,\(getprotobyname_r=\)'define',\1'undef',g" \
138 -e "s,\(getpwent_r=\)'define',\1'undef',g" \
139 -e "s,\(getservent_r=\)'define',\1'undef',g" \
140 -e "s,\(gethostent_r=\)'define',\1'undef',g" \
141 -e "s,\(getnetent_r=\)'define',\1'undef',g" \
142 -e "s,\(getnetbyaddr_r=\)'define',\1'undef',g" \
143 -e "s,\(getprotoent_r=\)'define',\1'undef',g" \
144 -e "s,\(getprotobynumber_r=\)'define',\1'undef',g" \
145 -e "s,\(getgrent_r=\)'define',\1'undef',g" \
146 -e "s,\(i_fcntl=\)'undef',\1'define',g" \
147 -e "s,\(h_fcntl=\)'false',\1'true',g" \
148 -e "s,-fstack-protector,-fno-stack-protector,g" \
149 config.sh-${TARGET_ARCH}-${TARGET_OS}
150 fi
151
152 # Update some paths in the configuration
153 sed -i -e 's,@ARCH@-thread-multi,,g' \
154 -e 's,@ARCH@,${TARGET_ARCH}-${TARGET_OS},g' \
155 -e 's,@STAGINGDIR@,${STAGING_DIR_HOST},g' \
156 -e "s,@INCLUDEDIR@,${STAGING_INCDIR},g" \
157 -e "s,@LIBDIR@,${libdir},g" \
158 -e "s,@BASELIBDIR@,${base_libdir},g" \
159 -e "s,@EXECPREFIX@,${exec_prefix},g" \
160 -e 's,@USRBIN@,${bindir},g' \
161 -e "s,-lnsl,,g" \
162 config.sh-${TARGET_ARCH}-${TARGET_OS}
163
164 case "${TARGET_ARCH}" in
165 x86_64 | powerpc | s390)
166 sed -i -e "s,\(need_va_copy=\)'undef',\1'define',g" \
167 config.sh-${TARGET_ARCH}-${TARGET_OS}
168 ;;
169 arm)
170 sed -i -e "s,\(d_u32align=\)'undef',\1'define',g" \
171 config.sh-${TARGET_ARCH}-${TARGET_OS}
172 ;;
173 esac
174 # These are strewn all over the source tree
175 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
176 echo Fixing: $foo
177 sed -e 's|\([ "^'\''I]\+\)/usr/include/|\1${STAGING_INCDIR}/|g' -i $foo
178 done
179
180 rm -f config
181 echo "ARCH = ${TARGET_ARCH}" > config
182 echo "OS = ${TARGET_OS}" >> config
183}
184
185do_compile() {
186 # Fix to avoid recursive substitution of path
187 sed -i -e 's|(@libpath, ".*"|(@libpath, "${STAGING_LIBDIR}"|g' cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm
188
189 cd Cross
190 oe_runmake perl LD="${CCLD}"
191}
192
193do_compile_append_class-target() {
194 # Remove build host references from numerous comments...
195 find "${S}/cpan/Encode" -type f \
196 \( -name '*.exh' -o -name '*.c' -o -name '*.h' \)\
197 -exec sed -i -e 's:${RECIPE_SYSROOT_NATIVE}::g' {} +
198 sed -i -e 's:${RECIPE_SYSROOT}::g' ${S}/perl.h ${S}/pp.h
199 sed -i -e 's:${RECIPE_SYSROOT_NATIVE}/usr/bin/perl-native/perl${PV}.real:/usr/bin/perl${PV}:g' \
200 ${S}/cpan/Compress-Raw-Bzip2/constants.h \
201 ${S}/cpan/Compress-Raw-Zlib/constants.h \
202 ${S}/cpan/IPC-SysV/const-c.inc \
203 ${S}/dist/Time-HiRes/const-c.inc
204}
205
206do_install() {
207 #export hostperl="${STAGING_BINDIR_NATIVE}/perl-native/perl${PV}"
208 oe_runmake install DESTDIR=${D}
209 # Add perl pointing at current version
210 ln -sf perl${PV} ${D}${bindir}/perl
211
212 ln -sf perl ${D}/${libdir}/perl5
213
214 # Remove unwanted file and empty directories
215 rm -f ${D}/${libdir}/perl/${PV}/.packlist
216 rmdir ${D}/${libdir}/perl/site_perl/${PV}
217 rmdir ${D}/${libdir}/perl/site_perl
218
219 # Fix up shared library
220 mv ${D}/${libdir}/perl/${PV}/CORE/libperl.so ${D}/${libdir}/libperl.so.${PV}
221 ln -sf libperl.so.${PV} ${D}/${libdir}/libperl.so.5
222 ln -sf ../../../libperl.so.${PV} ${D}/${libdir}/perl/${PV}/CORE/libperl.so
223
224 # target config, used by cpan.bbclass to extract version information
225 install config.sh ${D}${libdir}/perl
226
227 ln -s Config_heavy.pl ${D}${libdir}/perl/${PV}/Config_heavy-target.pl
228}
229
230do_install_append_class-nativesdk () {
231 create_wrapper ${D}${bindir}/perl \
232 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}'
233}
234
235PACKAGE_PREPROCESS_FUNCS += "perl_package_preprocess"
236
237perl_package_preprocess () {
238 # Fix up installed configuration
239 sed -i -e "s,${D},,g" \
240 -e "s,${DEBUG_PREFIX_MAP},,g" \
241 -e "s,--sysroot=${STAGING_DIR_HOST},,g" \
242 -e "s,-isystem${STAGING_INCDIR} ,,g" \
243 -e "s,${STAGING_LIBDIR},${libdir},g" \
244 -e "s,${STAGING_BINDIR},${bindir},g" \
245 -e "s,${STAGING_INCDIR},${includedir},g" \
246 -e "s,${STAGING_BINDIR_NATIVE}/perl-native/,${bindir}/,g" \
247 -e "s,${STAGING_BINDIR_NATIVE}/,,g" \
248 -e "s,${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX},${bindir},g" \
249 -e 's:${RECIPE_SYSROOT}::g' \
250 ${PKGD}${bindir}/h2xs \
251 ${PKGD}${bindir}/h2ph \
252 ${PKGD}${bindir}/pod2man \
253 ${PKGD}${bindir}/pod2text \
254 ${PKGD}${bindir}/pod2usage \
255 ${PKGD}${bindir}/podchecker \
256 ${PKGD}${bindir}/podselect \
257 ${PKGD}${libdir}/perl/${PV}/CORE/config.h \
258 ${PKGD}${libdir}/perl/${PV}/CORE/perl.h \
259 ${PKGD}${libdir}/perl/${PV}/CORE/pp.h \
260 ${PKGD}${libdir}/perl/${PV}/Config.pm \
261 ${PKGD}${libdir}/perl/${PV}/Config.pod \
262 ${PKGD}${libdir}/perl/${PV}/Config_heavy.pl \
263 ${PKGD}${libdir}/perl/${PV}/ExtUtils/Liblist/Kid.pm \
264 ${PKGD}${libdir}/perl/${PV}/FileCache.pm \
265 ${PKGD}${libdir}/perl/${PV}/pod/*.pod \
266 ${PKGD}${libdir}/perl/config.sh
267}
268
269PACKAGES = "perl-dbg perl perl-misc perl-dev perl-pod perl-doc perl-lib \
270 perl-module-cpan perl-module-cpanplus perl-module-unicore"
271FILES_${PN} = "${bindir}/perl ${bindir}/perl${PV} \
272 ${libdir}/perl/${PV}/Config.pm \
273 ${libdir}/perl/${PV}/strict.pm \
274 ${libdir}/perl/${PV}/warnings.pm \
275 ${libdir}/perl/${PV}/warnings \
276 ${libdir}/perl/${PV}/vars.pm \
277 "
278FILES_${PN}_append_class-nativesdk = " ${bindir}/perl.real"
279RPROVIDES_${PN} += "perl-module-strict perl-module-vars perl-module-config perl-module-warnings \
280 perl-module-warnings-register"
281FILES_${PN}-dev = "${libdir}/perl/${PV}/CORE"
282FILES_${PN}-lib = "${libdir}/libperl.so* \
283 ${libdir}/perl5 \
284 ${libdir}/perl/config.sh \
285 ${libdir}/perl/${PV}/Config_git.pl \
286 ${libdir}/perl/${PV}/Config_heavy.pl \
287 ${libdir}/perl/${PV}/Config_heavy-target.pl"
288FILES_${PN}-pod = "${libdir}/perl/${PV}/pod \
289 ${libdir}/perl/${PV}/*.pod \
290 ${libdir}/perl/${PV}/*/*.pod \
291 ${libdir}/perl/${PV}/*/*/*.pod "
292FILES_perl-misc = "${bindir}/*"
293FILES_${PN}-doc = "${libdir}/perl/${PV}/*/*.txt \
294 ${libdir}/perl/${PV}/*/*/*.txt \
295 ${libdir}/perl/${PV}/auto/XS/Typemap \
296 ${libdir}/perl/${PV}/B/assemble \
297 ${libdir}/perl/${PV}/B/cc_harness \
298 ${libdir}/perl/${PV}/B/disassemble \
299 ${libdir}/perl/${PV}/B/makeliblinks \
300 ${libdir}/perl/${PV}/CGI/eg \
301 ${libdir}/perl/${PV}/CPAN/PAUSE2003.pub \
302 ${libdir}/perl/${PV}/CPAN/SIGNATURE \
303 ${libdir}/perl/${PV}/CPANPLUS/Shell/Default/Plugins/HOWTO.pod \
304 ${libdir}/perl/${PV}/Encode/encode.h \
305 ${libdir}/perl/${PV}/ExtUtils/MANIFEST.SKIP \
306 ${libdir}/perl/${PV}/ExtUtils/NOTES \
307 ${libdir}/perl/${PV}/ExtUtils/PATCHING \
308 ${libdir}/perl/${PV}/ExtUtils/typemap \
309 ${libdir}/perl/${PV}/ExtUtils/xsubpp \
310 ${libdir}/perl/${PV}/ExtUtils/Changes_EU-Install \
311 ${libdir}/perl/${PV}/Net/*.eg \
312 ${libdir}/perl/${PV}/unicore/mktables \
313 ${libdir}/perl/${PV}/unicore/mktables.lst \
314 ${libdir}/perl/${PV}/unicore/version "
315
316FILES_perl-module-cpan += "${libdir}/perl/${PV}/CPAN \
317 ${libdir}/perl/${PV}/CPAN.pm"
318FILES_perl-module-cpanplus += "${libdir}/perl/${PV}/CPANPLUS \
319 ${libdir}/perl/${PV}/CPANPLUS.pm"
320FILES_perl-module-unicore += "${libdir}/perl/${PV}/unicore"
321
322# Create a perl-modules package recommending all the other perl
323# packages (actually the non modules packages and not created too)
324ALLOW_EMPTY_perl-modules = "1"
325PACKAGES_append = " perl-modules "
326
327PACKAGESPLITFUNCS_prepend = "split_perl_packages "
328
329python split_perl_packages () {
330 libdir = d.expand('${libdir}/perl/${PV}')
331 do_split_packages(d, libdir, 'auto/([^.]*)/[^/]*\.(so|ld|ix|al)', 'perl-module-%s', 'perl module %s', recursive=True, match_path=True, prepend=False)
332 do_split_packages(d, libdir, 'Module/([^\/]*)\.pm', 'perl-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
333 do_split_packages(d, libdir, 'Module/([^\/]*)/.*', 'perl-module-%s', 'perl module %s', recursive=True, allow_dirs=False, match_path=True, prepend=False)
334 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)
335
336 # perl-modules should recommend every perl module, and only the
337 # modules. Don't attempt to use the result of do_split_packages() as some
338 # modules are manually split (eg. perl-module-unicore).
339 packages = filter(lambda p: 'perl-module-' in p, d.getVar('PACKAGES').split())
340 d.setVar(d.expand("RRECOMMENDS_${PN}-modules"), ' '.join(packages))
341}
342
343PACKAGES_DYNAMIC += "^perl-module-.*(?<!\-native)$"
344PACKAGES_DYNAMIC_class-nativesdk = "^nativesdk-perl-module-.*"
345
346RPROVIDES_perl-lib = "perl-lib"
347
348require perl-rdepends_${PV}.inc
349require perl-ptest.inc
350
351SSTATE_SCAN_FILES += "*.pm *.pod *.h *.pl *.sh"
352
353BBCLASSEXTEND = "nativesdk"