[11/20] Darwin support

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

Details

Message ID 1407352611-7652-11-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/c++.oeclass      |  3 ++
 classes/c.oeclass        |  8 ++++++
 classes/image-qa.oeclass | 74 +++++++++++++++++++++++++++++++++++++++++++-----
 classes/rpath.oeclass    |  4 +++
 conf/distro/common.inc   |  1 +
 conf/package.conf        |  2 ++
 conf/provided/osx.conf   |  2 ++
 lib/oelite/arch.py       |  6 ++++
 8 files changed, 93 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/classes/c++.oeclass b/classes/c++.oeclass
index f699ea9..15a8f96 100644
--- a/classes/c++.oeclass
+++ b/classes/c++.oeclass
@@ -74,6 +74,9 @@  TARGET_CXXFLAGS:canadian-cross	 = "${MACHINE_CXXFLAGS} \
 	-isystem ${MACHINE_SYSROOT}${machine_includedir}/c++/${GCC_VERSION}/${MACHINE_ARCH} \
 	-isystem ${MACHINE_SYSROOT}${machine_includedir}/c++/${GCC_VERSION}"
 
+HOST_CXXFLAGS:>HOST_KERNEL_darwin = " -mmacosx-version-min=${DARWIN_VERSION}"
+TARGET_CXXFLAGS:>TARGET_KERNEL_darwin = " -mmacosx-version-min=${DARWIN_VERSION}"
+
 # Local Variables:
 # mode: python
 # End:
diff --git a/classes/c.oeclass b/classes/c.oeclass
index 24abb90..1f54fbd 100644
--- a/classes/c.oeclass
+++ b/classes/c.oeclass
@@ -37,6 +37,9 @@  TARGET_CPPFLAGS:sdk-cross	 = "${SDK_CPPFLAGS} \
 TARGET_CPPFLAGS:canadian-cross	 = "${MACHINE_CPPFLAGS} \
 	--sysroot=${MACHINE_SYSROOT}"
 
+HOST_CFLAGS:>HOST_KERNEL_darwin = " -mmacosx-version-min=${DARWIN_VERSION}"
+TARGET_CFLAGS:>TARGET_KERNEL_darwin = " -mmacosx-version-min=${DARWIN_VERSION}"
+
 # CFLAGS
 export CFLAGS = "${HOST_CFLAGS}"
 export BUILD_CFLAGS
@@ -81,6 +84,10 @@  TARGET_CFLAGS_OPT:sdk		 = "${SDK_CFLAGS_OPT}"
 TARGET_CFLAGS_OPT:sdk-cross	 = "${SDK_CFLAGS_OPT}"
 TARGET_CFLAGS_OPT:canadian-cross = "${MACHINE_CFLAGS_OPT}"
 
+
+HOST_LDFLAGS:>HOST_KERNEL_darwin = " -mmacosx-version-min=${DARWIN_VERSION}"
+TARGET_LDFLAGS:>TARGET_KERNEL_darwin = " -mmacosx-version-min=${DARWIN_VERSION}"
+
 # LDFLAGS
 export LDFLAGS = "${HOST_LDFLAGS}"
 export BUILD_LDFLAGS
@@ -88,6 +95,7 @@  export BUILD_LDFLAGS
 BUILD_LDFLAGS		?= "-Wl,-O1 -Wl,-z -Wl,origin"
 BUILD_LDFLAGS:BUILD_KERNEL_darwin ?= ""
 MACHINE_LDFLAGS		?= "-Wl,-O1"
+MACHINE_LDFLAGS:TARGET_KERNEL_darwin ?= ""
 SDK_LDFLAGS		?= "-Wl,-O1"
 
 BUILD_LINK_HASH_STYLE	?= "gnu"
diff --git a/classes/image-qa.oeclass b/classes/image-qa.oeclass
index 491e45c..f7fba2c 100644
--- a/classes/image-qa.oeclass
+++ b/classes/image-qa.oeclass
@@ -26,16 +26,71 @@  inherit c
 
 do_imageqa[dirs] = "${IMAGE_DIR}"
 
