merge of '1413d095164c683305cfc29d3e275c6cd0aff5c2'
[vuplus_openembedded] / classes / cpan_build.bbclass
1 #
2 # This is for perl modules that use the new Build.PL build system
3 #
4 INHIBIT_NATIVE_STAGE_INSTALL = "1"
5 FILES_${PN} += '${libdir}/perl5'
6
7 DEPENDS  += "perl-native"
8 RDEPENDS += "perl"
9
10 #
11 # We also need to have built libmodule-build-perl-native for
12 # everything except libmodule-build-perl-native itself (which uses
13 # this class, but uses itself as the probider of
14 # libmodule-build-perl)
15 #
16 def cpan_build_dep_prepend(d):
17         import bb;
18         if bb.data.getVar('CPAN_BUILD_DEPS', d, 1):
19                 return ''
20         pn = bb.data.getVar('PN', d, 1)
21         if pn in ['libmodule-build-perl', 'libmodule-build-perl-native']:
22                 return ''
23         return 'libmodule-build-perl-native '
24
25 DEPENDS_prepend = "${@cpan_build_dep_prepend(d)}"
26
27 def is_crosscompiling(d):
28     import bb
29     if not bb.data.inherits_class('native', d):
30         return "yes"
31     return "no"
32
33 cpan_build_do_configure () {
34         if [ ${@is_crosscompiling(d)} == "yes" ]; then
35                 # build for target
36                 . ${STAGING_DIR}/${TARGET_SYS}/perl/config.sh
37                 perl Build.PL --installdirs vendor \
38                         --destdir ${D} \
39                         --install_path lib="${libdir}/perl5/site_perl/${version}" \
40                         --install_path arch="${libdir}/perl5/site_perl/${version}/${TARGET_SYS}" \
41                         --install_path script=${bindir} \
42                         --install_path bin=${bindir} \
43                         --install_path bindoc=${mandir}/man1 \
44                         --install_path libdoc=${mandir}/man3
45         else
46                 # build for host
47                 perl Build.PL --installdirs site
48         fi
49 }
50
51 cpan_build_do_compile () {
52         perl Build
53 }
54
55 cpan_build_do_install () {
56         if [ ${@is_crosscompiling(d)} == "yes" ]; then
57                 perl Build install
58         fi
59 }
60
61 do_stage_append () {
62         if [ ${@is_crosscompiling(d)} == "no" ]; then
63                 perl Build install
64         fi
65 }
66
67 EXPORT_FUNCTIONS do_configure do_compile do_install