Build system base on scons(oic-resource)
[platform/upstream/iotivity.git] / build_common / darwin / SConscript
1 ##
2 # This script set darwin specific flags (GNU GCC)
3 #
4 ##
5 import platform
6
7 Import('env', 'RELEASE_BUILD', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'SYS_VERSION')
8
9 if SYS_VERSION is None:
10         print '''
11 *********************************** Error *************************************
12 *   MAC OSX/IOS version isn't set, please set it in command line as :         *
13 *      # scons SYS_VERSION=<version> ...                                      *
14 *   To get the version, please see:                                                               *
15 * /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/   *
16 * /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ *
17 *******************************************************************************
18 '''
19         Exit(1)
20
21 # Set release/debug flags
22 if RELEASE_BUILD:
23         env.AppendUnique(CFLAGS = ['-Os'])
24         env.AppendUnique(CXXFLAGS = ['-Os'])
25         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
26 else:
27         env.AppendUnique(CFLAGS = ['-g'])
28         env.AppendUnique(CXXFLAGS = ['-g'])
29
30 if BUILD_TARGET == 'darwin':
31         SYS_ROOT = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + SYS_VERSION + '.sdk/'
32 else:
33         if TARGET_CPU_ARCH in ['i386', 'x86_64']:
34                 SYS_ROOT = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator' + SYS_VERSION + '.sdk/'
35         else:
36                 SYS_ROOT = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS' + SYS_VERSION + '.sdk/'
37
38 # Set arch flags
39 env.AppendUnique(CXXFLAGS = ['-arch', TARGET_CPU_ARCH, '-isysroot', SYS_ROOT])
40 env.AppendUnique(CCFLAGS = ['-arch', TARGET_CPU_ARCH, '-isysroot', SYS_ROOT])
41 env.AppendUnique(LINKFLAGS = ['-arch', TARGET_CPU_ARCH, '-isysroot', SYS_ROOT])
42
43 if BUILD_TARGET == 'darwin':
44         flag = '-mmacosx-version-min=' + SYS_VERSION
45         env.AppendUnique(CXXFLAGS = [flag])
46         env.AppendUnique(CCFLAGS = [flag])
47         env.AppendUnique(LINKFLAGS = [flag])