build: Add conditional compilation
Two conditionals are introduced in this commit:
- if <ifaddrs.h> is not available, NetworkInterface helper will always return
an empty set of interfaces
- If dropping/elevating effective user/group is not supported, an error
will be thrown if used (e.g., if general.user or general.group is
configured)
Both conditionals are necessary on Android platform.
Change-Id: Ib360e03514af97ed2d68032fbcbe279a8dc84682
diff --git a/wscript b/wscript
index 65c249a..34de382 100644
--- a/wscript
+++ b/wscript
@@ -73,6 +73,15 @@
conf.checkDependency(name='librt', lib='rt', mandatory=False)
conf.checkDependency(name='libresolv', lib='resolv', mandatory=False)
+ conf.check_cxx(header_name='ifaddrs.h', mandatory=False)
+ try:
+ for function in ['setegid', 'seteuid', 'sysconf', 'getgrnam_r', 'getpwnam_r']:
+ conf.check_cxx(function_name=function,
+ header_name=['unistd.h', 'pwd.h', 'grp.h'], mandatory=True)
+ conf.define('HAVE_PRIVILEGE_DROP_AND_ELEVATE', 1)
+ except:
+ Logs.warn('Dropping privileges is not supported on this platform')
+
boost_libs = 'system chrono program_options random'
if conf.options.with_tests:
conf.env['WITH_TESTS'] = 1