openpower: Build libecmd, capi, ext and stub libraries

    1) ecmd-pdbg(edbg) will use this as depends
    2) All the ecmd, stub, capi & ext headers are copied to standard
       location instead of module specific path
    3) help text files are copied under /usr/share/libecmd/help

(From meta-openpower rev: 7814d18487f8836b40fb6fedb7c001250400cbc4)

Signed-off-by: Lakshminarayana R. Kammath <lkammath@in.ibm.com>
Change-Id: Id1e516873a1d6a2c4c24e7b709861a274d8cc6b2
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/meta-openpower/recipes-bsp/ecmd/libecmd_git.bb b/meta-openpower/recipes-bsp/ecmd/libecmd_git.bb
new file mode 100644
index 0000000..c2e43a4
--- /dev/null
+++ b/meta-openpower/recipes-bsp/ecmd/libecmd_git.bb
@@ -0,0 +1,61 @@
+SUMMARY = "eCMD"
+DESCRIPTION = "eCMD is a hardware access API for POWER Systems"
+LICENSE= "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${S}/NOTICE;md5=fee220301a2af3faf8f211524b4248ea"
+
+SRC_URI = "git://github.com/open-power/eCMD.git;branch=ecmd15;protocol=git"
+SRCREV = "15e382180d49f7ea4117ccc341ca91e361721fd4"
+
+inherit python3native
+DEPENDS = "zlib"
+
+S = "${WORKDIR}/git"
+
+export LD="${CXX}"
+export SLDFLAGS="${LDFLAGS}"
+
+# use native config.py to build required ecmd extensions
+do_configure() {
+   ${S}/config.py --without-swig --without-python --without-python3 --without-perl \
+       --without-pyecmd --install-path ${D}${prefix} --output-root ${B} --target ${TARGET_ARCH} \
+       --extensions "cmd cip"
+}
+
+do_compile() {
+    oe_runmake all
+}
+
+do_install() {
+    oe_runmake install
+
+    # we don't need the target scripts or ecmd setup
+    rm ${D}${bindir}/target.* ${D}${bindir}/ecmdsetup.pl
+
+    # ecmd installs to atypical places in the filesystem.
+    # move all the installed files to more conventional directories.
+    install -d ${D}${includedir} ${D}${datadir}/${BPN}/help ${D}${bindir} ${D}${libdir}
+    mv ${D}${prefix}/help/**  ${D}${datadir}/${BPN}/help
+    mv ${D}${prefix}/${TARGET_ARCH}/bin/**  ${D}${bindir}
+    mv ${D}${prefix}/${TARGET_ARCH}/lib/**  ${D}${libdir}
+
+    rm ${D}${bindir}/ecmdVersion
+
+    rmdir  ${D}${prefix}/help \
+        ${D}${prefix}/${TARGET_ARCH}/lib \
+        ${D}${prefix}/${TARGET_ARCH}/bin \
+        ${D}${prefix}/${TARGET_ARCH}/perl \
+        ${D}${prefix}/${TARGET_ARCH}
+}
+
+# ecmd makefile assumes that dependencies are built from left to right.
+PARALLEL_MAKE = ""
+
+# ecmd doesn't have proper library versioning
+FILES_${PN}-dev_remove = "${libdir}/lib*.so"
+FILES_${PN} += "${libdir}/lib*.so"
+
+RDEPENDS_${PN}-bin = "libecmd"
+
+# This allows someone to easily use ecmd bins, even if you don’t want them.
+PACKAGE_BEFORE_PN = "libecmd-bin"
+FILES_${PN}-bin += "${bindir}"