+IMAGEQA_DARWIN_ASSUMED_LIBS ?= "\
+  usr/lib/libSystem.B.dylib \
+  System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices \
+  System/Library/Frameworks/Foundation.framework/Versions/C/Foundation \
+  System/Library/Frameworks/Carbon.framework/Versions/A/Carbon \
+  System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation \
+  System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa usr/lib/libSystem.B.dylib \
+  System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices \
+  usr/lib/libresolv.9.dylib \
+  usr/lib/libstdc++.6.dylib \
+  usr/lib/libgcc_s.1.dylib \
+  usr/lib/libobjc.A.dylib \
+  System/Library/Frameworks/AppKit.framework/Versions/C/AppKit \
+  System/Library/Frameworks/VideoDecodeAcceleration.framework/Versions/A/VideoDecodeAcceleration \
+  System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore \
+  System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL \
+  System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo \
+  System/Library/Frameworks/QTKit.framework/Versions/A/QTKit \
+  System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio \
+  System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit \
+  System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox \
+  usr/lib/libncurses.5.4.dylib \
+  usr/lib/libbz2.1.0.dylib \
+"
+
+IMAGEQA_READELF_RE = " 0x[0-9a-f]{8,16} *\(NEEDED\) *Shared library: \[(.*)\]"
+IMAGEQA_OTOOL_RE = "\s*/(\S+) \(.*\)"
+
+#
+# Host
+#
+
 IMAGEQA_HOST_READELF ?= "${HOST_PREFIX}readelf"
+IMAGEQA_HOST_OTOOL ?= "${HOST_PREFIX}otool"
+IMAGEQA_HOST_CMD = "${IMAGEQA_HOST_READELF} -d"
+IMAGEQA_HOST_CMD:HOST_KERNEL_darwin = "${IMAGEQA_HOST_OTOOL} -L"
+IMAGEQA_HOST_RE = "${IMAGEQA_READELF_RE}"
+IMAGEQA_HOST_RE:HOST_KERNEL_darwin = "${IMAGEQA_OTOOL_RE}"
+IMAGEQA_HOST_READELF_ASSUMED_LIBS:HOST_KERNEL_darwin = "${IMAGEQA_DARWIN_ASSUMED_LIBS}"
+
 IMAGEQA_HOST_READELF_SEARCH_DIRS ?= "\
 	${base_sbindir} ${base_bindir} ${sbindir} ${bindir} \
 	${base_libdir} ${libdir} ${base_sharedlibdir} ${sharedlibdir} \
 "
 IMAGEQA_HOST_READELF_LIB_DIRS ?= "\
-	${IMAGE_DIR}${base_libdir} ${IMAGE_DIR}${libdir}"
+	${IMAGE_DIR}${base_libdir} \
+	${IMAGE_DIR}${libdir} \
+	${IMAGE_DIR} \
+"
+
+#
+# Target
+#
 
 IMAGEQA_TARGET_READELF:machine ?= "${TARGET_PREFIX}readelf"
 IMAGEQA_TARGET_READELF:canadian-cross ?= "${TARGET_PREFIX}readelf"
