aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/cpanm.bbclass
blob: 77aa854b0a965d7540019e7afbb3c9edbc00774a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# This is for perl modules that use cpanm (App::cpanminus)
#
inherit cpan-base perlnative

# Env var which tells perl if it should use host (no) or target (yes) settings
export PERLCONFIGTARGET = "${@is_target(d)}"
export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
export LD = "${CCLD}"

# Env var which tells cpanm where to download files
export PERL_CPANM_HOME = "${DL_DIR}/.cpanm"
# Env vars which would be set by local::lib
export PERL_MB_OPT = "--install_base ${PERL_ARCHLIB}"
export PERL_MM_OPT = "INSTALL_BASE=${PERL_ARCHLIB}"
export PERL5LIB = "${PERL_ARCHLIB}:${STAGING_LIBDIR}/perl/"
export PERL_LOCAL_LIB_ROOT = "${libdir}/perl"

#
# We also need to have built libapp-cpanminus-perl-native for
# everything except libapp-cpanminus-perl-native itself (which uses
# this class, but uses itself as the provider of
# libapp-cpanminus-perl)
#
def cpanm_dep_prepend(d):
	if d.getVar('CPANM_DEPS', True):
		return ''
	pn = d.getVar('PN', True)
	if pn in ['libapp-cpanminus-perl', 'libapp-cpanminus-perl-native']:
		return ''
	return 'libapp-cpanminus-perl-native '

DEPENDS_prepend = "${@cpanm_dep_prepend(d)}"

cpanm_do_configure () {
	if [ "${@is_target(d)}" = "yes" ]; then
		# build for target
		. ${STAGING_LIBDIR}/perl/config.sh
	fi

	perl Build.PL --installdirs vendor \
				--destdir ${D} \
				--install_path arch="${libdir}/perl" \
				--install_path script=${bindir} \
				--install_path bin=${bindir} \
				--install_path bindoc=${mandir}/man1 \
				--install_path libdoc=${mandir}/man3 \
}

cpanm_do_compile () {
	cpanm perl Build
}

cpanm_do_install () {
	cpanm perl Build install
}

EXPORT_FUNCTIONS do_configure do_compile do_install