Merge "Added code to send close_notify alert when OC stack shuts down."
[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 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 *******************************************************************************
27 '''
28         Exit(1)
29
30 target_arch = env.get('TARGET_ARCH')
31 target_os = env.get('TARGET_OS')
32 # Set release/debug flags
33 if env.get('RELEASE'):
34         env.AppendUnique(CCFLAGS = ['-Os'])
35         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
36 else:
37         env.AppendUnique(CCFLAGS = ['-g'])
38
39 if target_os == 'darwin':
40         sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
41 else:
42         if target_arch in ['i386', 'x86_64']:
43                 sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator' + sys_version + '.sdk/'
44         else:
45                 sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS' + sys_version + '.sdk/'
46
47 # Set arch flags
48 env.AppendUnique(CCFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
49 env.AppendUnique(LINKFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
50
51 if target_os == 'darwin':
52         flag = '-mmacosx-version-min=' + sys_version
53         env.AppendUnique(CCFLAGS = [flag])
54         env.AppendUnique(LINKFLAGS = [flag])