# a waf tool to add autoconf-like macros to the configure section
-import Build, os, Options, preproc, Logs
+import Build, os, sys, Options, preproc, Logs
import string
from Configure import conf
from samba_utils import *
def CHECK_HEADER(conf, h, add_headers=False, lib=None):
'''check for a header'''
- if h in missing_headers:
+ if h in missing_headers and lib is None:
return False
d = h.upper().replace('/', '_')
d = d.replace('.', '_')
if msg is None:
msg="Checking for %s" % define
+ cflags = TO_LIST(cflags)
+
if local_include:
- cflags += ' -I%s' % conf.curdir
+ cflags.append('-I%s' % conf.curdir)
if not link:
type='nolink'
(ccflags, ldflags) = library_flags(conf, uselib)
- cflags = TO_LIST(cflags)
cflags.extend(ccflags)
if on_target:
msg="Checking linker accepts %s" % ldflags)
+@conf
+def CONFIG_GET(conf, option):
+ '''return True if a configuration option was found'''
+ if (option in conf.env):
+ return conf.env[option]
+ else:
+ return None
+
@conf
def CONFIG_SET(conf, option):
'''return True if a configuration option was found'''
return (option in conf.env) and (conf.env[option] != ())
Build.BuildContext.CONFIG_SET = CONFIG_SET
+Build.BuildContext.CONFIG_GET = CONFIG_GET
-def library_flags(conf, libs):
+def library_flags(self, libs):
'''work out flags from pkg_config'''
ccflags = []
ldflags = []
for lib in TO_LIST(libs):
- inc_path = getattr(conf.env, 'CPPPATH_%s' % lib.upper(), [])
- lib_path = getattr(conf.env, 'LIBPATH_%s' % lib.upper(), [])
+ inc_path = getattr(self.env, 'CPPPATH_%s' % lib.upper(), [])
+ lib_path = getattr(self.env, 'LIBPATH_%s' % lib.upper(), [])
ccflags.extend(['-I%s' % i for i in inc_path])
ldflags.extend(['-L%s' % l for l in lib_path])
- extra_ccflags = TO_LIST(getattr(conf.env, 'CCFLAGS_%s' % lib.upper(), []))
- extra_ldflags = TO_LIST(getattr(conf.env, 'LDFLAGS_%s' % lib.upper(), []))
+ extra_ccflags = TO_LIST(getattr(self.env, 'CCFLAGS_%s' % lib.upper(), []))
+ extra_ldflags = TO_LIST(getattr(self.env, 'LDFLAGS_%s' % lib.upper(), []))
ccflags.extend(extra_ccflags)
ldflags.extend(extra_ldflags)
- if 'EXTRA_LDFLAGS' in conf.env:
- ldflags.extend(conf.env['EXTRA_LDFLAGS'])
+ if 'EXTRA_LDFLAGS' in self.env:
+ ldflags.extend(self.env['EXTRA_LDFLAGS'])
+
ccflags = unique_list(ccflags)
ldflags = unique_list(ldflags)
return (ccflags, ldflags)
@conf
-def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True):
+def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True, shlib=False):
'''check if a set of libraries exist as system libraries
returns the sublist of libs that do exist as a syslib or []
'''
+ fragment= '''
+int foo()
+{
+ int v = 2;
+ return v*2;
+}
+'''
ret = []
liblist = TO_LIST(libs)
for lib in liblist[:]:
continue
(ccflags, ldflags) = library_flags(conf, lib)
+ if shlib:
+ res = conf.check(features='cc cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags)
+ else:
+ res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags)
- if not conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags):
+ if not res:
if mandatory:
Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
sys.exit(1)
if Options.options.developer:
# we add these here to ensure that -Wstrict-prototypes is not set during configure
- conf.ADD_CFLAGS('-Wall -g -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k',
+ conf.ADD_CFLAGS('-Wall -g -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k -Wmissing-prototypes',
testflags=True)
+ if os.getenv('TOPLEVEL_BUILD'):
+ conf.ADD_CFLAGS('-Wcast-qual', testflags=True)
+ conf.env.DEVELOPER_MODE = True
if Options.options.picky_developer:
conf.ADD_CFLAGS('-Werror', testflags=True)
def ADD_LDFLAGS(conf, flags, testflags=False):
'''add some LDFLAGS to the command line
optionally set testflags to ensure all the flags work
+
+ this will return the flags that are added, if any
'''
if testflags:
ok_flags=[]
if not 'EXTRA_LDFLAGS' in conf.env:
conf.env['EXTRA_LDFLAGS'] = []
conf.env['EXTRA_LDFLAGS'].extend(TO_LIST(flags))
-
+ return flags
@conf