[09/20] shared/static compilation It's allow from distro configure file to enable/disable shared/static version of a library. Maybe there is a way to make this method more generic and allow the modification of any recipe override.

Submitted by Yann Diorcet on Aug. 6, 2014, 7:16 p.m.

Details

Message ID 1407352611-7652-9-git-send-email-diorcet.yann@gmail.com
State New
Delegated to: Esben Haabendal
Headers show

Commit Message

Yann Diorcet Aug. 6, 2014, 7:16 p.m.
---
 classes/autotools.oeclass |  6 ++++++
 classes/make.oeclass      |  8 ++++++++
 conf/overrides.conf       | 20 ++++++++++++++++++++
 3 files changed, 34 insertions(+)

Patch hide | download patch | download mbox

diff --git a/classes/autotools.oeclass b/classes/autotools.oeclass
index c813da5..a2834ee 100644
--- a/classes/autotools.oeclass
+++ b/classes/autotools.oeclass
@@ -26,6 +26,11 @@  OECONF_ARCHTUPLE:>sdk-cross 		= " --target=${TARGET_ARCH}"
 OECONF_ARCHTUPLE:>canadian-cross	= " --target=${TARGET_ARCH}"
 OECONF_ARCHTUPLE[emit] = "do_configure"
 
+OECONF_STATIC = "--disable-static"
+OECONF_SHARED = "--disable-shared"
+OECONF_STATIC:STATIC = "--enable-static"
+OECONF_SHARED:SHARED = "--enable-shared"
+
 CONFIGURE_SCRIPT ?= "${S}/configure"
 
 autotools_configure () {
@@ -38,6 +43,7 @@  autotools_configure () {
  --sharedstatedir=${sharedstatedir} --localstatedir=${localstatedir}\
  --libdir=${libdir} --includedir=${includedir}\
  --infodir=${infodir} --mandir=${mandir}\
+ ${OECONF_SHARED} ${OECONF_STATIC}\
  ${EXTRA_OECONF} $@
     else
         oefatal "no configure script found"
diff --git a/classes/make.oeclass b/classes/make.oeclass
index aec7e24..1719746 100644
--- a/classes/make.oeclass
+++ b/classes/make.oeclass
@@ -13,6 +13,14 @@  require conf/make.conf
 
 export MAKE
 
+# Default flags for shared/static
+OECONF_SHARED_native ?= "true"
+OECONF_STATIC_native ?= "true"
+OECONF_SHARED_cross ?= "true"
+OECONF_STATIC_cross ?= "true"
+OECONF_SHARED_machine ?= "true"
+OECONF_STATIC_machine ?= "true"
+
 oe_runmake() {
 	${MAKE} $PARALLEL_MAKE ${EXTRA_OEMAKE} "$@"
 }
diff --git a/conf/overrides.conf b/conf/overrides.conf
index be02845..17eb95d 100644
--- a/conf/overrides.conf
+++ b/conf/overrides.conf
@@ -81,5 +81,25 @@  def late_overrides_fixup(d):
         if cpu == 'x86_64':
             overrides.insert(overrides.index('%s_CPU_${%s_CPU}'%(type, type)) + 1,
                              '%s_CPU_x86'%(type))
+
+    # Static/Shared
+    fmtPN = d.get("PN").replace("-","_").replace("+","p")
+    enable = d.get("OECONF_STATIC_" + fmtPN + "_" + d.get("RECIPE_TYPE"))
+    if enable:
+        if enable.lower() in ("yes", "true", "t", "1"):
+            overrides.append("STATIC")
+    else: 
+        enable = d.get("OECONF_STATIC_" + d.get("RECIPE_TYPE"))
+        if enable and enable.lower() in ("yes", "true", "t", "1"):
+            overrides.append("STATIC")
+    enable = d.get("OECONF_SHARED_" + fmtPN + "_" + d.get("RECIPE_TYPE"))
+    if enable:
+        if enable.lower() in ("yes", "true", "t", "1"):
+            overrides.append("SHARED")
+    else: 
+        enable = d.get("OECONF_SHARED_" + d.get("RECIPE_TYPE"))
+        if enable and enable.lower() in ("yes", "true", "t", "1"):
+            overrides.append("SHARED")
+
     d.set("OVERRIDES", ":".join(overrides))
     return