summaryrefslogtreecommitdiff
path: root/buildtools/wafsamba/samba_autoconf.py
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-07 17:00:22 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:26:43 +1000
commiteadf918402996d7f9d737679c958f2dc1b6f8783 (patch)
tree089ee095b150ff5cbf8d2b00062cb38faa343108 /buildtools/wafsamba/samba_autoconf.py
parentaac8aec0d1bd07aa4a2521c87807b88f54ac090d (diff)
downloadsamba-eadf918402996d7f9d737679c958f2dc1b6f8783.tar.gz
samba-eadf918402996d7f9d737679c958f2dc1b6f8783.tar.bz2
samba-eadf918402996d7f9d737679c958f2dc1b6f8783.zip
build: expand CHECK_CODE() function
Diffstat (limited to 'buildtools/wafsamba/samba_autoconf.py')
-rw-r--r--buildtools/wafsamba/samba_autoconf.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 3dc2a30884..804e65391c 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -166,9 +166,10 @@ def CHECK_SIZEOF(conf, vars, headers=None, define=None):
@conf
-def CHECK_CODE_COMPILES(conf, code, define,
- always=False, headers=None):
- '''check if some code compiles'''
+def CHECK_CODE(conf, code, define,
+ always=False, execute=False, addmain=True,
+ headers=None, msg=None):
+ '''check if some code compiles and/or runs'''
hdrs=''
if headers is not None:
hlist = to_list(headers)
@@ -176,15 +177,27 @@ def CHECK_CODE_COMPILES(conf, code, define,
hlist = conf.env.hlist
for h in hlist:
hdrs += '#include <%s>\n' % h
- if conf.check(fragment='''
- %s
- int main(void) {
- %s;
- return 0;
- }
- ''' % (hdrs, code),
- execute=0,
- msg="Checking %s" % define):
+
+ if execute:
+ execute = 1
+ else:
+ execute = 0
+
+ if addmain:
+ fragment='#include "confdefs.h"\n%s\n int main(void) { %s; return 0; }' % (hdrs, code)
+ else:
+ fragment='#include "confdefs.h"\n%s\n%s' % (hdrs, code)
+
+ conf.write_config_header('confdefs.h', top=True)
+
+ if msg is None:
+ msg="Checking for %s" % define
+
+ if conf.check(fragment=fragment,
+ execute=execute,
+ ccflags='-I%s' % conf.curdir,
+ includes='# . ../default',
+ msg=msg):
conf.DEFINE(define, 1)
return True
elif always: