Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / build_common / darwin / SConscript
1 ##
2 # This script set darwin specific flags (GNU GCC)
3 #
4 ##
5 import os
6 import platform
7
8 Import('env')
9
10 # SYS_VERSION build option
11 help_vars = Variables()
12 help_vars.Add('SYS_VERSION', 'MAC OS X version / IOS version', os.environ.get('SYS_VERSION'))
13 help_vars.Update(env)
14 Help(help_vars.GenerateHelpText(env))
15
16 sys_version = env.get('SYS_VERSION')
17
18 if sys_version is None:
19         print '''
20 *********************************** Error *************************************
21 *   MAC OSX/IOS version isn't set, please set it in command line as :         *
22 *      # scons TARGET_ARCH=<arch> TARGET_OS=<os> SYS_VERSION=<version> ...    *
23 *   To get the version, please see:                                                               *
24 * /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/   *
25 * /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ *
26 *   <arch> is 'armv7','armv7s','arm64','i386', 'x86_64'
27 *   <os> is 'darwin','ios'
28 *******************************************************************************
29 '''
30         Exit(1)
31
32 target_arch = env.get('TARGET_ARCH')
33 target_os = env.get('TARGET_OS')
34 # Set release/debug flags
35 if env.get('RELEASE'):
36         env.AppendUnique(CCFLAGS = ['-Os'])
37         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
38 else:
39         env.AppendUnique(CCFLAGS = ['-g'])
40         env.AppendUnique(LINKFLAGS = ['-g'])
41
42 if target_os == 'darwin':
43         sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
44 else:
45         if target_arch in ['i386', 'x86_64']:
46                 sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator' + sys_version + '.sdk/'
47         else:
48                 sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS' + sys_version + '.sdk/'
49
50 # Set arch flags
51 env.AppendUnique(CCFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
52 env.AppendUnique(LINKFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
53
54 if target_os == 'darwin':
55         flag = '-mmacosx-version-min=' + sys_version
56         env.AppendUnique(CCFLAGS = [flag])
57         env.AppendUnique(LINKFLAGS = [flag])