+IMAGEQA_TARGET_OTOOL:machine ?= "${TARGET_PREFIX}otool"
+IMAGEQA_TARGET_OTOOL:canadian-cross ?= "${TARGET_PREFIX}otool"
+IMAGEQA_TARGET_CMD = "${IMAGEQA_TARGET_READELF} -d"
+IMAGEQA_TARGET_CMD:TARGET_KERNEL_darwin = "${IMAGEQA_TARGET_OTOOL} -L"
+IMAGEQA_TARGET_RE = "${IMAGEQA_READELF_RE}"
+IMAGEQA_TARGET_RE:TARGET_KERNEL_darwin = "${IMAGEQA_OTOOL_RE}"
+IMAGEQA_TARGET_READELF_ASSUMED_LIBS:TARGET_KERNEL_darwin = "${IMAGEQA_DARWIN_ASSUMED_LIBS}"
+
+
 IMAGEQA_TARGET_READELF_SEARCH_DIRS ?= "\
 	${TARGET_ARCH}/${TARGET_TYPE}${target_base_sbindir} \
 	${TARGET_ARCH}/${TARGET_TYPE}${target_base_bindir} \
@@ -44,9 +99,11 @@  IMAGEQA_TARGET_READELF_SEARCH_DIRS ?= "\
 	${TARGET_ARCH}/${TARGET_TYPE}${target_base_libdir} \
 	${TARGET_ARCH}/${TARGET_TYPE}${target_libdir} \
 "
