wafsamba: add CHECK_VALUEOF() helper
[metze/samba/wip.git] / buildtools / wafsamba / samba_autoconf.py
index 5d3cc5a6882dd57202b9dc38b9a0f2709aebdf2e..65c66f393bc592c7444016aa30199b60d6b12b0e 100644 (file)
@@ -62,8 +62,8 @@ def COMPOUND_END(conf, result):
     conf.check_message_1 = conf.saved_check_message_1
     conf.check_message_2 = conf.saved_check_message_2
     p = conf.check_message_2
-    if result:
-        p('ok ')
+    if result is True:
+        p('ok')
     elif not result:
         p('not found', 'YELLOW')
     else:
@@ -323,7 +323,25 @@ def CHECK_SIZEOF(conf, vars, headers=None, define=None):
             ret = False
     return ret
 
-
+@conf
+def CHECK_VALUEOF(conf, v, headers=None, define=None):
+    '''check the value of a variable/define'''
+    ret = True
+    v_define = define
+    if v_define is None:
+        v_define = 'VALUEOF_%s' % v.upper().replace(' ', '_')
+    if CHECK_CODE(conf,
+                  'printf("%%u", (unsigned)(%s))' % v,
+                  define=v_define,
+                  execute=True,
+                  define_ret=True,
+                  quote=False,
+                  headers=headers,
+                  local_include=False,
+                  msg="Checking value of %s" % v):
+        return int(conf.env[v_define])
+
+    return None
 
 @conf
 def CHECK_CODE(conf, code, define,