1 #******************************************************************
3 # Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26 target_os = env.get('TARGET_OS')
27 target_arch = env.get('TARGET_ARCH')
29 ######################################################################
30 # Generate iotivity_config.h using presence of headers
31 ######################################################################
33 config_h_env = env.Clone()
34 conf = Configure(config_h_env)
37 /* ****************************************************************************
38 * iotivity_config.h - IoTivity platform-specific configuration header.
40 * Auto-generated code for the %s %s platform.
44 *************************************************************************** */
46 #ifndef IOTIVITY_CONFIG_H__
47 #define IOTIVITY_CONFIG_H__
49 ''' % (str(target_os), str(target_arch), str(datetime.datetime.utcnow()))
55 #include "platform_features.h"
57 #endif // IOTIVITY_CONFIG_H__
61 cxx_headers = ['arpa/inet.h',
88 if target_os == 'arduino':
89 # Detection of headers on the Arduino platform is currently broken.
92 if target_os == 'msys_nt':
93 # WinPThread provides a pthread.h, but we want to use native threads.
94 cxx_headers.remove('pthread.h')
96 def get_define_from_header_file(header_file):
97 header_file_converted = header_file.replace("/","_").replace(".","_").upper()
98 return "HAVE_" + header_file_converted
100 for header_file_name in cxx_headers:
101 if conf.CheckCXXHeader(header_file_name):
102 config_h_body += "#define %s 1\n\n" % get_define_from_header_file(header_file_name)
105 # Autoconf feature doesn't work with Jenkins' arduino toolchain, so hardcode it here.
106 if target_os == 'arduino':
107 config_h_body += "#define HAVE_ARDUINO_TIME_H\n\n"
110 src_dir = env.get('SRC_DIR')
111 config_h_file_path = os.path.join(src_dir, 'resource', 'c_common', 'iotivity_config.h')
112 if os.path.exists(config_h_file_path):
113 os.remove(config_h_file_path)
114 config_h_file = open(config_h_file_path, "w")
115 config_h_file.write(config_h_header + config_h_body + config_h_footer)
116 config_h_file.close()
118 # Sanity check to ensure that the above block created the file.
119 if not os.path.exists(config_h_file_path):
120 print "Error: iotivity_config.h file not created!"
122 # iotivity_config.h should be copied to the build dir
123 env.UserInstallTargetHeader(config_h_file_path, 'c_common', 'iotivity_config.h')
125 # Use the generated file internally
126 env.AppendUnique(CPPPATH = [os.path.join(src_dir, 'resource', 'c_common')])
128 ######################################################################
130 ######################################################################
131 # Add platform-specific helper library
132 ######################################################################
134 if target_os in ['windows', 'msys_nt']:
135 SConscript('windows/SConscript')
137 env.AppendUnique(CPPPATH = [
138 os.path.join(Dir('.').abspath, 'oic_malloc', 'include'),
139 os.path.join(Dir('.').abspath, 'oic_string', 'include'),
140 os.path.join(Dir('.').abspath, 'oic_time', 'include'),
141 os.path.join(Dir('.').abspath, 'ocrandom', 'include')
144 if target_os == 'tizen':
145 env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
147 env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'c_common')])
149 if target_os in ['tizen', 'linux']:
150 env.ParseConfig("pkg-config --cflags --libs uuid")
152 common_env = env.Clone()
154 ######################################################################
155 # Source files and Targets
156 ######################################################################
158 'oic_string/src/oic_string.c',
159 'oic_malloc/src/oic_malloc.c',
160 'oic_time/src/oic_time.c',
161 'ocrandom/src/ocrandom.c',
163 commonlib = common_env.StaticLibrary('c_common', common_src)
164 common_env.InstallTarget(commonlib, 'c_common')
165 common_env.UserInstallTargetLib(commonlib, 'c_common')
166 common_env.UserInstallTargetHeader('platform_features.h', 'c_common', 'platform_features.h')
168 env.PrependUnique(LIBS = ['c_common'])