Glib patch for Gnome-glib android build
authorRahul Rahul <rahul.rahul@intel.com>
Thu, 9 Apr 2015 21:47:17 +0000 (14:47 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 9 Apr 2015 22:00:05 +0000 (22:00 +0000)
Added boost dependency in the scons script.
The scons build script downloads the appropriate boost version for
android, unpacks and builds it.

This also builds C++ liboc library but not the examples.

Change-Id: I54d1a938e249a3e251d8508180c8cd103420d70f
Signed-off-by: jnashok <jn.ashok@samsung.com>
Signed-off-by: Rahul Rahul <rahul.rahul@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/623
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
25 files changed:
SConstruct
build_common/android/SConscript
extlibs/boost/SConscript [new file with mode: 0644]
extra_options.scons
resource/SConscript
resource/csdk/SConscript
resource/csdk/connectivity/build/android/SConscript
resource/csdk/connectivity/build/android/jni/Android.mk
resource/csdk/connectivity/common/SConscript
resource/csdk/connectivity/lib/android/glib_build.sh [new file with mode: 0644]
resource/csdk/connectivity/lib/android/glibpatch_Readme.txt [new file with mode: 0644]
resource/csdk/connectivity/lib/android/jni/Android.mk [new file with mode: 0644]
resource/csdk/connectivity/lib/android/jni/Application.mk [new file with mode: 0644]
resource/csdk/connectivity/lib/android/patches/glib-2.40.2-withoutMakefile.patch [new file with mode: 0644]
resource/csdk/connectivity/lib/android/patches/glib-2.40.2-x64-withoutMakefile.patch [new file with mode: 0644]
resource/csdk/connectivity/lib/android/patches/glib-2.40.2-x64.patch [new file with mode: 0644]
resource/csdk/connectivity/lib/android/patches/glib-2.40.2.patch [new file with mode: 0644]
resource/csdk/connectivity/src/SConscript
resource/csdk/connectivity/src/bt_edr_adapter/SConscript
resource/oc_logger/SConscript
tools/scons/BoostBootstrap.py [new file with mode: 0644]
tools/scons/BoostBuild.py [new file with mode: 0644]
tools/scons/Configure.py [new file with mode: 0644]
tools/scons/URLDownload.py [new file with mode: 0644]
tools/scons/UnpackAll.py [new file with mode: 0644]

index 318541f..939ac6a 100644 (file)
@@ -47,11 +47,12 @@ build_dir = env.get('BUILD_DIR')
 # Build 'resource' sub-project
 SConscript(build_dir + 'resource/SConscript')
 
-if target_os not in ['arduino','darwin','ios']:
+if target_os not in ['arduino','darwin','ios', 'android']:
        SConscript(build_dir + 'examples/OICMiddle/SConscript')
 
 # Build 'service' sub-project
-SConscript(build_dir + 'service/SConscript')
+if target_os != 'android':
+       SConscript(build_dir + 'service/SConscript')
 
 # Append targets information to the help information, to see help info, execute command line:
 #     $ scon [options] -h
index 5cc203d..d8c2dec 100644 (file)
@@ -23,6 +23,19 @@ if not android_ndk:
 '''
        Exit(1)
 
+# check 'glib' library
+src_dir = env.get('SRC_DIR')
+if not os.path.exists(src_dir + '/extlibs/glib'):
+       print '''
+*********************************** Error: **************************************
+*  glib' library doesn't exist. please download gnome glib to extlibs directory *
+*  apply the patch as following:                                                *
+* Download the Gnome Glib from http://ftp.gnome.org/pub/GNOME/sources/glib/2.40/*
+* Please go through build instructions at :                                     *
+* resource/csdk/connectivity/lib/android/glibpatch_Readme.txt
+*********************************************************************************
+       '''
+
 # Overwrite suffixes and prefixes
 if env['HOST_OS'] == 'win32':
        env['OBJSUFFIX'] = '.o'
@@ -142,6 +155,17 @@ for flags in p.stdout.readlines():
                if not platform_ver.isdigit():
                        platform_ver = ''
 
+# Determine dependency faux SYS_ROOT
+dep_sys_root = os.path.join(env.get('SRC_DIR'), 'dep', 'android', target_arch, 'usr')
+dep_src_dir =  os.path.join(dep_sys_root, 'include')
+dep_lib_dir =  os.path.join(dep_sys_root, 'lib')
+
+env['DEP_SYS_ROOT'] = dep_sys_root
+
+# Add external libraries including boost
+env.AppendUnique(CPPPATH = [ dep_src_dir ])
+env.AppendUnique(LIBPATH = [ dep_lib_dir ])
+
 ######################################################################
 # Set release/debug flags
 ######################################################################
@@ -152,6 +176,24 @@ if env.get('RELEASE'):
 else:
        env.AppendUnique(CCFLAGS = ['-g'])
 
+if env.get('LOGGING'):
+        env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
+
+
+env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__ANDROID__'])
+env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
+#env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
+
+env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+env.AppendUnique(LIBPATH = [src_dir + '/resource/csdk/connectivity/lib/android'])
+env.AppendUnique(LIBS = ['log', 'glib-2.40.2', 'gthread-2.40.2', 'coap'])
+
+glib_dir = src_dir + '/extlibs/glib/glib-2.40.2/'
+env.AppendUnique(CPPPATH = [
+                           glib_dir,
+                           glib_dir + 'glib',
+                           glib_dir + 'gthread'])
+
 # From android-5 (API > 20), all application must be built with flags '-fPIE' '-pie'.
 # Due to the limitation of Scons, it's required to added it into the command line
 # directly (otherwise, it will also be added when build share library)
@@ -164,3 +206,6 @@ if platform_ver == '' or int(platform_ver) > 20:
        SConscript('compatibility/c_compat.scons')
 
 SConscript('compatibility/cpp11_compat.scons')
+
+# Make sure that boost for android is available
+SConscript(env.get('SRC_DIR') + '/extlibs/boost/SConscript')
diff --git a/extlibs/boost/SConscript b/extlibs/boost/SConscript
new file mode 100644 (file)
index 0000000..516174b
--- /dev/null
@@ -0,0 +1,53 @@
+import os, string, sys
+
+Import('env')
+
+modules = ['thread','program_options']
+
+target_os = env.get('TARGET_OS')
+
+if 'linux' == target_os :
+    # Check for Boost libraries in /usr/boost
+    print 'TODO: Perform platform check for linux'
+    raise SCons.Errors.EnvironmentError('Unsupported platform')
+
+if 'android' == target_os :
+    env.Tool('URLDownload',    toolpath=['../../tools/scons'])
+    env.Tool('UnpackAll',      toolpath=['../../tools/scons'])
+    env.Tool('BoostBootstrap', toolpath=['../../tools/scons'])
+    env.Tool('BoostBuild',     toolpath=['../../tools/scons'])
+
+    boost_version   = '1.57.0'
+    boost_base_name  = 'boost_'+string.replace(boost_version,'.','_')
+    boost_arch_name  = boost_base_name+'.zip'
+    boost_url       = 'http://downloads.sourceforge.net/project/boost/boost/'+boost_version+'/'+boost_arch_name+'?r=&ts=1421801329&use_mirror=iweb'
+
+    host_os = sys.platform
+
+    if host_os == 'linux2' :
+        boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh'
+        boost_b2_name    = boost_base_name+os.sep+'b2'
+    else :
+        msg="Host platform (%s) is currently not supported for boost builds" % host_os
+        raise SCons.Errors.EnvironmentError(msg)
+
+    boost_zip = env.URLDownload(boost_arch_name, boost_url)
+    boost_dir = env.UnpackAll(boost_bootstrap, boost_zip)
+    boost_b2  = env.BoostBootstrap(boost_b2_name, boost_dir)
+
+    dep_sys_root = env['DEP_SYS_ROOT']
+    dep_src_dir =  dep_sys_root + os.sep + 'include'
+    dep_lib_dir =  dep_sys_root + os.sep + 'lib'
+
+    boost_targets = [
+        os.path.join(dep_src_dir, 'boost', 'config.hpp'),
+        os.path.join(dep_src_dir, 'boost', 'variant.hpp'),
+        os.path.join(dep_src_dir, 'boost', 'program_options.hpp'),
+        os.path.join(dep_src_dir, 'libboost_thread.a'),
+        os.path.join(dep_src_dir, 'libboost_atomic.a'),
+        os.path.join(dep_src_dir, 'libboost_system.a'),
+        os.path.join(dep_src_dir, 'libboost_program_options.a')
+        ]
+
+    boost_build = env.BoostBuild(boost_targets, boost_b2, PREFIX=dep_sys_root, MODULES=modules)
+
index 2ceb100..d0dfca4 100644 (file)
@@ -44,4 +44,3 @@ if not os.path.exists(src_dir + '/extlibs/cereal'):
 *********************************************************************************
 '''
        Exit(1)
-
index 8673abf..58540c9 100644 (file)
@@ -46,6 +46,7 @@ if target_os not in ['arduino','darwin']:
        # Build liboc
        SConscript('src/SConscript')
 
+if target_os not in ['arduino','darwin', 'android']:
        # Build examples
        SConscript('examples/SConscript')
 
index fb6a9cd..c11ee98 100644 (file)
@@ -68,7 +68,8 @@ if target_os == 'arduino':
        liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
 elif target_os not in ['darwin','ios']:
        liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
-
+if target_os == 'android':     
+       liboctbstack_env.AppendUnique(LIBS = ['connectivity_abstraction'])
 if target_os in ['darwin', 'ios']:
        liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
        liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
index 3d5249a..f70355e 100644 (file)
@@ -157,16 +157,19 @@ else:
 env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__ANDROID__'])
 if env.get('LOGGING'):
        env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
-env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC','`pkg-config','--cflags','glib-2.0`'])
-env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread', '-lglib-2.0', '-lgthread-2.0', '-llog', '-landroid'])
+env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
+env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
 
-env.Append(LIBS=[
-  '-lglib-2.0', '-lgthread-2.0'
-])
+main_dir  = Dir('.').srcnode().abspath
+
+glib_dir = main_dir + '/../../../../../extlibs/glib/glib-2.40.2/'
+env.AppendUnique(CPPPATH = [
+                           glib_dir,
+                           glib_dir + 'glib',
+                           glib_dir + 'gthread'])
 
 # From android-5 (API > 20), all application must be built with flags '-fPIE' '-pie'.
 # Due to the limitation of Scons, it's required to added it into the command line
 # directly (otherwise, it will also be added when build share library)
 env.Replace(CCCOM = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM -fPIE $SOURCES')
 env.Replace(CXXCOM = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM -fPIE $SOURCES')
-env.Replace(LINKCOM = '$LINK -o $TARGET -pie $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS')
index 9d4f9e8..13e9d4d 100644 (file)
@@ -6,11 +6,12 @@ PROJECT_API_PATH                      = $(PROJECT_ROOT_PATH)/api
 PROJECT_INC_PATH                       = $(PROJECT_ROOT_PATH)/inc
 PROJECT_SRC_PATH                       = $(PROJECT_ROOT_PATH)/src
 PROJECT_COMMON_PATH                    = $(PROJECT_ROOT_PATH)/common
-PROJECT_COMMON_INC_PATH                = $(PROJECT_COMMON_PATH)/inc
-PROJECT_COMMON_SRC_PATH                = $(PROJECT_COMMON_PATH)/src
+PROJECT_COMMON_INC_PATH                        = $(PROJECT_COMMON_PATH)/inc
+PROJECT_COMMON_SRC_PATH                        = $(PROJECT_COMMON_PATH)/src
 PROJECT_LIB_PATH                       = $(PROJECT_ROOT_PATH)/lib
-PROJECT_EXTERNAL_PATH  = $(PROJECT_ROOT_PATH)/external/inc
-DTLS_LIB                                       = $(PROJECT_LIB_PATH)/tinydtls
+PROJECT_EXTERNAL_PATH                  = $(PROJECT_ROOT_PATH)/external/inc
+DTLS_LIB                               = $(PROJECT_LIB_PATH)/tinydtls
+GLIB_PATH                              = $(PROJECT_LIB_PATH)/android/glib-2.40.2
 
 #Modify below values to enable/disable the Adapter
 #Suffix "NO_" to disable given adapter
@@ -38,8 +39,8 @@ include $(CLEAR_VARS)
 LOCAL_PATH = $(PROJECT_LIB_PATH)/android
 LOCAL_MODULE = Glib
 LOCAL_SRC_FILES := libglib-2.40.2.so
-LOCAL_EXPORT_C_INCLUDES = $(PROJECT_LIB_PATH)/android/glib-2.40.2 \
-                          $(PROJECT_LIB_PATH)/android/glib-2.40.2/glib
+LOCAL_EXPORT_C_INCLUDES = $(GLIB_PATH) \
+                          $(GLIB_PATH)/glib
 
 include $(PREBUILT_SHARED_LIBRARY)
 
@@ -50,8 +51,8 @@ include $(CLEAR_VARS)
 LOCAL_PATH = $(PROJECT_LIB_PATH)/android
 LOCAL_MODULE = GLibThread
 LOCAL_SRC_FILES := libgthread-2.40.2.so
-LOCAL_EXPORT_C_INCLUDES = $(PROJECT_LIB_PATH)/android/glib-2.40.2 \
-                          $(PROJECT_LIB_PATH)/android/glib-2.40.2/glib
+LOCAL_EXPORT_C_INCLUDES = $(GLIB_PATH) \
+                          $(GLIB_PATH)/glib
 
 include $(PREBUILT_SHARED_LIBRARY)
 
index 3ef0295..a44e8ca 100644 (file)
@@ -7,14 +7,18 @@ Import('env')
 print "Reading common folder script"
 
 ca_os = env.get('TARGET_OS')
+
 root_dir = './../'
-ca_common_path = root_dir + '/common/'
+
+
+ca_common_path = root_dir + 'common/'
 ca_common_src_path = ca_common_path + 'src/'
 
 env.AppendUnique(CPPPATH = [
        'common/inc/',
        ])
 
+
 temp = env['CPPPATH']
 header = ' '
 for item in temp:
diff --git a/resource/csdk/connectivity/lib/android/glib_build.sh b/resource/csdk/connectivity/lib/android/glib_build.sh
new file mode 100644 (file)
index 0000000..89ad3ce
--- /dev/null
@@ -0,0 +1,28 @@
+#/******************************************************************
+#*
+#* Copyright 2015 Samsung Electronics All Rights Reserved.
+#*
+#*
+#*
+#* Licensed under the Apache License, Version 2.0 (the "License");
+#* you may not use this file except in compliance with the License.
+#* You may obtain a copy of the License at
+#*
+#*      http://www.apache.org/licenses/LICENSE-2.0
+#*
+#* Unless required by applicable law or agreed to in writing, software
+#* distributed under the License is distributed on an "AS IS" BASIS,
+#* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#* See the License for the specific language governing permissions and
+#* limitations under the License.
+#*
+#******************************************************************/
+rm -f *.so
+
+set NDK_PATH="~/ndk"
+$NDK_PATH/ndk-build clean
+$NDK_PATH/ndk-build
+
+#change the folder path as per TARGET_ARCH
+cp libs/armeabi/*.* .
+
diff --git a/resource/csdk/connectivity/lib/android/glibpatch_Readme.txt b/resource/csdk/connectivity/lib/android/glibpatch_Readme.txt
new file mode 100644 (file)
index 0000000..21e1b91
--- /dev/null
@@ -0,0 +1,94 @@
+/******************************************************************
+*
+* Copyright 2014 Samsung Electronics All Rights Reserved.
+*
+*
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+******************************************************************/
+
+Pre-requisites :
+Install libffi6 and libffi-dev packages
+#sudo apt-get install libffi6 libffi-dev
+
+
+Download Gnome Glib 2.40.2 from http://ftp.gnome.org/pub/GNOME/sources/glib/2.40/
+1.Download glib-2.40.2.tar.xz
+
+2.untar the Downloaded file
+#tar -xJf glib-2.40.2.tar.xz
+
+3.change to glib-2.40.2 directory
+#cd glib-2.40.2
+
+4.
+#./configure
+
+5.If configure is successful, your base folder is ready to apply the patch :
+#cd ..
+#patch -p1 < resource/csdk/connectivity/lib/android/patches/glib-2.40.2.patch
+
+There are two kinds of patches :
+       - with Android.mk files, automatically added in the respective folders
+       - without Android.mk files (If you want to use your own Android.mk files)
+
+       glib-2.40.2.patch
+       glib-2.40.2-wihtoutMakefile.patch
+
+       glib-2.40.2-x64.patch
+       glib-2.40.2-x64-wihtoutMakefile.patch
+
+If you are using 64-bit linux build, please apply the patch named with "x64"
+
+6.To build glib libraries for Android, Andoroid.mk and Application.mk are placed at
+resource/csdk/connectivity/lib/android/jni
+#cd resource/csdk/connectivity/lib/android
+
+7.Edit the resource/csdk/connectivity/lib/android/jni/Android.mk
+#vi jni/Android.mk
+
+8.Copy your glib-2.40.2 directory to extlibs/glib.
+Edit the GLIB_SRC_PATH and add the path to glib source directory
+GLIB_SRC_PATH ?= ../../../../../extlibs/glib/glib-2.40.2
+
+9a-1.run the ndk-build
+#$(NDK_PATH)/ndk-build
+
+9a-2.copy libglib-2.40.2.so and libgthread-2.40.2.so from libs/armeabi folder to
+resource/csdk/connectivity/lib/android directory
+Change the folder path as per the TARGET_ARCH
+#cp libs/armeabi/*.* ./
+
+or
+
+9b-1.
+#chmod 777 ./glib_build.sh
+
+9b-2. Edit the NDK_PATH and set the ndk folder path
+#vi glib_build.sh
+NDK_PATH = ~/ndk
+
+9b-3 Edit the folder path as per TARGET_ARCH
+#cp libs/armeabi/*.* .
+
+9b-4.
+#./glib_build.sh
+
+10.This will build the glib libraries and copy to the current folder
+
+11. To build with NDK Edit the resource/csdk/connectivity/build/Android.mk file.
+set the GLIB_PATH to your glib-2.40.2 folder path.
+
+GLIB_PATH                              = $(PROJECT_LIB_PATH)/android/glib-2.40.2
+
diff --git a/resource/csdk/connectivity/lib/android/jni/Android.mk b/resource/csdk/connectivity/lib/android/jni/Android.mk
new file mode 100644 (file)
index 0000000..a8f7bf9
--- /dev/null
@@ -0,0 +1,36 @@
+#/******************************************************************
+#*
+#* Copyright 2015 Samsung Electronics All Rights Reserved.
+#*
+#*
+#*
+#* Licensed under the Apache License, Version 2.0 (the "License");
+#* you may not use this file except in compliance with the License.
+#* You may obtain a copy of the License at
+#*
+#*      http://www.apache.org/licenses/LICENSE-2.0
+#*
+#* Unless required by applicable law or agreed to in writing, software
+#* distributed under the License is distributed on an "AS IS" BASIS,
+#* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#* See the License for the specific language governing permissions and
+#* limitations under the License.
+#*
+#******************************************************************/
+#define build type
+BUILD = debug
+
+#you can set the path to ../../../../../extlibs/glib
+GLIB_SRC_PATH  ?= $(YOUR_GLIB_PATH)/glib-2.40.2
+
+DEFINE_FLAG = -D__ANDROID__
+
+
+BUILD_FLAG.debug       = $(DEFINE_FLAG)
+BUILD_FLAG = $(BUILD_FLAG.$(BUILD))
+
+LOCAL_PATH = ../
+
+#Build glib
+include $(CLEAR_VARS)
+include $(GLIB_SRC_PATH)/Android.mk
diff --git a/resource/csdk/connectivity/lib/android/jni/Application.mk b/resource/csdk/connectivity/lib/android/jni/Application.mk
new file mode 100644 (file)
index 0000000..914642b
--- /dev/null
@@ -0,0 +1,28 @@
+#/******************************************************************
+#*
+#* Copyright 2015 Samsung Electronics All Rights Reserved.
+#*
+#*
+#*
+#* Licensed under the Apache License, Version 2.0 (the "License");
+#* you may not use this file except in compliance with the License.
+#* You may obtain a copy of the License at
+#*
+#*      http://www.apache.org/licenses/LICENSE-2.0
+#*
+#* Unless required by applicable law or agreed to in writing, software
+#* distributed under the License is distributed on an "AS IS" BASIS,
+#* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#* See the License for the specific language governing permissions and
+#* limitations under the License.
+#*
+#******************************************************************/
+
+#Specify Android.mk path w.r.t APPLICATION_BUILD in the Makefile
+APP_PROJECT_PATH = ./
+
+APP_STL = gnustl_shared
+APP_PLATFORM = android-19
+APP_CPPFLAGS += -fexceptions
+APP_CPPFLAGS += -frtti += -Wno-error=format-security
+APP_CFLAGS = -Wno-error=format-security
diff --git a/resource/csdk/connectivity/lib/android/patches/glib-2.40.2-withoutMakefile.patch b/resource/csdk/connectivity/lib/android/patches/glib-2.40.2-withoutMakefile.patch
new file mode 100644 (file)
index 0000000..9f9db8c
--- /dev/null
@@ -0,0 +1,289 @@
+diff -rupN glibref/glib-2.40.2/config.h glibpatch/glib-2.40.2/config.h
+--- glibref/glib-2.40.2/config.h       2015-03-31 16:25:56.882894898 +0900
++++ glibpatch/glib-2.40.2/config.h     2015-04-01 13:21:19.593558693 +0900
+@@ -31,8 +31,9 @@
+ /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
+ /* always defined to indicate that i18n is enabled */
++#ifndef _GLIB_ANDROID_
+ #define ENABLE_NLS 1
+-
++#endif /* _GLIB_ANDROID__ */
+ /* Define the gettext package to be used */
+ #define GETTEXT_PACKAGE "glib20"
+@@ -100,8 +101,9 @@
+ /* #undef HAVE_COCOA */
+ /* Have nl_langinfo (CODESET) */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_CODESET 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <crt_externs.h> header file. */
+ /* #undef HAVE_CRT_EXTERNS_H */
+@@ -130,8 +132,10 @@
+ /* we have the eventfd(2) system call */
+ #define HAVE_EVENTFD 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `fallocate' function. */
+ #define HAVE_FALLOCATE 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define if we have FAM */
+ /* #undef HAVE_FAM */
+@@ -224,6 +228,7 @@
+ /* Define to 1 if you have the `kqueue' function. */
+ /* #undef HAVE_KQUEUE */
++#ifndef _GLIB_ANDROID_
+ /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+ #define HAVE_LANGINFO_CODESET 1
+@@ -232,6 +237,7 @@
+ /* Have nl_langinfo (PM_STR) */
+ #define HAVE_LANGINFO_TIME 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `lchmod' function. */
+ /* #undef HAVE_LCHMOD */
+@@ -283,9 +289,10 @@
+ /* Define to 1 if you have the <memory.h> header file. */
+ #define HAVE_MEMORY_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `mmap' function. */
+ #define HAVE_MMAP 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <mntent.h> header file. */
+ #define HAVE_MNTENT_H 1
+@@ -317,8 +324,10 @@
+ /* Have POSIX function getgrgid_r */
+ #define HAVE_POSIX_GETGRGID_R 1
++#ifndef _GLIB_ANDROID_
+ /* Have POSIX function getpwuid_r */
+ #define HAVE_POSIX_GETPWUID_R 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `posix_memalign' function. */
+ #define HAVE_POSIX_MEMALIGN 1
+@@ -333,8 +342,11 @@
+ #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+ /* Have function pthread_cond_timedwait_relative_np */
++#ifndef _GLIB_ANDROID_
+ /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
+-
++#else
++#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if the system has the type `ptrdiff_t'. */
+ #define HAVE_PTRDIFF_T 1
+@@ -384,8 +396,10 @@
+ /* Define to 1 if you have the <stdlib.h> header file. */
+ #define HAVE_STDLIB_H 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `stpcpy' function. */
+ #define HAVE_STPCPY 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `strcasecmp' function. */
+ #define HAVE_STRCASECMP 1
+@@ -532,10 +546,10 @@
+ /* Define to 1 if you have the <sys/xattr.h> header file. */
+ #define HAVE_SYS_XATTR_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `timegm' function. */
+ #define HAVE_TIMEGM 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <unistd.h> header file. */
+ #define HAVE_UNISTD_H 1
+@@ -563,7 +577,7 @@
+ /* Define to 1 if you have the `vsnprintf' function. */
+ #define HAVE_VSNPRINTF 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define if you have the 'wchar_t' type. */
+ #define HAVE_WCHAR_T 1
+@@ -575,12 +589,14 @@
+ /* Define to 1 if xattr is available */
+ #define HAVE_XATTR 1
+-
++#endif
+ /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
+ /* #undef HAVE_XATTR_NOFOLLOW */
+ /* Define to 1 if you have the <xlocale.h> header file. */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_XLOCALE_H 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `_NSGetEnviron' function. */
+ /* #undef HAVE__NSGETENVIRON */
+diff -rupN glibref/glib-2.40.2/glib/gconvert.c glibpatch/glib-2.40.2/glib/gconvert.c
+--- glibref/glib-2.40.2/glib/gconvert.c        2015-03-31 16:25:56.946894901 +0900
++++ glibpatch/glib-2.40.2/glib/gconvert.c      2015-03-31 16:40:50.546926503 +0900
+@@ -22,7 +22,11 @@
+ #include "glibconfig.h"
+ #ifndef G_OS_WIN32
++
++#ifndef _GLIB_ANDROID_
+ #include <iconv.h>
++#endif /* _GLIB_ANDROID_ */
++
+ #endif
+ #include <errno.h>
+ #include <stdio.h>
+@@ -168,6 +172,7 @@
+ G_DEFINE_QUARK (g_convert_error, g_convert_error)
++#ifndef _GLIB_ANDROID_
+ static gboolean
+ try_conversion (const char *to_codeset,
+               const char *from_codeset,
+@@ -197,9 +202,9 @@ try_to_aliases (const char **to_aliases,
+         p++;
+       }
+     }
+-
+   return FALSE;
+ }
++#endif /* _GLIB_ANDROID_ */
+ /**
+  * g_iconv_open:
+@@ -220,6 +225,7 @@ GIConv
+ g_iconv_open (const gchar  *to_codeset,
+             const gchar  *from_codeset)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd;
+   
+   if (!try_conversion (to_codeset, from_codeset, &cd))
+@@ -248,6 +254,9 @@ g_iconv_open (const gchar  *to_codeset,
+  out:
+   return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
++#else
++  return (GIConv)-1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -274,9 +283,13 @@ g_iconv (GIConv   converter,
+        gchar  **outbuf,
+        gsize   *outbytes_left)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -297,9 +310,13 @@ g_iconv (GIConv   converter,
+ gint
+ g_iconv_close (GIConv converter)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv_close (cd);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ static GIConv
+diff -rupN glibref/glib-2.40.2/glib/gfileutils.c glibpatch/glib-2.40.2/glib/gfileutils.c
+--- glibref/glib-2.40.2/glib/gfileutils.c      2015-03-31 16:25:57.170894910 +0900
++++ glibpatch/glib-2.40.2/glib/gfileutils.c    2015-03-31 16:37:29.594919396 +0900
+@@ -54,7 +54,9 @@
+ #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
+ #include <linux/magic.h>
++#ifndef _GLIB_ANDROID_
+ #include <sys/vfs.h>
++#endif /* _GLIB_ANDROID_ */
+ #endif
+diff -rupN glibref/glib-2.40.2/glib/ggettext.c glibpatch/glib-2.40.2/glib/ggettext.c
+--- glibref/glib-2.40.2/glib/ggettext.c        2015-03-31 16:25:57.182894907 +0900
++++ glibpatch/glib-2.40.2/glib/ggettext.c      2015-03-31 16:37:55.538920314 +0900
+@@ -40,7 +40,10 @@
+ #include <string.h>
+ #include <locale.h>
++
++#ifndef _GLIB_ANDROID_
+ #include <libintl.h>
++#endif /* _GLIB_ANDROID_ */
+ #ifdef G_OS_WIN32
+diff -rupN glibref/glib-2.40.2/glib/glibconfig.h glibpatch/glib-2.40.2/glib/glibconfig.h
+--- glibref/glib-2.40.2/glib/glibconfig.h      2015-03-31 16:25:57.166894909 +0900
++++ glibpatch/glib-2.40.2/glib/glibconfig.h    2015-03-31 16:38:06.954920717 +0900
+@@ -154,7 +154,9 @@ typedef unsigned int guintptr;
+ #define G_THREADS_ENABLED
+ #define G_THREADS_IMPL_POSIX
++#ifndef _GLIB_ANDROID_
+ #define G_ATOMIC_LOCK_FREE
++#endif /* _GLIB_ANDROID_ */
+ #define GINT16_TO_LE(val)     ((gint16) (val))
+ #define GUINT16_TO_LE(val)    ((guint16) (val))
+diff -rupN glibref/glib-2.40.2/glib/gslice.c glibpatch/glib-2.40.2/glib/gslice.c
+--- glibref/glib-2.40.2/glib/gslice.c  2015-03-31 16:25:56.946894901 +0900
++++ glibpatch/glib-2.40.2/glib/gslice.c        2015-03-31 16:38:38.302921827 +0900
+@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
+        * This way it's possible to force gslice to be enabled under
+        * valgrind just by setting G_SLICE to the empty string.
+        */
++ #ifndef _GLIB_ANDROID_
+       if (RUNNING_ON_VALGRIND)
++#endif /* _GLIB_ANDROID_ */
+         config->always_malloc = TRUE;
+     }
+ }
+diff -rupN glibref/glib-2.40.2/glib/gstrfuncs.c glibpatch/glib-2.40.2/glib/gstrfuncs.c
+--- glibref/glib-2.40.2/glib/gstrfuncs.c       2015-03-31 16:25:56.950894901 +0900
++++ glibpatch/glib-2.40.2/glib/gstrfuncs.c     2015-03-31 16:39:00.154922598 +0900
+@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
+ const guint16 * const g_ascii_table = ascii_table_data;
++#ifndef _GLIB_ANDROID_
+ #if defined (HAVE_NEWLOCALE) && \
+     defined (HAVE_USELOCALE) && \
+     defined (HAVE_STRTOD_L) && \
+@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
+     defined (HAVE_STRTOLL_L)
+ #define USE_XLOCALE 1
+ #endif
++#endif /* _GLIB_ANDROID_ */
+ #ifdef USE_XLOCALE
+ static locale_t
diff --git a/resource/csdk/connectivity/lib/android/patches/glib-2.40.2-x64-withoutMakefile.patch b/resource/csdk/connectivity/lib/android/patches/glib-2.40.2-x64-withoutMakefile.patch
new file mode 100644 (file)
index 0000000..ee75f35
--- /dev/null
@@ -0,0 +1,456 @@
+diff -rupN glibremake/glibbase/glib-2.40.2/config.h glibremake/glib-2.40.2/config.h
+--- glibremake/glibbase/glib-2.40.2/config.h   2015-03-31 18:56:48.099484578 +0900
++++ glibremake/glib-2.40.2/config.h    2015-03-31 19:36:57.139558379 +0900
+@@ -8,10 +8,10 @@
+ #define ALIGNOF_GUINT32 4
+ /* The normal alignment of `guint64', in bytes. */
+-#define ALIGNOF_GUINT64 8
++#define ALIGNOF_GUINT64 4
+ /* The normal alignment of `unsigned long', in bytes. */
+-#define ALIGNOF_UNSIGNED_LONG 8
++#define ALIGNOF_UNSIGNED_LONG 4
+ /* poll doesn't work on devices */
+ /* #undef BROKEN_POLL */
+@@ -31,8 +31,9 @@
+ /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
+ /* always defined to indicate that i18n is enabled */
++#ifndef _GLIB_ANDROID_
+ #define ENABLE_NLS 1
+-
++#endif /* _GLIB_ANDROID__ */
+ /* Define the gettext package to be used */
+ #define GETTEXT_PACKAGE "glib20"
+@@ -100,8 +101,9 @@
+ /* #undef HAVE_COCOA */
+ /* Have nl_langinfo (CODESET) */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_CODESET 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <crt_externs.h> header file. */
+ /* #undef HAVE_CRT_EXTERNS_H */
+@@ -130,8 +132,10 @@
+ /* we have the eventfd(2) system call */
+ #define HAVE_EVENTFD 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `fallocate' function. */
+ #define HAVE_FALLOCATE 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define if we have FAM */
+ /* #undef HAVE_FAM */
+@@ -224,6 +228,7 @@
+ /* Define to 1 if you have the `kqueue' function. */
+ /* #undef HAVE_KQUEUE */
++#ifndef _GLIB_ANDROID_
+ /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+ #define HAVE_LANGINFO_CODESET 1
+@@ -232,6 +237,7 @@
+ /* Have nl_langinfo (PM_STR) */
+ #define HAVE_LANGINFO_TIME 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `lchmod' function. */
+ /* #undef HAVE_LCHMOD */
+@@ -283,9 +289,10 @@
+ /* Define to 1 if you have the <memory.h> header file. */
+ #define HAVE_MEMORY_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `mmap' function. */
+ #define HAVE_MMAP 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <mntent.h> header file. */
+ #define HAVE_MNTENT_H 1
+@@ -317,8 +324,10 @@
+ /* Have POSIX function getgrgid_r */
+ #define HAVE_POSIX_GETGRGID_R 1
++#ifndef _GLIB_ANDROID_
+ /* Have POSIX function getpwuid_r */
+ #define HAVE_POSIX_GETPWUID_R 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `posix_memalign' function. */
+ #define HAVE_POSIX_MEMALIGN 1
+@@ -333,8 +342,11 @@
+ #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+ /* Have function pthread_cond_timedwait_relative_np */
++#ifndef _GLIB_ANDROID_
+ /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
+-
++#else
++#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if the system has the type `ptrdiff_t'. */
+ #define HAVE_PTRDIFF_T 1
+@@ -384,8 +396,10 @@
+ /* Define to 1 if you have the <stdlib.h> header file. */
+ #define HAVE_STDLIB_H 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `stpcpy' function. */
+ #define HAVE_STPCPY 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `strcasecmp' function. */
+ #define HAVE_STRCASECMP 1
+@@ -532,10 +546,10 @@
+ /* Define to 1 if you have the <sys/xattr.h> header file. */
+ #define HAVE_SYS_XATTR_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `timegm' function. */
+ #define HAVE_TIMEGM 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <unistd.h> header file. */
+ #define HAVE_UNISTD_H 1
+@@ -563,7 +577,7 @@
+ /* Define to 1 if you have the `vsnprintf' function. */
+ #define HAVE_VSNPRINTF 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define if you have the 'wchar_t' type. */
+ #define HAVE_WCHAR_T 1
+@@ -575,12 +589,14 @@
+ /* Define to 1 if xattr is available */
+ #define HAVE_XATTR 1
+-
++#endif
+ /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
+ /* #undef HAVE_XATTR_NOFOLLOW */
+ /* Define to 1 if you have the <xlocale.h> header file. */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_XLOCALE_H 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `_NSGetEnviron' function. */
+ /* #undef HAVE__NSGETENVIRON */
+@@ -628,7 +644,7 @@
+ #define SIZEOF_INT 4
+ /* The size of `long', as computed by sizeof. */
+-#define SIZEOF_LONG 8
++#define SIZEOF_LONG 4
+ /* The size of `long long', as computed by sizeof. */
+ #define SIZEOF_LONG_LONG 8
+@@ -637,13 +653,13 @@
+ #define SIZEOF_SHORT 2
+ /* The size of `size_t', as computed by sizeof. */
+-#define SIZEOF_SIZE_T 8
++#define SIZEOF_SIZE_T 4
+ /* The size of `ssize_t', as computed by sizeof. */
+-#define SIZEOF_SSIZE_T 8
++#define SIZEOF_SSIZE_T 4
+ /* The size of `void *', as computed by sizeof. */
+-#define SIZEOF_VOID_P 8
++#define SIZEOF_VOID_P 4
+ /* The size of `__int64', as computed by sizeof. */
+ #define SIZEOF___INT64 0
+@@ -720,13 +736,8 @@
+ # endif
+ #endif
+-/* Enable large inode numbers on Mac OS X 10.5.  */
+-#ifndef _DARWIN_USE_64_BIT_INODE
+-# define _DARWIN_USE_64_BIT_INODE 1
+-#endif
+-
+ /* Number of bits in a file offset, on hosts where this is settable. */
+-/* #undef _FILE_OFFSET_BITS */
++#define _FILE_OFFSET_BITS 64
+ /* defines how to decorate public symbols while building */
+ #define _GLIB_EXTERN __attribute__((visibility("default"))) extern
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gconvert.c glibremake/glib-2.40.2/glib/gconvert.c
+--- glibremake/glibbase/glib-2.40.2/glib/gconvert.c    2015-03-31 18:56:47.783484568 +0900
++++ glibremake/glib-2.40.2/glib/gconvert.c     2015-03-31 19:00:09.863490759 +0900
+@@ -22,7 +22,11 @@
+ #include "glibconfig.h"
+ #ifndef G_OS_WIN32
++
++#ifndef _GLIB_ANDROID_
+ #include <iconv.h>
++#endif /* _GLIB_ANDROID_ */
++
+ #endif
+ #include <errno.h>
+ #include <stdio.h>
+@@ -168,6 +172,7 @@
+ G_DEFINE_QUARK (g_convert_error, g_convert_error)
++#ifndef _GLIB_ANDROID_
+ static gboolean
+ try_conversion (const char *to_codeset,
+               const char *from_codeset,
+@@ -200,6 +205,7 @@ try_to_aliases (const char **to_aliases,
+   return FALSE;
+ }
++#endif /* _GLIB_ANDROID_ */
+ /**
+  * g_iconv_open:
+@@ -220,6 +226,7 @@ GIConv
+ g_iconv_open (const gchar  *to_codeset,
+             const gchar  *from_codeset)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd;
+   
+   if (!try_conversion (to_codeset, from_codeset, &cd))
+@@ -248,6 +255,9 @@ g_iconv_open (const gchar  *to_codeset,
+  out:
+   return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
++#else
++  return (GIConv)-1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -274,9 +284,13 @@ g_iconv (GIConv   converter,
+        gchar  **outbuf,
+        gsize   *outbytes_left)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -297,9 +311,13 @@ g_iconv (GIConv   converter,
+ gint
+ g_iconv_close (GIConv converter)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv_close (cd);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ static GIConv
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gfileutils.c glibremake/glib-2.40.2/glib/gfileutils.c
+--- glibremake/glibbase/glib-2.40.2/glib/gfileutils.c  2015-03-31 18:56:47.687484565 +0900
++++ glibremake/glib-2.40.2/glib/gfileutils.c   2015-03-31 18:59:50.395490162 +0900
+@@ -54,7 +54,7 @@
+ #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
+ #include <linux/magic.h>
+-#include <sys/vfs.h>
++//#include <sys/vfs.h>
+ #endif
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/ggettext.c glibremake/glib-2.40.2/glib/ggettext.c
+--- glibremake/glibbase/glib-2.40.2/glib/ggettext.c    2015-03-31 18:56:47.687484565 +0900
++++ glibremake/glib-2.40.2/glib/ggettext.c     2015-03-31 19:27:28.671540964 +0900
+@@ -40,7 +40,10 @@
+ #include <string.h>
+ #include <locale.h>
++
++#ifndef _GLIB_ANDROID_
+ #include <libintl.h>
++#endif /* _GLIB_ANDROID_ */
+ #ifdef G_OS_WIN32
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/glibconfig.h glibremake/glib-2.40.2/glib/glibconfig.h
+--- glibremake/glibbase/glib-2.40.2/glib/glibconfig.h  2015-03-31 18:56:47.783484568 +0900
++++ glibremake/glib-2.40.2/glib/glibconfig.h   2015-03-31 19:33:14.071551545 +0900
+@@ -48,30 +48,30 @@ typedef unsigned int guint32;
+ #define G_GUINT32_FORMAT "u"
+ #define G_HAVE_GINT64 1          /* deprecated, always true */
+-typedef signed long gint64;
+-typedef unsigned long guint64;
++G_GNUC_EXTENSION typedef signed long long gint64;
++G_GNUC_EXTENSION typedef unsigned long long guint64;
+-#define G_GINT64_CONSTANT(val)        (val##L)
+-#define G_GUINT64_CONSTANT(val)       (val##UL)
+-#define G_GINT64_MODIFIER "l"
+-#define G_GINT64_FORMAT "li"
+-#define G_GUINT64_FORMAT "lu"
+-
+-#define GLIB_SIZEOF_VOID_P 8
+-#define GLIB_SIZEOF_LONG   8
+-#define GLIB_SIZEOF_SIZE_T 8
+-#define GLIB_SIZEOF_SSIZE_T 8
+-
+-typedef signed long gssize;
+-typedef unsigned long gsize;
+-#define G_GSIZE_MODIFIER "l"
+-#define G_GSSIZE_MODIFIER "l"
+-#define G_GSIZE_FORMAT "lu"
+-#define G_GSSIZE_FORMAT "li"
+-
+-#define G_MAXSIZE     G_MAXULONG
+-#define G_MINSSIZE    G_MINLONG
+-#define G_MAXSSIZE    G_MAXLONG
++#define G_GINT64_CONSTANT(val)        (G_GNUC_EXTENSION (val##LL))
++#define G_GUINT64_CONSTANT(val)       (G_GNUC_EXTENSION (val##ULL))
++#define G_GINT64_MODIFIER "ll"
++#define G_GINT64_FORMAT "lli"
++#define G_GUINT64_FORMAT "llu"
++
++#define GLIB_SIZEOF_VOID_P 4
++#define GLIB_SIZEOF_LONG   4
++#define GLIB_SIZEOF_SIZE_T 4
++#define GLIB_SIZEOF_SSIZE_T 4
++
++typedef signed int gssize;
++typedef unsigned int gsize;
++#define G_GSIZE_MODIFIER ""
++#define G_GSSIZE_MODIFIER ""
++#define G_GSIZE_FORMAT "u"
++#define G_GSSIZE_FORMAT "i"
++
++#define G_MAXSIZE     G_MAXUINT
++#define G_MINSSIZE    G_MININT
++#define G_MAXSSIZE    G_MAXINT
+ typedef gint64 goffset;
+ #define G_MINOFFSET   G_MININT64
+@@ -82,18 +82,18 @@ typedef gint64 goffset;
+ #define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
+-#define GPOINTER_TO_INT(p)    ((gint)  (glong) (p))
+-#define GPOINTER_TO_UINT(p)   ((guint) (gulong) (p))
++#define GPOINTER_TO_INT(p)    ((gint)  (gint) (p))
++#define GPOINTER_TO_UINT(p)   ((guint) (guint) (p))
+-#define GINT_TO_POINTER(i)    ((gpointer) (glong) (i))
+-#define GUINT_TO_POINTER(u)   ((gpointer) (gulong) (u))
++#define GINT_TO_POINTER(i)    ((gpointer) (gint) (i))
++#define GUINT_TO_POINTER(u)   ((gpointer) (guint) (u))
+-typedef signed long gintptr;
+-typedef unsigned long guintptr;
++typedef signed int gintptr;
++typedef unsigned int guintptr;
+-#define G_GINTPTR_MODIFIER      "l"
+-#define G_GINTPTR_FORMAT        "li"
+-#define G_GUINTPTR_FORMAT       "lu"
++#define G_GINTPTR_MODIFIER      ""
++#define G_GINTPTR_FORMAT        "i"
++#define G_GUINTPTR_FORMAT       "u"
+ #ifndef G_DISABLE_DEPRECATED
+ #define g_ATEXIT(proc)        (atexit (proc))
+ #define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
+@@ -107,7 +107,6 @@ typedef unsigned long guintptr;
+ #define G_VA_COPY     va_copy
+-#define G_VA_COPY_AS_ARRAY 1
+ #ifdef        __cplusplus
+ #define       G_HAVE_INLINE   1
+@@ -155,7 +154,9 @@ typedef unsigned long guintptr;
+ #define G_THREADS_ENABLED
+ #define G_THREADS_IMPL_POSIX
++#ifndef _GLIB_ANDROID_
+ #define G_ATOMIC_LOCK_FREE
++#endif /* _GLIB_ANDROID_ */
+ #define GINT16_TO_LE(val)     ((gint16) (val))
+ #define GUINT16_TO_LE(val)    ((guint16) (val))
+@@ -169,18 +170,18 @@ typedef unsigned long guintptr;
+ #define GUINT64_TO_LE(val)    ((guint64) (val))
+ #define GINT64_TO_BE(val)     ((gint64) GUINT64_SWAP_LE_BE (val))
+ #define GUINT64_TO_BE(val)    (GUINT64_SWAP_LE_BE (val))
+-#define GLONG_TO_LE(val)      ((glong) GINT64_TO_LE (val))
+-#define GULONG_TO_LE(val)     ((gulong) GUINT64_TO_LE (val))
+-#define GLONG_TO_BE(val)      ((glong) GINT64_TO_BE (val))
+-#define GULONG_TO_BE(val)     ((gulong) GUINT64_TO_BE (val))
++#define GLONG_TO_LE(val)      ((glong) GINT32_TO_LE (val))
++#define GULONG_TO_LE(val)     ((gulong) GUINT32_TO_LE (val))
++#define GLONG_TO_BE(val)      ((glong) GINT32_TO_BE (val))
++#define GULONG_TO_BE(val)     ((gulong) GUINT32_TO_BE (val))
+ #define GINT_TO_LE(val)               ((gint) GINT32_TO_LE (val))
+ #define GUINT_TO_LE(val)      ((guint) GUINT32_TO_LE (val))
+ #define GINT_TO_BE(val)               ((gint) GINT32_TO_BE (val))
+ #define GUINT_TO_BE(val)      ((guint) GUINT32_TO_BE (val))
+-#define GSIZE_TO_LE(val)      ((gsize) GUINT64_TO_LE (val))
+-#define GSSIZE_TO_LE(val)     ((gssize) GINT64_TO_LE (val))
+-#define GSIZE_TO_BE(val)      ((gsize) GUINT64_TO_BE (val))
+-#define GSSIZE_TO_BE(val)     ((gssize) GINT64_TO_BE (val))
++#define GSIZE_TO_LE(val)      ((gsize) GUINT32_TO_LE (val))
++#define GSSIZE_TO_LE(val)     ((gssize) GINT32_TO_LE (val))
++#define GSIZE_TO_BE(val)      ((gsize) GUINT32_TO_BE (val))
++#define GSSIZE_TO_BE(val)     ((gssize) GINT32_TO_BE (val))
+ #define G_BYTE_ORDER G_LITTLE_ENDIAN
+ #define GLIB_SYSDEF_POLLIN =1
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gslice.c glibremake/glib-2.40.2/glib/gslice.c
+--- glibremake/glibbase/glib-2.40.2/glib/gslice.c      2015-03-31 18:56:47.775484568 +0900
++++ glibremake/glib-2.40.2/glib/gslice.c       2015-03-31 18:57:16.255485440 +0900
+@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
+        * This way it's possible to force gslice to be enabled under
+        * valgrind just by setting G_SLICE to the empty string.
+        */
++ #if 0
+       if (RUNNING_ON_VALGRIND)
++#endif          
+         config->always_malloc = TRUE;
+     }
+ }
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c glibremake/glib-2.40.2/glib/gstrfuncs.c
+--- glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c   2015-03-31 18:56:47.683484565 +0900
++++ glibremake/glib-2.40.2/glib/gstrfuncs.c    2015-03-31 18:57:07.783485181 +0900
+@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
+ const guint16 * const g_ascii_table = ascii_table_data;
++#ifndef _GLIB_ANDROID_
+ #if defined (HAVE_NEWLOCALE) && \
+     defined (HAVE_USELOCALE) && \
+     defined (HAVE_STRTOD_L) && \
+@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
+     defined (HAVE_STRTOLL_L)
+ #define USE_XLOCALE 1
+ #endif
++#endif /* _GLIB_ANDROID_ */
+ #ifdef USE_XLOCALE
+ static locale_t
diff --git a/resource/csdk/connectivity/lib/android/patches/glib-2.40.2-x64.patch b/resource/csdk/connectivity/lib/android/patches/glib-2.40.2-x64.patch
new file mode 100644 (file)
index 0000000..1d0b47f
--- /dev/null
@@ -0,0 +1,670 @@
+diff -rupN glibremake/glibbase/glib-2.40.2/Android.mk glibremake/glib-2.40.2/Android.mk
+--- glibremake/glibbase/glib-2.40.2/Android.mk 1970-01-01 09:00:00.000000000 +0900
++++ glibremake/glib-2.40.2/Android.mk  2015-03-31 19:38:39.067561502 +0900
+@@ -0,0 +1,14 @@
++#GLIB Android Makefile to build GLIB modules
++
++LOCAL_PATH            := $(call my-dir)
++GLIB_MAIN_DIR := $(LOCAL_PATH)
++
++GLIB_C_INCLUDES       := $(GLIB_MAIN_DIR) \
++                 $(GLIB_MAIN_DIR)/glib
++
++GTHREAD_C_INCLUDES    := $(GLIB_MAIN_DIR) \
++                         $(GLIB_MAIN_DIR)/gthread
++
++include $(GLIB_MAIN_DIR)/glib/Android.mk
++include $(GLIB_MAIN_DIR)/gthread/Android.mk
++
+diff -rupN glibremake/glibbase/glib-2.40.2/config.h glibremake/glib-2.40.2/config.h
+--- glibremake/glibbase/glib-2.40.2/config.h   2015-03-31 18:56:48.099484578 +0900
++++ glibremake/glib-2.40.2/config.h    2015-03-31 19:36:57.139558379 +0900
+@@ -8,10 +8,10 @@
+ #define ALIGNOF_GUINT32 4
+ /* The normal alignment of `guint64', in bytes. */
+-#define ALIGNOF_GUINT64 8
++#define ALIGNOF_GUINT64 4
+ /* The normal alignment of `unsigned long', in bytes. */
+-#define ALIGNOF_UNSIGNED_LONG 8
++#define ALIGNOF_UNSIGNED_LONG 4
+ /* poll doesn't work on devices */
+ /* #undef BROKEN_POLL */
+@@ -31,8 +31,9 @@
+ /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
+ /* always defined to indicate that i18n is enabled */
++#ifndef _GLIB_ANDROID_
+ #define ENABLE_NLS 1
+-
++#endif /* _GLIB_ANDROID__ */
+ /* Define the gettext package to be used */
+ #define GETTEXT_PACKAGE "glib20"
+@@ -100,8 +101,9 @@
+ /* #undef HAVE_COCOA */
+ /* Have nl_langinfo (CODESET) */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_CODESET 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <crt_externs.h> header file. */
+ /* #undef HAVE_CRT_EXTERNS_H */
+@@ -130,8 +132,10 @@
+ /* we have the eventfd(2) system call */
+ #define HAVE_EVENTFD 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `fallocate' function. */
+ #define HAVE_FALLOCATE 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define if we have FAM */
+ /* #undef HAVE_FAM */
+@@ -224,6 +228,7 @@
+ /* Define to 1 if you have the `kqueue' function. */
+ /* #undef HAVE_KQUEUE */
++#ifndef _GLIB_ANDROID_
+ /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+ #define HAVE_LANGINFO_CODESET 1
+@@ -232,6 +237,7 @@
+ /* Have nl_langinfo (PM_STR) */
+ #define HAVE_LANGINFO_TIME 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `lchmod' function. */
+ /* #undef HAVE_LCHMOD */
+@@ -283,9 +289,10 @@
+ /* Define to 1 if you have the <memory.h> header file. */
+ #define HAVE_MEMORY_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `mmap' function. */
+ #define HAVE_MMAP 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <mntent.h> header file. */
+ #define HAVE_MNTENT_H 1
+@@ -317,8 +324,10 @@
+ /* Have POSIX function getgrgid_r */
+ #define HAVE_POSIX_GETGRGID_R 1
++#ifndef _GLIB_ANDROID_
+ /* Have POSIX function getpwuid_r */
+ #define HAVE_POSIX_GETPWUID_R 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `posix_memalign' function. */
+ #define HAVE_POSIX_MEMALIGN 1
+@@ -333,8 +342,11 @@
+ #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+ /* Have function pthread_cond_timedwait_relative_np */
++#ifndef _GLIB_ANDROID_
+ /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
+-
++#else
++#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if the system has the type `ptrdiff_t'. */
+ #define HAVE_PTRDIFF_T 1
+@@ -384,8 +396,10 @@
+ /* Define to 1 if you have the <stdlib.h> header file. */
+ #define HAVE_STDLIB_H 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `stpcpy' function. */
+ #define HAVE_STPCPY 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `strcasecmp' function. */
+ #define HAVE_STRCASECMP 1
+@@ -532,10 +546,10 @@
+ /* Define to 1 if you have the <sys/xattr.h> header file. */
+ #define HAVE_SYS_XATTR_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `timegm' function. */
+ #define HAVE_TIMEGM 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <unistd.h> header file. */
+ #define HAVE_UNISTD_H 1
+@@ -563,7 +577,7 @@
+ /* Define to 1 if you have the `vsnprintf' function. */
+ #define HAVE_VSNPRINTF 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define if you have the 'wchar_t' type. */
+ #define HAVE_WCHAR_T 1
+@@ -575,12 +589,14 @@
+ /* Define to 1 if xattr is available */
+ #define HAVE_XATTR 1
+-
++#endif
+ /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
+ /* #undef HAVE_XATTR_NOFOLLOW */
+ /* Define to 1 if you have the <xlocale.h> header file. */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_XLOCALE_H 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `_NSGetEnviron' function. */
+ /* #undef HAVE__NSGETENVIRON */
+@@ -628,7 +644,7 @@
+ #define SIZEOF_INT 4
+ /* The size of `long', as computed by sizeof. */
+-#define SIZEOF_LONG 8
++#define SIZEOF_LONG 4
+ /* The size of `long long', as computed by sizeof. */
+ #define SIZEOF_LONG_LONG 8
+@@ -637,13 +653,13 @@
+ #define SIZEOF_SHORT 2
+ /* The size of `size_t', as computed by sizeof. */
+-#define SIZEOF_SIZE_T 8
++#define SIZEOF_SIZE_T 4
+ /* The size of `ssize_t', as computed by sizeof. */
+-#define SIZEOF_SSIZE_T 8
++#define SIZEOF_SSIZE_T 4
+ /* The size of `void *', as computed by sizeof. */
+-#define SIZEOF_VOID_P 8
++#define SIZEOF_VOID_P 4
+ /* The size of `__int64', as computed by sizeof. */
+ #define SIZEOF___INT64 0
+@@ -720,13 +736,8 @@
+ # endif
+ #endif
+-/* Enable large inode numbers on Mac OS X 10.5.  */
+-#ifndef _DARWIN_USE_64_BIT_INODE
+-# define _DARWIN_USE_64_BIT_INODE 1
+-#endif
+-
+ /* Number of bits in a file offset, on hosts where this is settable. */
+-/* #undef _FILE_OFFSET_BITS */
++#define _FILE_OFFSET_BITS 64
+ /* defines how to decorate public symbols while building */
+ #define _GLIB_EXTERN __attribute__((visibility("default"))) extern
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/Android.mk glibremake/glib-2.40.2/glib/Android.mk
+--- glibremake/glibbase/glib-2.40.2/glib/Android.mk    1970-01-01 09:00:00.000000000 +0900
++++ glibremake/glib-2.40.2/glib/Android.mk     2015-03-31 19:40:22.323564665 +0900
+@@ -0,0 +1,115 @@
++#glib Android Make File
++
++LOCAL_PATH            := $(call my-dir)
++
++include $(CLEAR_VARS)
++
++LOCAL_MODULE  := glib-2.40.2
++
++LOCAL_SRC_FILES       := \
++    libcharset/localcharset.c \
++    garray.c        \
++    gasyncqueue.c   \
++    gatomic.c       \
++    gbacktrace.c    \
++    gbase64.c       \
++    gbitlock.c      \
++    gbookmarkfile.c \
++    gbytes.c      \
++    gcharset.c      \
++    gchecksum.c     \
++    gconvert.c      \
++    gdataset.c      \
++    gdate.c         \
++    gdatetime.c     \
++    gdir.c          \
++    gerror.c        \
++    genviron.c      \
++    gfileutils.c    \
++    ggettext.c            \
++    ghash.c         \
++    ghmac.c         \
++    ghook.c         \
++    ghostutils.c    \
++    giochannel.c    \
++    gkeyfile.c      \
++    glib-init.c           \
++    glib-private.c  \
++    glib-unix.c     \
++    glist.c         \
++    gmain.c         \
++    gmappedfile.c   \
++    gmarkup.c       \
++    gmem.c          \
++    gmessages.c     \
++    gnode.c         \
++    goption.c       \
++    gpattern.c      \
++    gpoll.c         \
++    gprimes.c       \
++    gqsort.c        \
++    gquark.c        \
++    gqueue.c        \
++    grand.c         \
++    gregex.c        \
++    gscanner.c      \
++    gsequence.c     \
++    gshell.c        \
++    gslice.c        \
++    gslist.c        \
++    gstdio.c        \
++    gstrfuncs.c     \
++    gstring.c       \
++    gstringchunk.c  \
++    gtestutils.c    \
++    gthread.c       \
++    gthreadpool.c   \
++    gthread-posix.c \
++    gtimer.c        \
++    gtimezone.c     \
++    gtranslit.c     \
++    gtrashstack.c   \
++    gtree.c         \
++    guniprop.c      \
++    gutf8.c         \
++    gunibreak.c     \
++    gunicollate.c   \
++    gunidecomp.c    \
++    gurifuncs.c     \
++    gutils.c        \
++    gvariant.c      \
++    gvariant-core.c \
++    gvariant-parser.c \
++    gvariant-serialiser.c \
++    gvarianttypeinfo.c \
++    gvarianttype.c  \
++    gprintf.c       \
++    giounix.c       \
++    gspawn.c        \
++    gversion.c      \
++    gwakeup.c
++
++LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
++                  $(GLIB_MAIN_DIR)/glib \
++                  $(GLIB_MAIN_DIR)/glib/deprecated \
++                  $(GLIB_MAIN_DIR)/glib/libcharset \
++                  $(GLIB_MAIN_DIR)/pcre \
++
++LOCAL_STATIC_LIBRARIES := pcre
++
++LOCAL_LD_LIBS := -llog
++
++LOCAL_CFLAGS  := \
++      -D_GLIB_ANDROID_ \
++      -DLIBDIR=\"$(libdir)\" \
++      -DHAVE_CONFIG_H \
++      -DG_LOG_DOMAIN=\"GLib\" \
++      -DGLIB_COMPILATION \
++      -DPCRE_STATIC \
++      -DG_DISABLE_CAST_CHECKS
++
++include $(BUILD_SHARED_LIBRARY)
++
++include       $(GLIB_MAIN_DIR)/glib/pcre/Android.mk
++
++
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gconvert.c glibremake/glib-2.40.2/glib/gconvert.c
+--- glibremake/glibbase/glib-2.40.2/glib/gconvert.c    2015-03-31 18:56:47.783484568 +0900
++++ glibremake/glib-2.40.2/glib/gconvert.c     2015-03-31 19:00:09.863490759 +0900
+@@ -22,7 +22,11 @@
+ #include "glibconfig.h"
+ #ifndef G_OS_WIN32
++
++#ifndef _GLIB_ANDROID_
+ #include <iconv.h>
++#endif /* _GLIB_ANDROID_ */
++
+ #endif
+ #include <errno.h>
+ #include <stdio.h>
+@@ -168,6 +172,7 @@
+ G_DEFINE_QUARK (g_convert_error, g_convert_error)
++#ifndef _GLIB_ANDROID_
+ static gboolean
+ try_conversion (const char *to_codeset,
+               const char *from_codeset,
+@@ -200,6 +205,7 @@ try_to_aliases (const char **to_aliases,
+   return FALSE;
+ }
++#endif /* _GLIB_ANDROID_ */
+ /**
+  * g_iconv_open:
+@@ -220,6 +226,7 @@ GIConv
+ g_iconv_open (const gchar  *to_codeset,
+             const gchar  *from_codeset)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd;
+   
+   if (!try_conversion (to_codeset, from_codeset, &cd))
+@@ -248,6 +255,9 @@ g_iconv_open (const gchar  *to_codeset,
+  out:
+   return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
++#else
++  return (GIConv)-1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -274,9 +284,13 @@ g_iconv (GIConv   converter,
+        gchar  **outbuf,
+        gsize   *outbytes_left)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -297,9 +311,13 @@ g_iconv (GIConv   converter,
+ gint
+ g_iconv_close (GIConv converter)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv_close (cd);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ static GIConv
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gfileutils.c glibremake/glib-2.40.2/glib/gfileutils.c
+--- glibremake/glibbase/glib-2.40.2/glib/gfileutils.c  2015-03-31 18:56:47.687484565 +0900
++++ glibremake/glib-2.40.2/glib/gfileutils.c   2015-03-31 18:59:50.395490162 +0900
+@@ -54,7 +54,7 @@
+ #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
+ #include <linux/magic.h>
+-#include <sys/vfs.h>
++//#include <sys/vfs.h>
+ #endif
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/ggettext.c glibremake/glib-2.40.2/glib/ggettext.c
+--- glibremake/glibbase/glib-2.40.2/glib/ggettext.c    2015-03-31 18:56:47.687484565 +0900
++++ glibremake/glib-2.40.2/glib/ggettext.c     2015-03-31 19:27:28.671540964 +0900
+@@ -40,7 +40,10 @@
+ #include <string.h>
+ #include <locale.h>
++
++#ifndef _GLIB_ANDROID_
+ #include <libintl.h>
++#endif /* _GLIB_ANDROID_ */
+ #ifdef G_OS_WIN32
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/glibconfig.h glibremake/glib-2.40.2/glib/glibconfig.h
+--- glibremake/glibbase/glib-2.40.2/glib/glibconfig.h  2015-03-31 18:56:47.783484568 +0900
++++ glibremake/glib-2.40.2/glib/glibconfig.h   2015-03-31 19:33:14.071551545 +0900
+@@ -48,30 +48,30 @@ typedef unsigned int guint32;
+ #define G_GUINT32_FORMAT "u"
+ #define G_HAVE_GINT64 1          /* deprecated, always true */
+-typedef signed long gint64;
+-typedef unsigned long guint64;
++G_GNUC_EXTENSION typedef signed long long gint64;
++G_GNUC_EXTENSION typedef unsigned long long guint64;
+-#define G_GINT64_CONSTANT(val)        (val##L)
+-#define G_GUINT64_CONSTANT(val)       (val##UL)
+-#define G_GINT64_MODIFIER "l"
+-#define G_GINT64_FORMAT "li"
+-#define G_GUINT64_FORMAT "lu"
+-
+-#define GLIB_SIZEOF_VOID_P 8
+-#define GLIB_SIZEOF_LONG   8
+-#define GLIB_SIZEOF_SIZE_T 8
+-#define GLIB_SIZEOF_SSIZE_T 8
+-
+-typedef signed long gssize;
+-typedef unsigned long gsize;
+-#define G_GSIZE_MODIFIER "l"
+-#define G_GSSIZE_MODIFIER "l"
+-#define G_GSIZE_FORMAT "lu"
+-#define G_GSSIZE_FORMAT "li"
+-
+-#define G_MAXSIZE     G_MAXULONG
+-#define G_MINSSIZE    G_MINLONG
+-#define G_MAXSSIZE    G_MAXLONG
++#define G_GINT64_CONSTANT(val)        (G_GNUC_EXTENSION (val##LL))
++#define G_GUINT64_CONSTANT(val)       (G_GNUC_EXTENSION (val##ULL))
++#define G_GINT64_MODIFIER "ll"
++#define G_GINT64_FORMAT "lli"
++#define G_GUINT64_FORMAT "llu"
++
++#define GLIB_SIZEOF_VOID_P 4
++#define GLIB_SIZEOF_LONG   4
++#define GLIB_SIZEOF_SIZE_T 4
++#define GLIB_SIZEOF_SSIZE_T 4
++
++typedef signed int gssize;
++typedef unsigned int gsize;
++#define G_GSIZE_MODIFIER ""
++#define G_GSSIZE_MODIFIER ""
++#define G_GSIZE_FORMAT "u"
++#define G_GSSIZE_FORMAT "i"
++
++#define G_MAXSIZE     G_MAXUINT
++#define G_MINSSIZE    G_MININT
++#define G_MAXSSIZE    G_MAXINT
+ typedef gint64 goffset;
+ #define G_MINOFFSET   G_MININT64
+@@ -82,18 +82,18 @@ typedef gint64 goffset;
+ #define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
+-#define GPOINTER_TO_INT(p)    ((gint)  (glong) (p))
+-#define GPOINTER_TO_UINT(p)   ((guint) (gulong) (p))
++#define GPOINTER_TO_INT(p)    ((gint)  (gint) (p))
++#define GPOINTER_TO_UINT(p)   ((guint) (guint) (p))
+-#define GINT_TO_POINTER(i)    ((gpointer) (glong) (i))
+-#define GUINT_TO_POINTER(u)   ((gpointer) (gulong) (u))
++#define GINT_TO_POINTER(i)    ((gpointer) (gint) (i))
++#define GUINT_TO_POINTER(u)   ((gpointer) (guint) (u))
+-typedef signed long gintptr;
+-typedef unsigned long guintptr;
++typedef signed int gintptr;
++typedef unsigned int guintptr;
+-#define G_GINTPTR_MODIFIER      "l"
+-#define G_GINTPTR_FORMAT        "li"
+-#define G_GUINTPTR_FORMAT       "lu"
++#define G_GINTPTR_MODIFIER      ""
++#define G_GINTPTR_FORMAT        "i"
++#define G_GUINTPTR_FORMAT       "u"
+ #ifndef G_DISABLE_DEPRECATED
+ #define g_ATEXIT(proc)        (atexit (proc))
+ #define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
+@@ -107,7 +107,6 @@ typedef unsigned long guintptr;
+ #define G_VA_COPY     va_copy
+-#define G_VA_COPY_AS_ARRAY 1
+ #ifdef        __cplusplus
+ #define       G_HAVE_INLINE   1
+@@ -155,7 +154,9 @@ typedef unsigned long guintptr;
+ #define G_THREADS_ENABLED
+ #define G_THREADS_IMPL_POSIX
++#ifndef _GLIB_ANDROID_
+ #define G_ATOMIC_LOCK_FREE
++#endif /* _GLIB_ANDROID_ */
+ #define GINT16_TO_LE(val)     ((gint16) (val))
+ #define GUINT16_TO_LE(val)    ((guint16) (val))
+@@ -169,18 +170,18 @@ typedef unsigned long guintptr;
+ #define GUINT64_TO_LE(val)    ((guint64) (val))
+ #define GINT64_TO_BE(val)     ((gint64) GUINT64_SWAP_LE_BE (val))
+ #define GUINT64_TO_BE(val)    (GUINT64_SWAP_LE_BE (val))
+-#define GLONG_TO_LE(val)      ((glong) GINT64_TO_LE (val))
+-#define GULONG_TO_LE(val)     ((gulong) GUINT64_TO_LE (val))
+-#define GLONG_TO_BE(val)      ((glong) GINT64_TO_BE (val))
+-#define GULONG_TO_BE(val)     ((gulong) GUINT64_TO_BE (val))
++#define GLONG_TO_LE(val)      ((glong) GINT32_TO_LE (val))
++#define GULONG_TO_LE(val)     ((gulong) GUINT32_TO_LE (val))
++#define GLONG_TO_BE(val)      ((glong) GINT32_TO_BE (val))
++#define GULONG_TO_BE(val)     ((gulong) GUINT32_TO_BE (val))
+ #define GINT_TO_LE(val)               ((gint) GINT32_TO_LE (val))
+ #define GUINT_TO_LE(val)      ((guint) GUINT32_TO_LE (val))
+ #define GINT_TO_BE(val)               ((gint) GINT32_TO_BE (val))
+ #define GUINT_TO_BE(val)      ((guint) GUINT32_TO_BE (val))
+-#define GSIZE_TO_LE(val)      ((gsize) GUINT64_TO_LE (val))
+-#define GSSIZE_TO_LE(val)     ((gssize) GINT64_TO_LE (val))
+-#define GSIZE_TO_BE(val)      ((gsize) GUINT64_TO_BE (val))
+-#define GSSIZE_TO_BE(val)     ((gssize) GINT64_TO_BE (val))
++#define GSIZE_TO_LE(val)      ((gsize) GUINT32_TO_LE (val))
++#define GSSIZE_TO_LE(val)     ((gssize) GINT32_TO_LE (val))
++#define GSIZE_TO_BE(val)      ((gsize) GUINT32_TO_BE (val))
++#define GSSIZE_TO_BE(val)     ((gssize) GINT32_TO_BE (val))
+ #define G_BYTE_ORDER G_LITTLE_ENDIAN
+ #define GLIB_SYSDEF_POLLIN =1
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gslice.c glibremake/glib-2.40.2/glib/gslice.c
+--- glibremake/glibbase/glib-2.40.2/glib/gslice.c      2015-03-31 18:56:47.775484568 +0900
++++ glibremake/glib-2.40.2/glib/gslice.c       2015-03-31 18:57:16.255485440 +0900
+@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
+        * This way it's possible to force gslice to be enabled under
+        * valgrind just by setting G_SLICE to the empty string.
+        */
++ #if 0
+       if (RUNNING_ON_VALGRIND)
++#endif          
+         config->always_malloc = TRUE;
+     }
+ }
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c glibremake/glib-2.40.2/glib/gstrfuncs.c
+--- glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c   2015-03-31 18:56:47.683484565 +0900
++++ glibremake/glib-2.40.2/glib/gstrfuncs.c    2015-03-31 18:57:07.783485181 +0900
+@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
+ const guint16 * const g_ascii_table = ascii_table_data;
++#ifndef _GLIB_ANDROID_
+ #if defined (HAVE_NEWLOCALE) && \
+     defined (HAVE_USELOCALE) && \
+     defined (HAVE_STRTOD_L) && \
+@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
+     defined (HAVE_STRTOLL_L)
+ #define USE_XLOCALE 1
+ #endif
++#endif /* _GLIB_ANDROID_ */
+ #ifdef USE_XLOCALE
+ static locale_t
+diff -rupN glibremake/glibbase/glib-2.40.2/glib/pcre/Android.mk glibremake/glib-2.40.2/glib/pcre/Android.mk
+--- glibremake/glibbase/glib-2.40.2/glib/pcre/Android.mk       1970-01-01 09:00:00.000000000 +0900
++++ glibremake/glib-2.40.2/glib/pcre/Android.mk        2015-01-13 08:04:00.000000000 +0900
+@@ -0,0 +1,42 @@
++#libpcre Android Make File
++
++LOCAL_PATH            := $(call my-dir)
++
++include $(CLEAR_VARS)
++
++LOCAL_MODULE  := pcre
++
++LOCAL_LD_LIBS := -llog
++
++LOCAL_CFLAGS  := \
++      -DG_LOG_DOMAIN=\"GLib-GRegex\" \
++      -DHAVE_CONFIG_H \
++      -DHAVE_MEMMOVE \
++      -DSUPPORT_UCP \
++      -DSUPPORT_UTF \
++      -DSUPPORT_UTF8 \
++      -DNEWLINE=-1 \
++      -DMATCH_LIMIT=10000000 \
++      -DMATCH_LIMIT_RECURSION=8192 \
++      -DMAX_NAME_SIZE=32 \
++      -DMAX_NAME_COUNT=10000 \
++      -DMAX_DUPLENGTH=30000 \
++      -DLINK_SIZE=2 \
++      -DPOSIX_MALLOC_THRESHOLD=10 \
++      -DPCRE_STATIC \
++      -DG_DISABLE_CAST_CHECKS \
++      -DGLIB_COMPILATION \
++      -D_GLIB_ANDROID_
++
++LOCAL_SRC_FILES       :=      pcre_xclass.c pcre_valid_utf8.c pcre_tables.c \
++                                      pcre_study.c pcre_string_utils.c pcre_ord2utf8.c \
++                                      pcre_newline.c pcre_jit_compile.c pcre_globals.c \
++                                      pcre_get.c pcre_fullinfo.c pcre_exec.c \
++                                      pcre_dfa_exec.c pcre_config.c pcre_compile.c \
++                                      pcre_chartables.c pcre_byte_order.c
++
++LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
++                                      $(GLIB_MAIN_DIR)/glib
++
++
++include $(BUILD_STATIC_LIBRARY)
+\ No newline at end of file
+diff -rupN glibremake/glibbase/glib-2.40.2/gthread/Android.mk glibremake/glib-2.40.2/gthread/Android.mk
+--- glibremake/glibbase/glib-2.40.2/gthread/Android.mk 1970-01-01 09:00:00.000000000 +0900
++++ glibremake/glib-2.40.2/gthread/Android.mk  2015-03-31 19:39:47.151563588 +0900
+@@ -0,0 +1,25 @@
++#gthread Android Make File
++
++LOCAL_PATH            := $(call my-dir)
++
++include $(CLEAR_VARS)
++
++LOCAL_MODULE  := gthread-2.40.2
++
++LOCAL_SRC_FILES       :=      gthread-impl.c
++
++LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
++      $(GLIB_MAIN_DIR)/glib \
++      $(GLIB_MAIN_DIR)/gthread
++
++
++LOCAL_CFLAGS  := \
++      -DG_LOG_DOMAIN=\"GThread\" \
++      -DHAVE_CONFIG_H \
++      -DG_DISABLE_CAST_CHECKS \
++      -DG_DISABLE_DEPRECATED \
++      -D_GLIB_ANDROID_
++
++
++LOCAL_SHARED_LIBRARIES := glib-2.40.2
++include $(BUILD_SHARED_LIBRARY)
+\ No newline at end of file
diff --git a/resource/csdk/connectivity/lib/android/patches/glib-2.40.2.patch b/resource/csdk/connectivity/lib/android/patches/glib-2.40.2.patch
new file mode 100644 (file)
index 0000000..264f2d0
--- /dev/null
@@ -0,0 +1,503 @@
+diff -rupN glibref/glib-2.40.2/Android.mk glibpatch/glib-2.40.2/Android.mk
+--- glibref/glib-2.40.2/Android.mk     1970-01-01 09:00:00.000000000 +0900
++++ glibpatch/glib-2.40.2/Android.mk   2015-04-01 13:20:38.597557242 +0900
+@@ -0,0 +1,14 @@
++#GLIB Android Makefile to build GLIB modules
++
++LOCAL_PATH    := $(call my-dir)
++GLIB_MAIN_DIR := $(LOCAL_PATH)
++
++GLIB_C_INCLUDES       := $(GLIB_MAIN_DIR) \
++                 $(GLIB_MAIN_DIR)/glib
++
++GTHREAD_C_INCLUDES    := $(GLIB_MAIN_DIR) \
++                         $(GLIB_MAIN_DIR)/gthread
++
++include $(GLIB_MAIN_DIR)/glib/Android.mk
++include $(GLIB_MAIN_DIR)/gthread/Android.mk
++
+diff -rupN glibref/glib-2.40.2/config.h glibpatch/glib-2.40.2/config.h
+--- glibref/glib-2.40.2/config.h       2015-03-31 16:25:56.882894898 +0900
++++ glibpatch/glib-2.40.2/config.h     2015-04-01 13:21:19.593558693 +0900
+@@ -31,8 +31,9 @@
+ /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
+ /* always defined to indicate that i18n is enabled */
++#ifndef _GLIB_ANDROID_
+ #define ENABLE_NLS 1
+-
++#endif /* _GLIB_ANDROID__ */
+ /* Define the gettext package to be used */
+ #define GETTEXT_PACKAGE "glib20"
+@@ -100,8 +101,9 @@
+ /* #undef HAVE_COCOA */
+ /* Have nl_langinfo (CODESET) */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_CODESET 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <crt_externs.h> header file. */
+ /* #undef HAVE_CRT_EXTERNS_H */
+@@ -130,8 +132,10 @@
+ /* we have the eventfd(2) system call */
+ #define HAVE_EVENTFD 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `fallocate' function. */
+ #define HAVE_FALLOCATE 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define if we have FAM */
+ /* #undef HAVE_FAM */
+@@ -224,6 +228,7 @@
+ /* Define to 1 if you have the `kqueue' function. */
+ /* #undef HAVE_KQUEUE */
++#ifndef _GLIB_ANDROID_
+ /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+ #define HAVE_LANGINFO_CODESET 1
+@@ -232,6 +237,7 @@
+ /* Have nl_langinfo (PM_STR) */
+ #define HAVE_LANGINFO_TIME 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `lchmod' function. */
+ /* #undef HAVE_LCHMOD */
+@@ -283,9 +289,10 @@
+ /* Define to 1 if you have the <memory.h> header file. */
+ #define HAVE_MEMORY_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `mmap' function. */
+ #define HAVE_MMAP 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <mntent.h> header file. */
+ #define HAVE_MNTENT_H 1
+@@ -317,8 +324,10 @@
+ /* Have POSIX function getgrgid_r */
+ #define HAVE_POSIX_GETGRGID_R 1
++#ifndef _GLIB_ANDROID_
+ /* Have POSIX function getpwuid_r */
+ #define HAVE_POSIX_GETPWUID_R 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `posix_memalign' function. */
+ #define HAVE_POSIX_MEMALIGN 1
+@@ -333,8 +342,11 @@
+ #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+ /* Have function pthread_cond_timedwait_relative_np */
++#ifndef _GLIB_ANDROID_
+ /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
+-
++#else
++#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if the system has the type `ptrdiff_t'. */
+ #define HAVE_PTRDIFF_T 1
+@@ -384,8 +396,10 @@
+ /* Define to 1 if you have the <stdlib.h> header file. */
+ #define HAVE_STDLIB_H 1
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `stpcpy' function. */
+ #define HAVE_STPCPY 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `strcasecmp' function. */
+ #define HAVE_STRCASECMP 1
+@@ -532,10 +546,10 @@
+ /* Define to 1 if you have the <sys/xattr.h> header file. */
+ #define HAVE_SYS_XATTR_H 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define to 1 if you have the `timegm' function. */
+ #define HAVE_TIMEGM 1
+-
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the <unistd.h> header file. */
+ #define HAVE_UNISTD_H 1
+@@ -563,7 +577,7 @@
+ /* Define to 1 if you have the `vsnprintf' function. */
+ #define HAVE_VSNPRINTF 1
+-
++#ifndef _GLIB_ANDROID_
+ /* Define if you have the 'wchar_t' type. */
+ #define HAVE_WCHAR_T 1
+@@ -575,12 +589,14 @@
+ /* Define to 1 if xattr is available */
+ #define HAVE_XATTR 1
+-
++#endif
+ /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
+ /* #undef HAVE_XATTR_NOFOLLOW */
+ /* Define to 1 if you have the <xlocale.h> header file. */
++#ifndef _GLIB_ANDROID_
+ #define HAVE_XLOCALE_H 1
++#endif /* _GLIB_ANDROID_ */
+ /* Define to 1 if you have the `_NSGetEnviron' function. */
+ /* #undef HAVE__NSGETENVIRON */
+diff -rupN glibref/glib-2.40.2/glib/Android.mk glibpatch/glib-2.40.2/glib/Android.mk
+--- glibref/glib-2.40.2/glib/Android.mk        1970-01-01 09:00:00.000000000 +0900
++++ glibpatch/glib-2.40.2/glib/Android.mk      2015-03-31 17:10:22.722989176 +0900
+@@ -0,0 +1,115 @@
++#glib Android Make File
++
++LOCAL_PATH            := $(call my-dir)
++
++include $(CLEAR_VARS)
++
++LOCAL_MODULE  := glib-2.40.2
++
++LOCAL_SRC_FILES       := \
++    libcharset/localcharset.c \
++    garray.c        \
++    gasyncqueue.c   \
++    gatomic.c       \
++    gbacktrace.c    \
++    gbase64.c       \
++    gbitlock.c      \
++    gbookmarkfile.c \
++    gbytes.c      \
++    gcharset.c      \
++    gchecksum.c     \
++    gconvert.c      \
++    gdataset.c      \
++    gdate.c         \
++    gdatetime.c     \
++    gdir.c          \
++    gerror.c        \
++    genviron.c      \
++    gfileutils.c    \
++    ggettext.c            \
++    ghash.c         \
++    ghmac.c         \
++    ghook.c         \
++    ghostutils.c    \
++    giochannel.c    \
++    gkeyfile.c      \
++    glib-init.c           \
++    glib-private.c  \
++    glib-unix.c     \
++    glist.c         \
++    gmain.c         \
++    gmappedfile.c   \
++    gmarkup.c       \
++    gmem.c          \
++    gmessages.c     \
++    gnode.c         \
++    goption.c       \
++    gpattern.c      \
++    gpoll.c         \
++    gprimes.c       \
++    gqsort.c        \
++    gquark.c        \
++    gqueue.c        \
++    grand.c         \
++    gregex.c        \
++    gscanner.c      \
++    gsequence.c     \
++    gshell.c        \
++    gslice.c        \
++    gslist.c        \
++    gstdio.c        \
++    gstrfuncs.c     \
++    gstring.c       \
++    gstringchunk.c  \
++    gtestutils.c    \
++    gthread.c       \
++    gthreadpool.c   \
++    gthread-posix.c \
++    gtimer.c        \
++    gtimezone.c     \
++    gtranslit.c     \
++    gtrashstack.c   \
++    gtree.c         \
++    guniprop.c      \
++    gutf8.c         \
++    gunibreak.c     \
++    gunicollate.c   \
++    gunidecomp.c    \
++    gurifuncs.c     \
++    gutils.c        \
++    gvariant.c      \
++    gvariant-core.c \
++    gvariant-parser.c \
++    gvariant-serialiser.c \
++    gvarianttypeinfo.c \
++    gvarianttype.c  \
++    gprintf.c       \
++    giounix.c       \
++    gspawn.c        \
++    gversion.c      \
++    gwakeup.c
++
++LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
++                  $(GLIB_MAIN_DIR)/glib \
++                  $(GLIB_MAIN_DIR)/glib/deprecated \
++                  $(GLIB_MAIN_DIR)/glib/libcharset \
++                  $(GLIB_MAIN_DIR)/pcre \
++
++LOCAL_STATIC_LIBRARIES := pcre
++
++LOCAL_LD_LIBS := -llog
++
++LOCAL_CFLAGS  := \
++      -D_GLIB_ANDROID_ \
++      -DLIBDIR=\"$(libdir)\" \
++      -DHAVE_CONFIG_H \
++      -DG_LOG_DOMAIN=\"GLib\" \
++      -DGLIB_COMPILATION \
++      -DPCRE_STATIC \
++      -DG_DISABLE_CAST_CHECKS
++
++include $(BUILD_SHARED_LIBRARY)
++
++include       $(GLIB_MAIN_DIR)/glib/pcre/Android.mk
++
++
+diff -rupN glibref/glib-2.40.2/glib/gconvert.c glibpatch/glib-2.40.2/glib/gconvert.c
+--- glibref/glib-2.40.2/glib/gconvert.c        2015-03-31 16:25:56.946894901 +0900
++++ glibpatch/glib-2.40.2/glib/gconvert.c      2015-03-31 16:40:50.546926503 +0900
+@@ -22,7 +22,11 @@
+ #include "glibconfig.h"
+ #ifndef G_OS_WIN32
++
++#ifndef _GLIB_ANDROID_
+ #include <iconv.h>
++#endif /* _GLIB_ANDROID_ */
++
+ #endif
+ #include <errno.h>
+ #include <stdio.h>
+@@ -168,6 +172,7 @@
+ G_DEFINE_QUARK (g_convert_error, g_convert_error)
++#ifndef _GLIB_ANDROID_
+ static gboolean
+ try_conversion (const char *to_codeset,
+               const char *from_codeset,
+@@ -197,9 +202,9 @@ try_to_aliases (const char **to_aliases,
+         p++;
+       }
+     }
+-
+   return FALSE;
+ }
++#endif /* _GLIB_ANDROID_ */
+ /**
+  * g_iconv_open:
+@@ -220,6 +225,7 @@ GIConv
+ g_iconv_open (const gchar  *to_codeset,
+             const gchar  *from_codeset)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd;
+   
+   if (!try_conversion (to_codeset, from_codeset, &cd))
+@@ -248,6 +254,9 @@ g_iconv_open (const gchar  *to_codeset,
+  out:
+   return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
++#else
++  return (GIConv)-1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -274,9 +283,13 @@ g_iconv (GIConv   converter,
+        gchar  **outbuf,
+        gsize   *outbytes_left)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ /**
+@@ -297,9 +310,13 @@ g_iconv (GIConv   converter,
+ gint
+ g_iconv_close (GIConv converter)
+ {
++#ifndef _GLIB_ANDROID_
+   iconv_t cd = (iconv_t)converter;
+   return iconv_close (cd);
++#else
++  return -1;
++#endif /* _GLIB_ANDROID_ */
+ }
+ static GIConv
+diff -rupN glibref/glib-2.40.2/glib/gfileutils.c glibpatch/glib-2.40.2/glib/gfileutils.c
+--- glibref/glib-2.40.2/glib/gfileutils.c      2015-03-31 16:25:57.170894910 +0900
++++ glibpatch/glib-2.40.2/glib/gfileutils.c    2015-03-31 16:37:29.594919396 +0900
+@@ -54,7 +54,9 @@
+ #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
+ #include <linux/magic.h>
++#ifndef _GLIB_ANDROID_
+ #include <sys/vfs.h>
++#endif /* _GLIB_ANDROID_ */
+ #endif
+diff -rupN glibref/glib-2.40.2/glib/ggettext.c glibpatch/glib-2.40.2/glib/ggettext.c
+--- glibref/glib-2.40.2/glib/ggettext.c        2015-03-31 16:25:57.182894907 +0900
++++ glibpatch/glib-2.40.2/glib/ggettext.c      2015-03-31 16:37:55.538920314 +0900
+@@ -40,7 +40,10 @@
+ #include <string.h>
+ #include <locale.h>
++
++#ifndef _GLIB_ANDROID_
+ #include <libintl.h>
++#endif /* _GLIB_ANDROID_ */
+ #ifdef G_OS_WIN32
+diff -rupN glibref/glib-2.40.2/glib/glibconfig.h glibpatch/glib-2.40.2/glib/glibconfig.h
+--- glibref/glib-2.40.2/glib/glibconfig.h      2015-03-31 16:25:57.166894909 +0900
++++ glibpatch/glib-2.40.2/glib/glibconfig.h    2015-03-31 16:38:06.954920717 +0900
+@@ -154,7 +154,9 @@ typedef unsigned int guintptr;
+ #define G_THREADS_ENABLED
+ #define G_THREADS_IMPL_POSIX
++#ifndef _GLIB_ANDROID_
+ #define G_ATOMIC_LOCK_FREE
++#endif /* _GLIB_ANDROID_ */
+ #define GINT16_TO_LE(val)     ((gint16) (val))
+ #define GUINT16_TO_LE(val)    ((guint16) (val))
+diff -rupN glibref/glib-2.40.2/glib/gslice.c glibpatch/glib-2.40.2/glib/gslice.c
+--- glibref/glib-2.40.2/glib/gslice.c  2015-03-31 16:25:56.946894901 +0900
++++ glibpatch/glib-2.40.2/glib/gslice.c        2015-03-31 16:38:38.302921827 +0900
+@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
+        * This way it's possible to force gslice to be enabled under
+        * valgrind just by setting G_SLICE to the empty string.
+        */
++ #ifndef _GLIB_ANDROID_
+       if (RUNNING_ON_VALGRIND)
++#endif /* _GLIB_ANDROID_ */
+         config->always_malloc = TRUE;
+     }
+ }
+diff -rupN glibref/glib-2.40.2/glib/gstrfuncs.c glibpatch/glib-2.40.2/glib/gstrfuncs.c
+--- glibref/glib-2.40.2/glib/gstrfuncs.c       2015-03-31 16:25:56.950894901 +0900
++++ glibpatch/glib-2.40.2/glib/gstrfuncs.c     2015-03-31 16:39:00.154922598 +0900
+@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
+ const guint16 * const g_ascii_table = ascii_table_data;
++#ifndef _GLIB_ANDROID_
+ #if defined (HAVE_NEWLOCALE) && \
+     defined (HAVE_USELOCALE) && \
+     defined (HAVE_STRTOD_L) && \
+@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
+     defined (HAVE_STRTOLL_L)
+ #define USE_XLOCALE 1
+ #endif
++#endif /* _GLIB_ANDROID_ */
+ #ifdef USE_XLOCALE
+ static locale_t
+diff -rupN glibref/glib-2.40.2/glib/pcre/Android.mk glibpatch/glib-2.40.2/glib/pcre/Android.mk
+--- glibref/glib-2.40.2/glib/pcre/Android.mk   1970-01-01 09:00:00.000000000 +0900
++++ glibpatch/glib-2.40.2/glib/pcre/Android.mk 2015-01-13 08:04:00.000000000 +0900
+@@ -0,0 +1,42 @@
++#libpcre Android Make File
++
++LOCAL_PATH            := $(call my-dir)
++
++include $(CLEAR_VARS)
++
++LOCAL_MODULE  := pcre
++
++LOCAL_LD_LIBS := -llog
++
++LOCAL_CFLAGS  := \
++      -DG_LOG_DOMAIN=\"GLib-GRegex\" \
++      -DHAVE_CONFIG_H \
++      -DHAVE_MEMMOVE \
++      -DSUPPORT_UCP \
++      -DSUPPORT_UTF \
++      -DSUPPORT_UTF8 \
++      -DNEWLINE=-1 \
++      -DMATCH_LIMIT=10000000 \
++      -DMATCH_LIMIT_RECURSION=8192 \
++      -DMAX_NAME_SIZE=32 \
++      -DMAX_NAME_COUNT=10000 \
++      -DMAX_DUPLENGTH=30000 \
++      -DLINK_SIZE=2 \
++      -DPOSIX_MALLOC_THRESHOLD=10 \
++      -DPCRE_STATIC \
++      -DG_DISABLE_CAST_CHECKS \
++      -DGLIB_COMPILATION \
++      -D_GLIB_ANDROID_
++
++LOCAL_SRC_FILES       :=      pcre_xclass.c pcre_valid_utf8.c pcre_tables.c \
++                                      pcre_study.c pcre_string_utils.c pcre_ord2utf8.c \
++                                      pcre_newline.c pcre_jit_compile.c pcre_globals.c \
++                                      pcre_get.c pcre_fullinfo.c pcre_exec.c \
++                                      pcre_dfa_exec.c pcre_config.c pcre_compile.c \
++                                      pcre_chartables.c pcre_byte_order.c
++
++LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
++                                      $(GLIB_MAIN_DIR)/glib
++
++
++include $(BUILD_STATIC_LIBRARY)
+\ No newline at end of file
+diff -rupN glibref/glib-2.40.2/gthread/Android.mk glibpatch/glib-2.40.2/gthread/Android.mk
+--- glibref/glib-2.40.2/gthread/Android.mk     1970-01-01 09:00:00.000000000 +0900
++++ glibpatch/glib-2.40.2/gthread/Android.mk   2015-03-31 17:11:02.782990592 +0900
+@@ -0,0 +1,25 @@
++#gthread Android Make File
++
++LOCAL_PATH            := $(call my-dir)
++
++include $(CLEAR_VARS)
++
++LOCAL_MODULE  := gthread-2.40.2
++
++LOCAL_SRC_FILES       :=      gthread-impl.c
++
++LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
++      $(GLIB_MAIN_DIR)/glib \
++      $(GLIB_MAIN_DIR)/gthread
++
++
++LOCAL_CFLAGS  := \
++      -DG_LOG_DOMAIN=\"GThread\" \
++      -DHAVE_CONFIG_H \
++      -DG_DISABLE_CAST_CHECKS \
++      -DG_DISABLE_DEPRECATED \
++      -D_GLIB_ANDROID_
++
++
++LOCAL_SHARED_LIBRARIES := glib-2.40.2
++include $(BUILD_SHARED_LIBRARY)
+\ No newline at end of file
index 40e9eee..799a3c5 100644 (file)
@@ -100,7 +100,9 @@ if 'BLE' in ca_transport:
 
 print "Include path is %s" %env.get('CPPPATH')
 print "Files path is %s" %env.get('CA_SRC')
