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