import os
import platform
+project_version = '1.2.0'
+
# Map of host os and allowed target os (host: allowed target os)
host_target_map = {
'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
logging_default = (release_mode == False)
-
######################################################################
# Common build options (release, target os, target arch)
######################################################################
help_vars.Add(BoolVariable('WITH_RA', 'Build with Remote Access module', False))
help_vars.Add(BoolVariable('WITH_TCP', 'Build with TCP adapter', False))
+help_vars.Add(BoolVariable('WITH_PROXY', 'Build with CoAP-HTTP Proxy', False))
help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER']))
help_vars.Add(BoolVariable('WITH_CLOUD', 'Build including AccountManager class and Cloud Client sample', False))
help_vars.Add(ListVariable('RD_MODE', 'Resource Directory build mode', 'CLIENT', ['CLIENT', 'SERVER']))
######################################################################
pc_file = env.get('SRC_DIR') + '/iotivity.pc.in'
-if env.get('ROUTING') == 'GW':
- routing_define = 'ROUTING_GATEWAY'
-elif env.get('ROUTING') == 'EP':
- routing_define = 'ROUTING_EP'
-
user_prefix = env.get('PREFIX')
user_lib = env.get('LIB_INSTALL_DIR')
+
+if not user_prefix:
+ user_prefix = env.get('BUILD_DIR').encode('string_escape')
+
if not user_lib:
- user_lib = '$${prefix}/lib'
-
-if user_prefix:
- pc_vars = {'\@PREFIX\@': user_prefix,
- '\@EXEC_PREFIX\@':user_prefix,
- '\@VERSION\@': '1.2.0',
- '\@LIB_INSTALL_DIR\@': user_lib,
- '\@ROUTING_DEFINE\@': routing_define
- }
-else:
- pc_vars = {'\@PREFIX\@': env.get('BUILD_DIR').encode('string_escape'),
- '\@EXEC_PREFIX\@': env.get('BUILD_DIR').encode('string_escape'),
- '\@VERSION\@': '1.2.0',
- '\@LIB_INSTALL_DIR\@': user_lib,
- '\@ROUTING_DEFINE\@': routing_define
- }
+ user_lib = '$${prefix}/lib'
+
+defines = []
+if env.get('LOGGING'):
+ defines.append('-DTB_LOG=1')
+
+if env.get('ROUTING') == 'GW':
+ defines.append('-DROUTING_GATEWAY=1')
+elif env.get('ROUTING') == 'EP':
+ defines.append('-DROUTING_EP=1')
+
+pc_vars = {
+ '\@VERSION\@': project_version,
+ '\@PREFIX\@': user_prefix,
+ '\@EXEC_PREFIX\@': user_prefix,
+ '\@LIB_INSTALL_DIR\@': user_lib,
+ '\@DEFINES\@': " ".join(defines)
+}
env.Substfile(pc_file, SUBST_DICT = pc_vars)
# POSIX_SUPPORTED, 1 if it is supported, 0 otherwise
conf.CheckPThreadsSupport()
+######################################################################
+# Generate macros for presence of headers
+######################################################################
+cxx_headers = ['arpa/inet.h',
+ 'fcntl.h',
+ 'grp.h',
+ 'in6addr.h',
+ 'linux/limits.h',
+ 'memory.h',
+ 'netdb.h',
+ 'netinet/in.h',
+ 'pthread.h',
+ 'pwd.h',
+ 'stdlib.h',
+ 'string.h',
+ 'strings.h',
+ 'sys/socket.h',
+ 'sys/stat.h',
+ 'sys/time.h',
+ 'sys/timeb.h',
+ 'sys/types.h',
+ 'sys/unistd.h',
+ 'syslog.h',
+ 'time.h',
+ 'unistd.h',
+ 'uuid/uuid.h',
+ 'windows.h',
+ 'winsock2.h',
+ 'ws2tcpip.h']
+
+if target_os == 'arduino':
+ # Detection of headers on the Arduino platform is currently broken.
+ cxx_headers = []
+
+if target_os == 'msys_nt':
+ # WinPThread provides a pthread.h, but we want to use native threads.
+ cxx_headers.remove('pthread.h')
+
+def get_define_from_header_file(header_file):
+ header_file_converted = header_file.replace("/","_").replace(".","_").upper()
+ return "HAVE_" + header_file_converted
+
+for header_file_name in cxx_headers:
+ if conf.CheckCXXHeader(header_file_name):
+ conf.env.AppendUnique(CPPDEFINES = [get_define_from_header_file(header_file_name)])
+
env = conf.Finish()
######################################################################