From f110ad252fb9b3f4fcf569a943a1531ddd03ee56 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Mon, 7 Mar 2011 20:19:59 +0900 Subject: BENTO: check for C99 formats + add check_declaration. --- numpy/build_utils/__init__.py | 29 +++++++++++++++++++++++++++++ numpy/core/bscript | 6 ++++++ 2 files changed, 35 insertions(+) (limited to 'numpy') diff --git a/numpy/build_utils/__init__.py b/numpy/build_utils/__init__.py index 17bf8b009..ba9fa72be 100644 --- a/numpy/build_utils/__init__.py +++ b/numpy/build_utils/__init__.py @@ -77,3 +77,32 @@ int main() return ret == 0 return ret +@waflib.Configure.conf +def check_declaration(self, symbol, **kw): + code = r""" +int main() +{ +#ifndef %s + (void) %s; +#endif + ; + return 0; +} +""" % (symbol, symbol) + + kw["code"] = to_header(kw) + code + kw["msg"] = "Checking for macro %r" % symbol + kw["errmsg"] = "not found" + kw["okmsg"] = "yes" + + validate_arguments(self, kw) + try_compile(self, kw) + ret = kw["success"] + + kw["define_name"] = "HAVE_DECL_%s" % sanitize_string(symbol) + kw["define_comment"] = "/* Set to 1 if %s is defined. */" % symbol + self.post_check(**kw) + if not kw.get('execute', False): + return ret == 0 + return ret + diff --git a/numpy/core/bscript b/numpy/core/bscript index 0f9a1f3aa..22913ac3c 100644 --- a/numpy/core/bscript +++ b/numpy/core/bscript @@ -50,6 +50,12 @@ def configure(context): except waflib.Errors.ConfigurationError: NUMPYCONFIG_SYM.append(('DEFINE_NPY_HAVE_ENDIAN_H', '')) + try: + conf.check_declaration('PRIdPTR', header_name='inttypes.h') + NUMPYCONFIG_SYM.append(('DEFINE_NPY_USE_C99_FORMATS', '#define NPY_USE_C99_FORMATS 1')) + except waflib.Errors.ConfigurationError: + NUMPYCONFIG_SYM.append(('DEFINE_NPY_USE_C99_FORMATS', '')) + conf.env["CONFIG_HEADER_TEMPLATE"] = """\ %(content)s #ifndef _NPY_NPY_CONFIG_H_ -- cgit v1.2.1