+
 IMAGEQA_TARGET_READELF_LIB_DIRS ?= "\
 	${IMAGE_DIR}/${TARGET_ARCH}/${TARGET_TYPE}${target_base_libdir} \
 	${IMAGE_DIR}/${TARGET_ARCH}/${TARGET_TYPE}${target_libdir} \
+	${IMAGE_DIR}/${TARGET_ARCH}/${TARGET_TYPE} \
 "
 
 python do_imageqa () {
@@ -59,9 +116,10 @@  python do_imageqa () {
     filemagic.load()
 
     def readelf_check(arch):
-        readelf = d.getVar("IMAGEQA_"+arch+"_READELF", True)
-        if not readelf:
+        rcmd = d.getVar("IMAGEQA_"+arch+"_CMD", True)
+        if not rcmd:
             return None
+        rcmd = rcmd.split()
 
         oebakery.debug("Checking for missing %s libraries"%(arch.lower()))
         search_dirs = d.getVar("IMAGEQA_"+arch+"_READELF_SEARCH_DIRS", True).split()
@@ -88,14 +146,16 @@  python do_imageqa () {
                 if not "dynamically linked" in filetype:
                     continue
                 oebakery.debug("checking for needed libs")
-
-                cmd = [readelf, "-d", elffile]
+		
+                cmd = list(rcmd)
+                cmd.append(elffile)
                 try:
                     cmd = Popen(cmd, stdout=PIPE)
                 except OSError, e:
                     bb.fatal("Execution failed %s: %s" % (cmd, e))
 
-                needed_re = re.compile(r" 0x[0-9a-f]{8,16} *\(NEEDED\) *Shared library: \[(.*)\]")
+                libre = d.getVar("IMAGEQA_"+arch+"_RE", True)
+                needed_re = re.compile(libre)
 
                 needed_libs = []
                 for line in cmd.stdout.readlines():
@@ -106,7 +166,7 @@  python do_imageqa () {
                     oebakery.debug("%s: %s"%(elffile, " ".join(needed_libs)))
 
                 if cmd.wait():
-                    oebakery.warn("readelf %s failed"%(elffile))
+                    oebakery.warn("%s %s failed"%(rcmd,elffile))
 
                 missing_libs = []
                 for needed_lib in needed_libs:
diff --git a/classes/rpath.oeclass b/classes/rpath.oeclass
index fa2ec7d..69ddedb 100644
--- a/classes/rpath.oeclass
+++ b/classes/rpath.oeclass
@@ -6,14 +6,18 @@  CHRPATH_HOST	?= "${HOST_PREFIX}chrpath"
 CHRPATH_TARGET	?= "${TARGET_PREFIX}chrpath"
 
 CHRPATH_HOST:HOST_LIBC_mingw = ""
+CHRPATH_HOST:HOST_KERNEL_darwin = ""
 CHRPATH_TARGET:TARGET_LIBC_mingw = ""
+CHRPATH_TARGET:TARGET_KERNEL_darwin = ""
 
 CLASS_DEPENDS += "${CHRPATH_DEPENDS}"
 CHRPATH_DEPENDS = "${CHRPATH_DEPENDS_HOST} ${CHRPATH_DEPENDS_TARGET}"
 CHRPATH_DEPENDS_HOST = "host-cross:chrpath"
 CHRPATH_DEPENDS_HOST:HOST_LIBC_mingw = ""
+CHRPATH_DEPENDS_HOST:HOST_KERNEL_darwin = ""
 CHRPATH_DEPENDS_TARGET = "target-cross:chrpath"
 CHRPATH_DEPENDS_TARGET:TARGET_LIBC_mingw = ""
+CHRPATH_DEPENDS_TARGET:TARGET_KERNEL_darwin = ""
 CHRPATH_TYPES = "HOST TARGET"
 
 def chrpath_get_cmd(d,filetype):
diff --git a/conf/distro/common.inc b/conf/distro/common.inc
index 0a9e6af..2c3b8e1 100644
--- a/conf/distro/common.inc
+++ b/conf/distro/common.inc
@@ -1,6 +1,7 @@ 
 GCC_VERSION			?= "4.5.3"
 GCC_VERSION:TARGET_OS_mingw32	?= "4.5.3"
 CLANG_VERSION			?= "3.4"
+DARWIN_VERSION			?= "10.6"
 
 DISTRO_USE_sdk_linux_libc	?= "glibc:2.12.2"
 DISTRO_USE_sdk_windows_libc	?= "mingw:3.18"
diff --git a/conf/package.conf b/conf/package.conf
index fa2411e..dc9866e 100644
--- a/conf/package.conf
+++ b/conf/package.conf
@@ -15,8 +15,10 @@  HOMEPAGE	= "unknown"
 
 SOLIBS				= ".so.*"
 SOLIBS:HOST_LIBC_mingw		= "-*.dll"
+SOLIBS:HOST_KERNEL_darwin           = ".*.dylib"
 SOLIBSDEV			= ".so"
 SOLIBSDEV:HOST_LIBC_mingw	= ".dll.a"
+SOLIBSDEV:HOST_KERNEL_darwin        = ".dylib"
 
 PACKAGES	= "${PN}-dbg ${PN}-doc ${PN}-dev ${PN}-locale ${PN}"
 
diff --git a/conf/provided/osx.conf b/conf/provided/osx.conf
index a62dd54..6021f21 100644
--- a/conf/provided/osx.conf
+++ b/conf/provided/osx.conf
@@ -5,6 +5,7 @@  native:cc native:c++ native:libgcc native:libc \
 native:libgcc native:libdl native:libstdc++ native:libsupc++ \
 native:libresolv native:libutil native:libcrypt native:libpthread \
 native:libthread_db native:libbfd native:lib native:libm \
+native:libm-dev native:libc-dev native:libdl-dev native:libgcc-dev \
 native:librt native:libanl native:libBrokenLocale native:libnsl \
 native:libmemusage native:libpcprofile native:libSegFault \
 native:libnss_files native:libnss_dns native:libnss_compat \
@@ -22,6 +23,7 @@  native:texinfo native:doxygen \
 native:texlive-extra-utils native:texlive-latex-extra native:latex-xcolor \
 native:util-linux native:coreutils native:file \
 native:shasum \
+native:fakeroot \
 native:wget \
 native:flex native:bison \
 native:mtd-utils-mkfs-jffs2 \
diff --git a/lib/oelite/arch.py b/lib/oelite/arch.py
index ae52c5b..654f610 100644
--- a/lib/oelite/arch.py
+++ b/lib/oelite/arch.py
@@ -349,6 +349,9 @@  cpuspecs = {
             'march'		: 'athlon-4',
             'fpu'		: 'sse',
             },
+        'apple'			: {
+            'elf'		: 'Mach-O.* i386',
+            },
         },
 
     'i786'		: {
@@ -389,6 +392,9 @@  cpuspecs = {
         'amdfam10'		: {
             'march'		: 'amdfam10',
             },
+        'apple'			: {
+            'elf'		: 'Mach-O.* x86_64',
+            },
         },
 
     'ia64'		: {