Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / lib / libUPnP / Platinum / Build / Targets / arm-android-linux / Config.scons
blobbdbf08d3e65c407f2a71929baa09bb9e932499f9
1 #################################################################
2 # Important: this build file has been tested with Android NDK r6, r7 and r8
3 # It may or may not work with other releases of the NDK. Please notify
4 # us if you find a newer NDK for which this does not work.
5 #################################################################
7 import os
8 import re
9 import sys
10 import platform
12 # we need to know when the NDK is
13 ANDROID_NDK_ROOT=os.getenv('ANDROID_NDK_ROOT')
14 if not ANDROID_NDK_ROOT:
15     raise Exception('ANDROID_NDK_ROOT environment variable not set')
17 # detect the host system on which we're running
18 if env.has_key('android_host_system') and env['android_host_system']:
19         ANDROID_HOST_SYSTEM = env['android_host_system']
20 else:
21         PLATFORM_TO_TARGET_MAP = {
22         'linux-i386' : 'linux-x86',
23         'linux2'     : 'linux-x86',
24         'win32'      : 'windows',
25         'cygwin'     : 'windows',
26         'darwin'     : 'darwin-x86'
27         }
28         if sys.platform in PLATFORM_TO_TARGET_MAP:
29                 ANDROID_HOST_SYSTEM = PLATFORM_TO_TARGET_MAP[sys.platform]
30         else:
31                 raise Exception('Android Host Platform cannot be determined')
33 # set defaults
34 ANDROID_ARCH         = 'arm'
35 ANDROID_PLATFORM     = 'android-9'
36 ANDROID_TOOLCHAIN    = 'arm-linux-androideabi-4.4.3'
37 ANDROID_CROSS_PREFIX = 'arm-linux-androideabi'
39 if not os.path.exists(os.path.join(ANDROID_NDK_ROOT, 'toolchains', ANDROID_TOOLCHAIN)):
40     toolchain_dirs = os.listdir(ANDROID_NDK_ROOT+'/toolchains')
41     for toolchain_dir in toolchain_dirs:
42         if os.path.exists(os.path.join(ANDROID_NDK_ROOT, 'toolchains', toolchain_dir, 'prebuilt', ANDROID_HOST_SYSTEM)):
43             ANDROID_TOOLCHAIN=toolchain_dir
44             suffix_pos = toolchain_dir.rfind('-')
45             if (suffix_pos >= 0):
46                 ANDROID_CROSS_PREFIX = ANDROID_TOOLCHAIN[:suffix_pos]
47             print "Auto-selecting toolchain:", ANDROID_TOOLCHAIN
48             break
50 # override defaults from command line args
51 if ARGUMENTS.get('android_toolchain'):
52     ANDROID_TOOLCHAIN=ARGUMENTS.get('android_toolchain')
54 if ARGUMENTS.get('android_cross_prefix'):
55     ANDROID_CROSS_PREFIX=ARGUMENTS.get('android_cross_prefix')
57 if ARGUMENTS.get('android_platform'):
58     ANDROID_PLATFORM=ARGUMENTS.get('android_platform')
60 if ARGUMENTS.get('android_arch'):
61     ANDROID_ARCH=ARGUMENTS.get('android_arch')
63 print 'Building for Android: '
64 print 'ANDROID_HOST_SYSTEM =', ANDROID_HOST_SYSTEM
65 print 'ANDROID_TOOLCHAIN   =', ANDROID_TOOLCHAIN
66 print 'ANDROID_PLATFORM    =', ANDROID_PLATFORM
67 print 'ANDROID_ARCH        =', ANDROID_ARCH
69 ANDROID_TOOLCHAIN_BIN = ANDROID_NDK_ROOT+'/toolchains/'+ANDROID_TOOLCHAIN+'/prebuilt/'+ANDROID_HOST_SYSTEM+'/bin'
70 ANDROID_SYSROOT = ANDROID_NDK_ROOT+'/platforms/'+ANDROID_PLATFORM+'/arch-'+ANDROID_ARCH
72 ### add the tools to the path
73 env.PrependENVPath('PATH', ANDROID_TOOLCHAIN_BIN)
75 ### special C Runtime startup for executables
76 env['NPT_EXTRA_EXECUTABLE_OBJECTS'] = []
77 env['NPT_EXTRA_LIBS'] = ['gcc']
79 ### Load the tools
80 LoadTool('gcc-generic', env, gcc_cross_prefix=ANDROID_CROSS_PREFIX, gcc_strict=False)
81 env.AppendUnique(CCFLAGS = ['-I'+ANDROID_NDK_ROOT+'/sources/cxx-stl/system/include' ,
82                             '--sysroot', ANDROID_SYSROOT,
83                             '-msoft-float',
84                             '-fpic',
85                             '-mthumb-interwork',
86                             '-ffunction-sections',
87                             '-funwind-tables',
88                             '-fstack-protector',
89                             '-fno-short-enums'])
90 env.AppendUnique(CXXFLAGS = ['-fno-exceptions', '-fno-rtti'])
91 env.AppendUnique(CPPDEFINES = ['ANDROID', 'NPT_CONFIG_HAVE_SYSTEM_LOG_CONFIG'])
92 env.AppendUnique(LINKFLAGS = ['--sysroot', ANDROID_SYSROOT,
93                                           '-Wl,--no-undefined',
94                               '-Wl,-z,noexecstack',
95                                           '-L'+ANDROID_SYSROOT+'/usr/lib',
96                                           '-lc',
97                                           '-lstdc++',
98                                           '-lm',
99                                           '-llog',
100                                           '-ldl'])
102 ### Specific System choices
103 env['NPT_SYSTEM_SOURCES']={'System/StdC':'NptStdc[!D]*.cpp',
104                            'System/Bsd':'*.cpp',
105                            'System/Posix':'*.cpp',
106                            'System/Null':['NptNullSerialPort.cpp', 'NptNullAutoreleasePool.cpp'],
107                            'System/Android':'*.cpp'}