@conf
-def CHECK_VARIABLE(conf, v, define=None, always=False, headers=None):
+def CHECK_VARIABLE(conf, v, define=None, always=False, headers=None, msg=None):
'''check for a variable declaration (or define)'''
hdrs=''
if headers is not None:
hdrs += '#include <%s>\n' % h
if define is None:
define = 'HAVE_%s' % v.upper()
+
+ if CONFIG_SET(conf, define):
+ return True
+
+ if msg is None:
+ msg="Checking for variable %s" % v
+
if conf.check(fragment=
'''
%s
}
''' % (hdrs, v, v),
execute=0,
- msg="Checking for variable %s" % v):
+ msg=msg):
conf.DEFINE(define, 1)
return True
elif always:
define='HAVE_DECL_%s' % v.upper()
else:
define='HAVE_%s_DECL' % v.upper()
- if not CHECK_VARIABLE(conf, v, define=define, headers=headers):
+ if not CHECK_VARIABLE(conf, v,
+ define=define,
+ headers=headers,
+ msg='Checking for declaration of %s' % v):
ret = False
return ret
def CHECK_CODE(conf, code, define,
always=False, execute=False, addmain=True, mandatory=False,
headers=None, msg=None, cflags='', includes='# .',
- local_include=True):
+ local_include=True, lib='c'):
'''check if some code compiles and/or runs'''
hdrs=''
if headers is not None:
mandatory = mandatory,
ccflags=TO_LIST(cflags),
includes=includes,
+ lib=lib, # how do I make this conditional, so I can avoid the -lc?
msg=msg):
conf.DEFINE(define, 1)
return True
return ret
+@conf
+def CHECK_C_PROTOTYPE(conf, function, prototype, define, headers=None):
+ '''verify that a C prototype matches the one on the current system'''
+ if not conf.CHECK_DECLS(function, headers=headers):
+ return False
+ return conf.CHECK_CODE('%s;\n%s()' % (prototype, function),
+ define=define,
+ msg='Checking C prototype for %s' % function)
+
+
+
+
#################################################
# write out config.h in the right directory
@conf