ti-local-power-manager: avoid parse errors when variables aren't defined
[glsdk/meta-ti-glsdk.git] / recipes-ti / local-power-manager / ti-local-power-manager.inc
1 DESCRIPTION = "TI Local Power Manager (LPM)"
2 HOMEPAGE = "http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/lpm"
3 SECTION = "devel"
4 LICENSE = "GPLv2"
6 # TODO : Hardcoded path to evm3530 - need to fix when adding omap24xx/dm6446 (other lpm targets)
8 require ../includes/ti-paths.inc
9 require ../includes/ti-staging.inc
11 PROVIDES = "ti-lpm-module"
12 PROVIDES += "ti-lpm-utils"
14 # This package builds a kernel module, use kernel PR as base and append a local version
15 PR = "${MACHINE_KERNEL_PR}"
16 PR_append = "e"
18 S = "${WORKDIR}/local_power_manager_linux_${PV}"
20 SRC_URI = "http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/lpm/${PV}/exports/local_power_manager_linux_${PV}.tar.gz;name=lpmtarball"
22 DEPENDS = "ti-dsplink ti-xdctools"
23 DEPENDS += "virtual/kernel"
25 # SOC_FAMILY configuration
27 LPMDSPPOWERSOC_omap3  = "omap3530"
28 LPMDSPPOWERSOC_dm6446 = "dm6446"
29 LPMDSPPOWERSOC       ?= "UNDEFINED_LPMDSPPOWERSOC"
31 XDC_PLATFORM_dm6446   = "ti.platforms.evmDM6446"
32 XDC_PLATFORM_omap3    = "ti.platforms.evm3530"
33 XDC_PLATFORM         ?= "UNDEFINED_XDC_PLATFORM"
35 do_configure () {
37     # Generate a config.bld for XDC
39     cat > ${S}/config.bld <<EOF
41 /* Generated by ti-local-power-manager.inc OE recipe */
43 var Build = xdc.useModule('xdc.bld.BuildEnvironment');
45 var GCArmv5T = xdc.useModule('gnu.targets.arm.GCArmv5T');
46 GCArmv5T.LONGNAME = "bin/${TARGET_PREFIX}gcc";
47 GCArmv5T.rootDir = "${TOOLCHAIN_PATH}";
48 GCArmv5T.ccOpts.prefix += " -Wall -fno-strict-aliasing ";
49 GCArmv5T.lnkOpts.suffix = GCArmv5T.lnkOpts.suffix.replace("-lstdc++", "");
50 GCArmv5T.lnkOpts.suffix += " -lpthread ";
51 GCArmv5T.platform = null;
52 GCArmv5T.platforms = [
53     "${XDC_PLATFORM}"
54 ];
56 /* remove profiles we don't use */
57 delete GCArmv5T.profiles["coverage"];
58 delete GCArmv5T.profiles["profile"];
60 Build.targets.\$add(GCArmv5T);
61 EOF
63 }
65 do_prepsources () {
67     # Prepare the tree for rebuiling - generate makefiles and clean
68     XDCPATH=${S} ${XDC_INSTALL_DIR}/xdc .make -PR .
69     XDCPATH=${S} ${XDC_INSTALL_DIR}/xdc clean -PR .
70 }
72 addtask prepsources after do_configure before do_compile
74 do_compile () {
76     # Build the LPM kernel module
77     unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
78     cd ${S}/packages/ti/bios/power/modules/${LPMDSPPOWERSOC}/lpm
79     make \
80       DSPLINK_REPO="${LINK_INSTALL_DIR}" \
81       LINUXKERNEL_INSTALL_DIR="${STAGING_KERNEL_DIR}" \
82       MVTOOL_PREFIX="${TARGET_PREFIX}" \
83       clean default
85     # Build the user space library
86     # TODO
88     # Build the utilities (lpmON/OFF)
89     cd ${S}
90     XDCPATH=${S} ${XDC_INSTALL_DIR}/xdc -PR .
91 }
93 KERNEL_VERSION = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-abiversion')}"
95 do_install () {
97     # Install the kernel module 
98     install -d ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp
99     install -m 0755 ${S}/packages/ti/bios/power/modules/${LPMDSPPOWERSOC}/lpm/*.ko ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp
101     # Install the Utilities
102     install -d ${D}/${installdir}/ti-lpm-utils
103     install -m 0755 ${S}/packages/ti/bios/power/utils/bin/$(echo ${XDC_PLATFORM} | tr . _)/linux/release/* ${D}/${installdir}/ti-lpm-utils
105     # Install/Stage the Source Tree 
106     install -d ${D}${LPM_INSTALL_DIR_RECIPE}
107     cp -pPrf ${S}/* ${D}${LPM_INSTALL_DIR_RECIPE}
110 PACKAGES += "ti-lpm-module"
111 FILES_ti-lpm-module = "/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp/*lpm*ko"
112 RDEPENDS_ti-lpm-module += "ti-dsplink-module"
113 RDEPENDS_ti-lpm-module += "update-modules"
115 pkg_postinst_ti-lpm-module_append () {
116         if [ -n "$D" ]; then
117                 exit 1
118         fi
119         depmod -a
120         update-modules || true
123 pkg_postrm_ti-lpm-module_append () {
124         update-modules || true
127 PACKAGES += "ti-lpm-utils"
128 RDEPENDS_ti-lpm-utils += "ti-lpm-module"
129 FILES_ti-lpm-utils = "${installdir}/ti-lpm-utils/*"
130 INSANE_SKIP_ti-lpm-utils = True