-
-calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
+if ca_os == 'android':
+       calib = env.SharedLibrary('connectivity_abstraction', env.get('CA_SRC'))
+else:
+       calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
 env.InstallTarget(calib, 'libconnectivity_abstraction')
 
index 7a2bdc8..61bd22f 100644 (file)
@@ -32,5 +32,9 @@ if target_os == 'tizen':
 #Source files to build in Android platform
 if target_os == 'android':
        env.AppendUnique(CA_SRC=[src_dir+'caedradapter.c',
+                       src_dir+'android/caedrclient.c',
+                       src_dir+'android/caedrutils.c',
+                       src_dir+'android/caedrnwmonitor.c',
+                       src_dir+'android/caedrserver.c',
                        ])
 
index 99f43b8..761d401 100644 (file)
@@ -51,6 +51,6 @@ liboc_logger = liboc_logger_env.SharedLibrary('oc_logger',
 
 liboc_logger_env.InstallTarget([liboc_logger_core, liboc_logger], 'liboc_logger')
 
-if target_os not in ['ios']:
+if target_os not in ['ios', 'android']:
        SConscript('examples/SConscript')
 
diff --git a/tools/scons/BoostBootstrap.py b/tools/scons/BoostBootstrap.py
new file mode 100644 (file)
index 0000000..d1f722b
--- /dev/null
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-\r
+\r
+# *********************************************************************\r
+#\r
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.\r
+#\r
+# *********************************************************************\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#      http:#www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+#\r
+# *********************************************************************\r
+\r
+# This SCONS builder executes the boost bootstrap function which\r
+# is needed to create their build utility called 'b2'\r
+\r
+import os, subprocess\r
+import SCons.Builder, SCons.Node, SCons.Errors\r
+\r
+# creates the downloading output message\r
+# @param s original message\r
+# @param target target name\r
+# @param source source name\r
+# @param env environment object\r
+def __message( s, target, source, env ) :\r
+    print 'bootstrapping using [%s] ...' % (source[0])\r
+\r
+\r
+# Create the builder action which executes the bootstrap script\r
+#\r
+# @param target target file on the local drive\r
+# @param source URL for download\r
+# @param env environment object\r
+def __action( target, source, env ) :\r
+    cmd = None\r
+\r
+    # Windows...\r
+    if env['PLATFORM'] in ['win32'] :\r
+        if env.WhereIs('cmd') :\r
+            # TODO: Add Windows Support\r
+            cmd = None\r
+\r
+    # read the tools on *nix systems and sets the default parameters\r
+    elif env['PLATFORM'] in ['darwin', 'linux', 'posix'] :\r
+        if env.WhereIs('sh') :\r
+            cmd = './bootstrap.sh'\r
+\r
+    if not cmd :\r
+        raise SCons.Errors.StopError('Bootstrapping shell on this platform [%s] unkown' % (env['PLATFORM']))\r
+\r
+    # We need to be in the target's directory\r
+    cwd = os.path.dirname(os.path.realpath(target[0].path))\r
+\r
+    # build it now (we need the shell, because some programs need it)\r
+    devnull = open(os.devnull, 'wb')\r
+    handle  = subprocess.Popen( cmd, shell=True, cwd=cwd, stdout=devnull )\r
+\r
+    if handle.wait() <> 0 :\r
+        raise SCons.Errors.BuildError( 'Bootstrapping script [%s] on the source [%s]' % (cmd, source[0])  )\r
+\r
+# Define the emitter of the builder\r
+#\r
+# @param target target file on the local drive\r
+# @param source\r
+# @param env environment object\r
+def __emitter( target, source, env ) :\r
+    return target, source\r
+\r
+# Generate function which adds the builder to the environment,\r
+#\r
+# @param env environment object\r
+def generate( env ) :\r
+    env['BUILDERS']['BoostBootstrap'] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
+\r
+# Exist function of the builder\r
+# @param env environment object\r
+# @return true\r
+def exists( env ) :\r
+    return 1\r
+\r
diff --git a/tools/scons/BoostBuild.py b/tools/scons/BoostBuild.py
new file mode 100644 (file)
index 0000000..2d43d33
--- /dev/null
@@ -0,0 +1,156 @@
+# -*- coding: utf-8 -*-\r
+\r
+# *********************************************************************\r
+#\r
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.\r
+#\r
+# *********************************************************************\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#      http:#www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+#\r
+# *********************************************************************\r
+\r
+# This builder executes the boost builder ('b2') for the toolchain\r
+# defined currently in the SCONS environment. This builder was created\r
+# to create cross-compiled version of boost. In particular, it has\r
+# created to create boost binaries for Android's various architectures.\r
+\r
+import os, subprocess\r
+import SCons.Builder, SCons.Node, SCons.Errors\r
+\r
+# Creates the building message\r
+#\r
+# @param s original message\r
+# @param target target name\r
+# @param source source name\r
+# @param env environment object\r
+def __message( s, target, source, env ) :\r
+    print "building boost from [%s] for ..." % (source[0])\r
+\r
+\r
+# Create the builder action which constructs a user-config.jam based\r
+# on the current toolchain and executes the boost build system ('b2')\r
+#\r
+# @param target target file on the local drive\r
+# @param source URL for download\r
+# @@param env environment object\r
+def __action( target, source, env ) :\r
+    cmd = None\r
+\r
+    # Windows...\r
+    if env["PLATFORM"] in ["win32"] :\r
+        if env.WhereIs("cmd") :\r
+            # TODO: Add Windows Support\r
+            cmd = None\r
+\r
+    # read the tools on *nix systems and sets the default parameters\r
+    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :\r
+        if env.WhereIs("sh") :\r
+            cmd = ['./b2']\r
+\r
+    if not cmd :\r
+        raise SCons.Errors.StopError("Boost build system not supported on this platform [%s]" % (env["PLATFORM"]))\r
+\r
+    # We need to be in the target's directory\r
+    cwd = os.path.dirname(os.path.realpath(source[0].path))\r
+\r
+    # Gather all of the path, bin and flags\r
+    version     = env.get('VERSION','')\r
+    target_os   = env['TARGET_OS']\r
+    target_arch = env['TARGET_ARCH']\r
+    tool_path   = os.path.dirname(env['CXX'])\r
+    cxx_bin     = os.path.basename(env['CXX'])\r
+    ar_bin      = os.path.basename(env['AR'])\r
+    ranlib_bin  = os.path.basename(env['RANLIB'])\r
+    ccflags     = list(env['CFLAGS'])\r
+    cxxflags    = list(env['CXXFLAGS'])\r
+\r
+    try:\r
+        cxxflags.remove('-fno-rtti')\r
+    except ValueError:\r
+        pass\r
+    try:\r
+        cxxflags.remove('-fno-exceptions')\r
+    except ValueError:\r
+        pass\r
+\r
+    # Write a user-config for this variant\r
+    user_config_name = cwd+os.sep+'tools'+os.sep+'build'+os.sep+'src'+os.sep+'user-config.jam'\r
+    user_config_file = open(user_config_name, 'w')\r
+    user_config_file.write('import os ;\n')\r
+    user_config_file.write('using gcc :')\r
+    user_config_file.write(' '+version+' :')\r
+    #user_config_file.write(' :')\r
+    #user_config_file.write(' '+os.path.basename(toolchain['CXX']['BIN'])+' :\n')\r
+    user_config_file.write(' '+cxx_bin+' :\n')\r
+    user_config_file.write('    <archiver>'+ar_bin+'\n')\r
+    user_config_file.write('    <ranlib>'+ranlib_bin+'\n')\r
+    for value in env['CPPDEFINES'] :\r
+        if len(value) > 1 :\r
+            user_config_file.write('    <compileflags>-D'+value[0]+'='+value[1]+'\n')\r
+        else :\r
+            user_config_file.write('    <compileflags>-D'+value[0]+'\n')\r
+    for value in env['CPPPATH'] :\r
+        user_config_file.write('    <compileflags>-I'+value+'\n')\r
+    for flag in ccflags :\r
+        user_config_file.write('    <compileflags>'+flag+'\n')\r
+    for flag in cxxflags :\r
+        user_config_file.write('    <cxxflags>'+flag+'\n')\r
+    user_config_file.write('    ;\n')\r
+    user_config_file.close();\r
+\r
+    # Ensure that the toolchain is in the PATH\r
+    penv = os.environ.copy()\r
+    penv["PATH"] = tool_path+":" + penv["PATH"]\r
+\r
+    build_path = 'build' + os.sep + target_os + os.sep + target_arch\r
+\r
+    cmd.append('-q')\r
+    cmd.append('target-os=linux')\r
+    cmd.append('link=static')\r
+    cmd.append('threading=multi')\r
+    cmd.append('--layout=system')\r
+    cmd.append('--build-type=minimal')\r
+    cmd.append('--prefix='+env['PREFIX'])\r
+    cmd.append('--build-dir='+build_path)\r
+    for module in env.get('MODULES',[]) :\r
+        cmd.append('--with-'+module)\r
+    cmd.append('headers')\r
+    cmd.append('install')\r
+\r
+    # build it now (we need the shell, because some programs need it)\r
+    devnull = open(os.devnull, "wb")\r
+    handle  = subprocess.Popen( cmd, env=penv, cwd=cwd ) #, stdout=devnull )\r
+\r
+    if handle.wait() <> 0 :\r
+        raise SCons.Errors.BuildError( "Building boost [%s] on the source [%s]" % (cmd, source[0])  )\r
+\r
+# Define the emitter of the builder\r
+#\r
+# @param target target file on the local drive\r
+# @param source\r
+# @param env environment object\r
+def __emitter( target, source, env ) :\r
+    return target, source\r
+\r
+# Generate function which adds the builder to the environment\r
+#\r
+# @param env environment object\r
+def generate( env ) :\r
+    env["BUILDERS"]["BoostBuild"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.Entry,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
+\r
+# Exist function of the builder\r
+# @param env environment object\r
+# @return true\r
+def exists( env ) :\r
+    return 1\r
diff --git a/tools/scons/Configure.py b/tools/scons/Configure.py
new file mode 100644 (file)
index 0000000..88c184a
--- /dev/null
@@ -0,0 +1,88 @@
+# -*- coding: utf-8 -*-\r
+\r
+# *********************************************************************\r
+#\r
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.\r
+#\r
+# *********************************************************************\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#      http:#www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+#\r
+# *********************************************************************\r
+\r
+# This builder executes configure\r
+\r
+import os, subprocess\r
+import SCons.Builder, SCons.Node, SCons.Errors\r
+\r
+# Create the output message\r
+#\r
+# @param s original message\r
+# @param target target name\r
+# @param source source name\r
+# @param env environment object\r
+def __message( s, target, source, env ) :\r
+    print "Configuring using [%s] ..." % (source[0])\r
+\r
+# Create the action\r
+#\r
+# @param target target file on the local drive\r
+# @param source URL for download\r
+# @@param env environment object\r
+def __action( target, source, env ) :\r
+    cmd = None\r
+\r
+    # Windows...\r
+    if env["PLATFORM"] in ["win32"] :\r
+        if env.WhereIs("cmd") :\r
+            # TODO: Add Windows Support\r
+            cmd = None\r
+\r
+    # read the tools on *nix systems and sets the default parameters\r
+    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :\r
+        if env.WhereIs("sh") :\r
+            cmd = "./configure"\r
+\r
+    if not cmd :\r
+        raise SCons.Errors.StopError("Configure shell on this platform [%s] unkown" % (env["PLATFORM"]))\r
+\r
+    # We need to be in the target's directory\r
+    cwd = os.path.dirname(os.path.realpath(target[0].path))\r
+\r
+    # build it now (we need the shell, because some programs need it)\r
+    devnull = open(os.devnull, "wb")\r
+    handle  = subprocess.Popen( cmd, shell=True, cwd=cwd, stdout=devnull )\r
+\r
+    if handle.wait() <> 0 :\r
+        raise SCons.Errors.BuildError( "Configuring script [%s] on the source [%s]" % (cmd, source[0])  )\r
+\r
+# Define the builder's emitter\r
+#\r
+# @param target target file on the local drive\r
+# @param source \r
+# @param env environment object\r
+def __emitter( target, source, env ) :\r
+    return target, source\r
+\r
+# Generate function which adds the builder to the environment,\r
+#\r
+# @param env environment object\r
+def generate( env ) :\r
+    env["BUILDERS"]["Configure"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
+\r
+# Exist function for the builder\r
+#\r
+# @param env environment object\r
+# @return true\r
+def exists( env ) :\r
+    return 1\r
diff --git a/tools/scons/URLDownload.py b/tools/scons/URLDownload.py
new file mode 100644 (file)
index 0000000..724ad4d
--- /dev/null
@@ -0,0 +1,147 @@
+# -*- coding: utf-8 -*-\r
+\r
+############################################################################\r
+# GPL License                                                              #\r
+#                                                                          #\r
+# This file is a SCons (http://www.scons.org/) builder                     #\r
+# Copyright (c) 2012-14, Philipp Kraus, <philipp.kraus@flashpixx.de>       #\r
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.     #\r
+# This program is free software: you can redistribute it and/or modify     #\r
+# it under the terms of the GNU General Public License as                  #\r
+# published by the Free Software Foundation, either version 3 of the       #\r
+# License, or (at your option) any later version.                          #\r
+#                                                                          #\r
+# This program is distributed in the hope that it will be useful,          #\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #\r
+# GNU General Public License for more details.                             #\r
+#                                                                          #\r
+# You should have received a copy of the GNU General Public License        #\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.     #\r
+############################################################################\r
+\r
+# the URLDownload-Builder can download any data from an URL into a target\r
+# file. The target name is used are the file name of the downloaded file.\r
+\r
+# This builder originated from work by Philipp Kraus and flashpixx project\r
+# (see https://github.com/flashpixx). It has been modified to leverage\r
+# the HTTP ETag header to be used as the csig. This allows the download\r
+# builder to determine if the file should be downloaded again when the\r
+# ETag header is supported\r
+\r
+import os, time\r
+import urllib2, urlparse\r
+import SCons.Builder, SCons.Node, SCons.Errors\r
+\r
+# Define a source node to represent the remote file. The construction of the\r
+# node will query the hosting site to get the ETag, size and last-modified\r
+# date.  This node also defines the method by which we will determine if\r
+# the file should be downloaded again.\r
+#\r
+# This node derives from the Python.Value node\r
+#\r
+class URLNode(SCons.Node.Python.Value) :\r
+    def make_ready(self) :\r
+        try :\r
+            stream = urllib2.urlopen( str(self.value) )\r
+            info = stream.info()\r
+\r
+            self.url_etag = None\r
+            self.url_last_modified = None\r
+            self.url_content_length = None\r
+\r
+            if 'ETag' in info :\r
+                self.url_etag = info['ETag']\r
+            if 'Last-Modified' in info :\r
+                self.url_last_modified = time.mktime(time.strptime(info['Last-Modified'], '%a, %d %b %Y %H:%M:%S GMT'))\r
+            if 'Content-Length' in info :\r
+                self.url_content_legth = info['Content-Length']\r
+        except Exception, e :\r
+            raise SCons.Errors.StopError( '%s [%s]' % (e, self.value) )\r
+\r
+    def visited(self) :\r
+        ninfo = self.get_ninfo()\r
+\r
+        if self.url_etag :\r
+            ninfo.csig = self.url_etag\r
+        if self.url_last_modified :\r
+            ninfo.timestamp = self.url_last_modified\r
+        if self.url_content_length :\r
+            ninfo.size = self.url_content_length\r
+        SCons.Node.Node.visited(self);\r
+\r
+    def changed_since_last_build(self, target, prev_ni):\r
+        if prev_ni :\r
+            if self.url_etag :\r
+                if prev_ni.csig == self.url_etag :\r
+                    # print 'Matched on ETag:'+prev_ni.csig\r
+                    return False\r
+\r
+            if not self.url_last_modified :\r
+                # print 'Last modified date is not available'\r
+                return True\r
+            if not self.url_content_length :\r
+                # print 'Content length is not available'\r
+                return True\r
+            if prev_ni.timestamp != self.url_last_modified :\r
+                # print 'Modified since last build'\r
+                return True\r
+            if prev_ni.size != self.url_content_length :\r
+                # print 'Content length has changed'\r
+                return True\r
+\r
+            return False\r
+\r
+        # print 'Not previous built'\r
+        return True\r
+\r
+# Creates the output message\r
+# @param s original message\r
+# @param target target name\r
+# @param source source name\r
+# @param env environment object\r
+def __message( s, target, source, env ) :\r
+    print 'downloading [%s] from [%s] ...' % (target[0], source[0])\r
+\r
+# Creates the action ie. the download function.\r
+# This reads the data from the URL and writes it down to the file\r
+# @param target target file on the local drive\r
+# @param source URL for download\r
+# @@param env environment object\r
+def __action( target, source, env ) :\r
+    try :\r
+        source_name = str(source[0])\r
+        target_name = str(target[0])\r
+        stream = urllib2.urlopen(source_name)\r
+        file = open( target_name, 'wb' )\r
+        file.write(stream.read())\r
+        file.close()\r
+\r
+        # Change the access/modified time to match\r
+        # the date on the downloaded file, if available\r
+        ninfo = source[0].get_ninfo()\r
+        if hasattr(ninfo, 'timestamp') :\r
+            mtime = ninfo.timestamp\r
+            if mtime :\r
+                os.utime(target_name, (mtime, mtime))\r
+    except Exception, e :\r
+        raise SCons.Errors.StopError( '%s [%s]' % (e, source[0]) )\r
+\r
+\r
+# Defines the emitter of the builder\r
+# @param target target file on the local drive\r
+# @param source URL for download\r
+# @param env environment object\r
+def __emitter( target, source, env ) :\r
+    return target, source\r
+\r
+# generate function, that adds the builder to the environment,\r
+# @param env environment object\r
+def generate( env ) :\r
+    env['BUILDERS']['URLDownload'] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = URLNode,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
+\r
+# existing function of the builder\r
+# @param env environment object\r
+# @return true\r
+def exists(env) :\r
+    return 1\r
diff --git a/tools/scons/UnpackAll.py b/tools/scons/UnpackAll.py
new file mode 100644 (file)
index 0000000..409f980
--- /dev/null
@@ -0,0 +1,399 @@
+# -*- coding: utf-8 -*-\r
+\r
+############################################################################\r
+# GPL License                                                              #\r
+#                                                                          #\r
+# This file is a SCons (http://www.scons.org/) builder                     #\r
+# Copyright (c) 2012-14, Philipp Kraus, <philipp.kraus@flashpixx.de>       #\r
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.     #\r
+# This program is free software: you can redistribute it and/or modify     #\r
+# it under the terms of the GNU General Public License as                  #\r
+# published by the Free Software Foundation, either version 3 of the       #\r
+# License, or (at your option) any later version.                          #\r
+#                                                                          #\r
+# This program is distributed in the hope that it will be useful,          #\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #\r
+# GNU General Public License for more details.                             #\r
+#                                                                          #\r
+# You should have received a copy of the GNU General Public License        #\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.     #\r
+############################################################################\r
+\r
+# This builder originated from work by Philipp Kraus and flashpixx project\r
+# (see https://github.com/flashpixx). Based on the Unpack.py, it only\r
+# contains changes to allow a complete unpacking of the archive.\r
+# It is assumed that the target represents a file in the archive after it\r
+# is unpacked.\r
+\r
+# The Unpack Builder can be used for unpacking archives (eg Zip, TGZ, BZ, ... ).\r
+# The emitter of the Builder reads the archive data and creates a returning\r
+# file list the builder extract the archive. The environment variable\r
+# stores a dictionary "UNPACK" for set different extractions (subdict "EXTRACTOR"):\r
+# {\r
+#   PRIORITY         => a value for setting the extractor order (lower numbers = extractor is used earlier)\r
+#   SUFFIX           => defines a list with file suffixes, which should be handled with this extractor\r
+#   EXTRACTSUFFIX    => suffix of the extract command\r
+#   EXTRACTFLAGS     => a string parameter for the RUN command for extracting the data\r
+#   EXTRACTCMD       => full extract command of the builder\r
+#   RUN              => the main program which will be started (if the parameter is empty, the extractor will be ignored)\r
+#   LISTCMD          => the listing command for the emitter\r
+#   LISTFLAGS        => the string options for the RUN command for showing a list of files\r
+#   LISTSUFFIX       => suffix of the list command\r
+#   LISTEXTRACTOR    => a optional Python function, that is called on each output line of the\r
+#                       LISTCMD for extracting file & dir names, the function need two parameters (first line number,\r
+#                       second line content) and must return a string with the file / dir path (other value types\r
+#                       will be ignored)\r
+# }\r
+# Other options in the UNPACK dictionary are:\r
+#   STOPONEMPTYFILE  => bool variable for stoping if the file has empty size (default True)\r
+#   VIWEXTRACTOUTPUT => shows the output messages of the extraction command (default False)\r
+#   EXTRACTDIR       => path in that the data will be extracted (default #)\r
+#\r
+# The file which is handled by the first suffix match of the extractor, the extractor list can be append for other files.\r
+# The order of the extractor dictionary creates the listing & extractor command eg file extension .tar.gz should be\r
+# before .gz, because the tar.gz is extract in one shoot.\r
+#\r
+# Under *nix system these tools are supported: tar, bzip2, gzip, unzip\r
+# Under Windows only 7-Zip (http://www.7-zip.org/) is supported\r
+\r
+\r
+import subprocess, os\r
+import SCons.Errors, SCons.Warnings, SCons.Util\r
+\r
+# enables Scons warning for this builder\r
+class UnpackWarning(SCons.Warnings.Warning) :\r
+    pass\r
+\r
+SCons.Warnings.enableWarningClass(UnpackWarning)\r
+\r
+# extractor function for Tar output\r
+# @param env environment object\r
+# @param count number of returning lines\r
+# @param no number of the output line\r
+# @param i line content\r
+def __fileextractor_nix_tar( env, count, no, i ) :\r
+    return i.split()[-1]\r
+\r
+# extractor function for GZip output,\r
+# ignore the first line\r
+# @param env environment object\r
+# @param count number of returning lines\r
+# @param no number of the output line\r
+# @param i line content\r
+def __fileextractor_nix_gzip( env, count, no, i ) :\r
+    if no == 0 :\r
+        return None\r
+    return i.split()[-1]\r
+\r
+# extractor function for Unzip output,\r
+# ignore the first & last two lines\r
+# @param env environment object\r
+# @param count number of returning lines\r
+# @param no number of the output line\r
+# @param i line content\r
+def __fileextractor_nix_unzip( env, count, no, i ) :\r
+    if no < 3 or no >= count - 2 :\r
+        return None\r
+    return i.split()[-1]\r
+\r
+# extractor function for 7-Zip\r
+# @param env environment object\r
+# @param count number of returning lines\r
+# @param no number of the output line\r
+# @param i line content\r
+def __fileextractor_win_7zip( env, count, no, i ) :\r
+    item = i.split()\r
+    if no > 8 and no < count - 2 :\r
+        return item[-1]\r
+    return None\r
+\r
+\r
+\r
+# returns the extractor item for handling the source file\r
+# @param source input source file\r
+# @param env environment object\r
+# @return extractor entry or None on non existing\r
+def __getExtractor( source, env ) :\r
+    # we check each unpacker and get the correct list command first, run the command and\r
+    # replace the target filelist with the list values, we sorte the extractors by their priority\r
+    for unpackername, extractor in sorted(env["UNPACK"]["EXTRACTOR"].iteritems(), key = lambda (k,v) : (v["PRIORITY"],k)):\r
+\r
+        if not SCons.Util.is_String(extractor["RUN"]) :\r
+            raise SCons.Errors.StopError("list command of the unpack builder for [%s] archives is not a string" % (unpackername))\r
+        if not len(extractor["RUN"]) :\r
+            raise SCons.Errors.StopError("run command of the unpack builder for [%s] archives is not set - can not extract files" % (unpackername))\r
+\r
+\r
+        if not SCons.Util.is_String(extractor["LISTFLAGS"]) :\r
+            raise SCons.Errors.StopError("list flags of the unpack builder for [%s] archives is not a string" % (unpackername))\r
+        if not SCons.Util.is_String(extractor["LISTCMD"]) :\r
+            raise SCons.Errors.StopError("list command of the unpack builder for [%s] archives is not a string" % (unpackername))\r
+\r
+        if not SCons.Util.is_String(extractor["EXTRACTFLAGS"]) :\r
+            raise SCons.Errors.StopError("extract flags of the unpack builder for [%s] archives is not a string" % (unpackername))\r
+        if not SCons.Util.is_String(extractor["EXTRACTCMD"]) :\r
+            raise SCons.Errors.StopError("extract command of the unpack builder for [%s] archives is not a string" % (unpackername))\r
+\r
+\r
+        # check the source file suffix and if the first is found, run the list command\r
+        if not SCons.Util.is_List(extractor["SUFFIX"]) :\r
+            raise SCons.Errors.StopError("suffix list of the unpack builder for [%s] archives is not a list" % (unpackername))\r
+\r
+        for suffix in extractor["SUFFIX"] :\r
+            if str(source[0]).lower()[-len(suffix):] == suffix.lower() :\r
+                return extractor\r
+\r
+    return None\r
+\r
+\r
+# creates the extracter output message\r
+# @param s original message\r
+# @param target target name\r
+# @param source source name\r
+# @param env environment object\r
+def __message( s, target, source, env ) :\r
+    print "extract [%s] ..." % (source[0])\r
+\r
+\r
+# action function for extracting of the data\r
+# @param target target packed file\r
+# @param source extracted files\r
+# @param env environment object\r
+def __action( target, source, env ) :\r
+    extractor = __getExtractor(source, env)\r
+    if not extractor :\r
+        raise SCons.Errors.StopError( "can not find any extractor value for the source file [%s]" % (source[0]) )\r
+\r
+    extractor_cmd = extractor["EXTRACTCMD"]\r
+\r
+    # if the extract command is empty, we create an error\r
+    if len(extractor_cmd) == 0 :\r
+        raise SCons.Errors.StopError( "the extractor command for the source file [%s] is empty" % (source[0]) )\r
+\r
+    # build it now (we need the shell, because some programs need it)\r
+    handle = None\r
+\r
+    source_path = os.path.realpath(source[0].path)\r
+    target_path = os.path.realpath(target[0].path)\r
+\r
+    cmd = env.subst(extractor_cmd, source=source_path, target=target)\r
+    cwd = os.path.dirname(source_path)\r
+\r
+    if env["UNPACK"]["VIWEXTRACTOUTPUT"] :\r
+        handle  = subprocess.Popen( cmd, shell=True )\r
+    else :\r
+        devnull = open(os.devnull, "wb")\r
+        handle  = subprocess.Popen( cmd, shell=True, stdout=devnull, cwd=cwd)\r
+\r
+    if handle.wait() <> 0 :\r
+        raise SCons.Errors.BuildError( "error running extractor [%s] on the source [%s]" % (cmd, source[0]) )\r
+\r
+    fhandle = open(target_path, 'a')\r
+    try:\r
+        os.utime(target_path, None)\r
+    finally:\r
+        fhandle.close()\r
+\r
+\r
+# emitter function for getting the files\r
+# within the archive\r
+# @param target target packed file\r
+# @param source extracted files\r
+# @param env environment object\r
+def __emitter( target, source, env ) :\r
+    return target, source\r
+\r
+\r
+# generate function, that adds the builder to the environment\r
+# @param env environment object\r
+def generate( env ) :\r
+    # setup environment variable\r
+    toolset = {\r
+        "STOPONEMPTYFILE"  : True,\r
+        "VIWEXTRACTOUTPUT" : False,\r
+        "EXTRACTDIR"       : os.curdir,\r
+        "EXTRACTOR" : {\r
+            "TARGZ" : {\r
+                "PRIORITY"       : 0,\r
+                "SUFFIX"         : [".tar.gz", ".tgz", ".tar.gzip"],\r
+                "EXTRACTSUFFIX"  : "",\r
+                "EXTRACTFLAGS"   : "",\r
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TARGZ']['RUN']} ${UNPACK['EXTRACTOR']['TARGZ']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARGZ']['EXTRACTSUFFIX']}",\r
+                "RUN"            : "",\r
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TARGZ']['RUN']} ${UNPACK['EXTRACTOR']['TARGZ']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARGZ']['LISTSUFFIX']}",\r
+                "LISTSUFFIX"     : "",\r
+                "LISTFLAGS"      : "",\r
+                "LISTEXTRACTOR"  : None\r
+            },\r
+\r
+            "TARBZ" : {\r
+                "PRIORITY"       : 0,\r
+                "SUFFIX"         : [".tar.bz", ".tbz", ".tar.bz2", ".tar.bzip2", ".tar.bzip"],\r
+                "EXTRACTSUFFIX"  : "",\r
+                "EXTRACTFLAGS"   : "",\r
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TARBZ']['RUN']} ${UNPACK['EXTRACTOR']['TARBZ']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARBZ']['EXTRACTSUFFIX']}",\r
+                "RUN"            : "",\r
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TARBZ']['RUN']} ${UNPACK['EXTRACTOR']['TARBZ']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARBZ']['LISTSUFFIX']}",\r
+                "LISTSUFFIX"     : "",\r
+                "LISTFLAGS"      : "",\r
+                "LISTEXTRACTOR"  : None\r
+            },\r
+\r
+            "BZIP" : {\r
+                "PRIORITY"       : 1,\r
+                "SUFFIX"         : [".bz", "bzip", ".bz2", ".bzip2"],\r
+                "EXTRACTSUFFIX"  : "",\r
+                "EXTRACTFLAGS"   : "",\r
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['BZIP']['RUN']} ${UNPACK['EXTRACTOR']['BZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['BZIP']['EXTRACTSUFFIX']}",\r
+                "RUN"            : "",\r
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['BZIP']['RUN']} ${UNPACK['EXTRACTOR']['BZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['BZIP']['LISTSUFFIX']}",\r
+                "LISTSUFFIX"     : "",\r
+                "LISTFLAGS"      : "",\r
+                "LISTEXTRACTOR"  : None\r
+            },\r
+\r
+            "GZIP" : {\r
+                "PRIORITY"       : 1,\r
+                "SUFFIX"         : [".gz", ".gzip"],\r
+                "EXTRACTSUFFIX"  : "",\r
+                "EXTRACTFLAGS"   : "",\r
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['GZIP']['RUN']} ${UNPACK['EXTRACTOR']['GZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['GZIP']['EXTRACTSUFFIX']}",\r
+                "RUN"            : "",\r
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['GZIP']['RUN']} ${UNPACK['EXTRACTOR']['GZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['GZIP']['LISTSUFFIX']}",\r
+                "LISTSUFFIX"     : "",\r
+                "LISTFLAGS"      : "",\r
+                "LISTEXTRACTOR"  : None\r
+            },\r
+\r
+            "TAR" : {\r
+                "PRIORITY"       : 1,\r
+                "SUFFIX"         : [".tar"],\r
+                "EXTRACTSUFFIX"  : "",\r
+                "EXTRACTFLAGS"   : "",\r
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TAR']['RUN']} ${UNPACK['EXTRACTOR']['TAR']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TAR']['EXTRACTSUFFIX']}",\r
+                "RUN"            : "",\r
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TAR']['RUN']} ${UNPACK['EXTRACTOR']['TAR']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TAR']['LISTSUFFIX']}",\r
+                "LISTSUFFIX"     : "",\r
+                "LISTFLAGS"      : "",\r
+                "LISTEXTRACTOR"  : None\r
+            },\r
+\r
+            "ZIP" : {\r
+                "PRIORITY"       : 1,\r
+                "SUFFIX"         : [".zip"],\r
+                "EXTRACTSUFFIX"  : "",\r
+                "EXTRACTFLAGS"   : "",\r
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['ZIP']['RUN']} ${UNPACK['EXTRACTOR']['ZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['ZIP']['EXTRACTSUFFIX']}",\r
+                "RUN"            : "",\r
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['ZIP']['RUN']} ${UNPACK['EXTRACTOR']['ZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['ZIP']['LISTSUFFIX']}",\r
+                "LISTSUFFIX"     : "",\r
+                "LISTFLAGS"      : "",\r
+                "LISTEXTRACTOR"  : None\r
+            }\r
+        }\r
+    }\r
+\r
+    # read tools for Windows system\r
+    if env["PLATFORM"] <> "darwin" and "win" in env["PLATFORM"] :\r
+\r
+        if env.WhereIs("7z") :\r
+            toolset["EXTRACTOR"]["TARGZ"]["RUN"]           = "7z"\r
+            toolset["EXTRACTOR"]["TARGZ"]["LISTEXTRACTOR"] = __fileextractor_win_7zip\r
+            toolset["EXTRACTOR"]["TARGZ"]["LISTFLAGS"]     = "x"\r
+            toolset["EXTRACTOR"]["TARGZ"]["LISTSUFFIX"]    = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} l -sii -ttar -y -so"\r
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTFLAGS"]  = "x"\r
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTSUFFIX"] = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} x -sii -ttar -y -oc:${UNPACK['EXTRACTDIR']}"\r
+\r
+            toolset["EXTRACTOR"]["TARBZ"]["RUN"]           = "7z"\r
+            toolset["EXTRACTOR"]["TARBZ"]["LISTEXTRACTOR"] = __fileextractor_win_7zip\r
+            toolset["EXTRACTOR"]["TARBZ"]["LISTFLAGS"]     = "x"\r
+            toolset["EXTRACTOR"]["TARBZ"]["LISTSUFFIX"]    = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} l -sii -ttar -y -so"\r
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTFLAGS"]  = "x"\r
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTSUFFIX"] = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} x -sii -ttar -y -oc:${UNPACK['EXTRACTDIR']}"\r
+\r
+            toolset["EXTRACTOR"]["BZIP"]["RUN"]            = "7z"\r
+            toolset["EXTRACTOR"]["BZIP"]["LISTEXTRACTOR"]  = __fileextractor_win_7zip\r
+            toolset["EXTRACTOR"]["BZIP"]["LISTFLAGS"]      = "l"\r
+            toolset["EXTRACTOR"]["BZIP"]["LISTSUFFIX"]     = "-y -so"\r
+            toolset["EXTRACTOR"]["BZIP"]["EXTRACTFLAGS"]   = "x"\r
+            toolset["EXTRACTOR"]["BZIP"]["EXTRACTSUFFIX"]  = "-y -oc:${UNPACK['EXTRACTDIR']}"\r
+\r
+            toolset["EXTRACTOR"]["GZIP"]["RUN"]            = "7z"\r
+            toolset["EXTRACTOR"]["GZIP"]["LISTEXTRACTOR"]  = __fileextractor_win_7zip\r
+            toolset["EXTRACTOR"]["GZIP"]["LISTFLAGS"]      = "l"\r
+            toolset["EXTRACTOR"]["GZIP"]["LISTSUFFIX"]     = "-y -so"\r
+            toolset["EXTRACTOR"]["GZIP"]["EXTRACTFLAGS"]   = "x"\r
+            toolset["EXTRACTOR"]["GZIP"]["EXTRACTSUFFIX"]  = "-y -oc:${UNPACK['EXTRACTDIR']}"\r
+\r
+            toolset["EXTRACTOR"]["ZIP"]["RUN"]             = "7z"\r
+            toolset["EXTRACTOR"]["ZIP"]["LISTEXTRACTOR"]   = __fileextractor_win_7zip\r
+            toolset["EXTRACTOR"]["ZIP"]["LISTFLAGS"]       = "l"\r
+            toolset["EXTRACTOR"]["ZIP"]["LISTSUFFIX"]      = "-y -so"\r
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTFLAGS"]    = "x"\r
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTSUFFIX"]   = "-y -oc:${UNPACK['EXTRACTDIR']}"\r
+\r
+            toolset["EXTRACTOR"]["TAR"]["RUN"]             = "7z"\r
+            toolset["EXTRACTOR"]["TAR"]["LISTEXTRACTOR"]   = __fileextractor_win_7zip\r
+            toolset["EXTRACTOR"]["TAR"]["LISTFLAGS"]       = "l"\r
+            toolset["EXTRACTOR"]["TAR"]["LISTSUFFIX"]      = "-y -ttar -so"\r
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTFLAGS"]    = "x"\r
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTSUFFIX"]   = "-y -ttar -oc:${UNPACK['EXTRACTDIR']}"\r
+\r
+        # here can add some other Windows tools, that can handle the archive files\r
+        # but I don't know which ones can handle all file types\r
+\r
+\r
+\r
+    # read the tools on *nix systems and sets the default parameters\r
+    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :\r
+\r
+        if env.WhereIs("unzip") :\r
+            toolset["EXTRACTOR"]["ZIP"]["RUN"]             = "unzip"\r
+            toolset["EXTRACTOR"]["ZIP"]["LISTEXTRACTOR"]   = __fileextractor_nix_unzip\r
+            toolset["EXTRACTOR"]["ZIP"]["LISTFLAGS"]       = "-l"\r
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTFLAGS"]    = "-oqq"\r
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTSUFFIX"]   = "-d ${UNPACK['EXTRACTDIR']}"\r
+\r
+        if env.WhereIs("tar") :\r
+            toolset["EXTRACTOR"]["TAR"]["RUN"]             = "tar"\r
+            toolset["EXTRACTOR"]["TAR"]["LISTEXTRACTOR"]   = __fileextractor_nix_tar\r
+            toolset["EXTRACTOR"]["TAR"]["LISTFLAGS"]       = "tvf"\r
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTFLAGS"]    = "xf"\r
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTSUFFIX"]   = "-C ${UNPACK['EXTRACTDIR']}"\r
+\r
+            toolset["EXTRACTOR"]["TARGZ"]["RUN"]           = "tar"\r
+            toolset["EXTRACTOR"]["TARGZ"]["LISTEXTRACTOR"] = __fileextractor_nix_tar\r
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTFLAGS"]  = "xfz"\r
+            toolset["EXTRACTOR"]["TARGZ"]["LISTFLAGS"]     = "tvfz"\r
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTSUFFIX"] = "-C ${UNPACK['EXTRACTDIR']}"\r
+\r
+            toolset["EXTRACTOR"]["TARBZ"]["RUN"]           = "tar"\r
+            toolset["EXTRACTOR"]["TARBZ"]["LISTEXTRACTOR"] = __fileextractor_nix_tar\r
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTFLAGS"]  = "xfj"\r
+            toolset["EXTRACTOR"]["TARBZ"]["LISTFLAGS"]     = "tvfj"\r
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTSUFFIX"] = "-C ${UNPACK['EXTRACTDIR']}"\r
+\r
+        if env.WhereIs("bzip2") :\r
+            toolset["EXTRACTOR"]["BZIP"]["RUN"]            = "bzip2"\r
+            toolset["EXTRACTOR"]["BZIP"]["EXTRACTFLAGS"]   = "-df"\r
+\r
+        if env.WhereIs("gzip") :\r
+            toolset["EXTRACTOR"]["GZIP"]["RUN"]            = "gzip"\r
+            toolset["EXTRACTOR"]["GZIP"]["LISTEXTRACTOR"]  = __fileextractor_nix_gzip\r
+            toolset["EXTRACTOR"]["GZIP"]["LISTFLAGS"]      = "-l"\r
+            toolset["EXTRACTOR"]["GZIP"]["EXTRACTFLAGS"]   = "-df"\r
+\r
+    else :\r
+        raise SCons.Errors.StopError("Unpack tool detection on this platform [%s] unkown" % (env["PLATFORM"]))\r
+\r
+    # the target_factory must be a "Entry", because the target list can be files and dirs, so we can not specified the targetfactory explicite\r
+    env.Replace(UNPACK = toolset)\r
+    env["BUILDERS"]["UnpackAll"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.Entry,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
+\r
+\r
+# existing function of the builder\r
+# @param env environment object\r
+# @return true\r
+def exists(env) :\r
+    return 1\r