1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7#
8# This is for perl modules that use the new Build.PL build system
9#
10inherit cpan-base perlnative
11
12EXTRA_CPAN_BUILD_FLAGS ?= ""
13
14# Env var which tells perl if it should use host (no) or target (yes) settings
15export PERLCONFIGTARGET = "${@is_target(d)}"
16export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl5/${@get_perl_version(d)}/${@get_perl_arch(d)}"
17export PERLHOSTLIB = "${STAGING_LIBDIR_NATIVE}/perl5/${@get_perl_version(d)}/"
18export PERLHOSTARCHLIB = "${STAGING_LIBDIR_NATIVE}/perl5/${@get_perl_version(d)}/${@get_perl_hostarch(d)}/"
19export LD = "${CCLD}"
20
21cpan_build_do_configure () {
22	if [ "${@is_target(d)}" = "yes" ]; then
23		# build for target
24		. ${STAGING_LIBDIR}/perl5/config.sh
25	fi
26
27	perl Build.PL --installdirs vendor --destdir ${D} \
28			${EXTRA_CPAN_BUILD_FLAGS}
29
30	# Build.PLs can exit with success without generating a
31	# Build, e.g. in cases of missing configure time
32	# dependencies. This is considered a best practice by
33	# cpantesters.org. See:
34	#  * http://wiki.cpantesters.org/wiki/CPANAuthorNotes
35	#  * http://www.nntp.perl.org/group/perl.qa/2008/08/msg11236.html
36	[ -e Build ] || bbfatal "No Build was generated by Build.PL"
37}
38
39cpan_build_do_compile () {
40        perl Build --perl "${bindir}/perl" verbose=1
41}
42
43cpan_build_do_install () {
44	perl Build install --destdir ${D}
45}
46
47EXPORT_FUNCTIONS do_configure do_compile do_install
48