- config_pre = '', config_post = '',
- headers = [], functions = [], types = [], libs = [],
- custom_tests = [], extra_items = []):
- ''' create a configuration file, with options
- config_file: which file to create
- config_pre: first part of the config file
- config_post: last part of the config file
- headers: header files to check, in the form of a list of
- ('file', 'HAVE_FILE', 'c'/'c++')
- functions: functions to check, in the form of a list of
- ('func', 'HAVE_func', 'include lines'/None)
- types: types to check, in the form of a list of
- ('type', 'HAVE_TYPE', 'includelines'/None)
- libs: libraries to check, in the form of a list of
- ('lib', 'HAVE_LIB', 'LIB_NAME'). HAVE_LIB will be set if 'lib' exists,
- or any of the libs exists if 'lib' is a list of libs.
- Optionally, user can provide another key LIB_NAME, that will
- be set to the detected lib (or None otherwise).
- custom_tests: extra tests to perform, in the form of a list of
- (test (True/False), 'key', 'desc', 'true config line', 'false config line')
- If the last two are ignored, '#define key 1' '/*#undef key */'
- will be used.
- extra_items: extra configuration lines, in the form of a list of
- ('config', 'description')
- Return:
- The result of each test, as a dictioanry of
- res['XXX'] = True/False
- XXX are keys defined in each argument.
- '''
- cont = config_pre + '\n'
- result = {}
- # add to this string, in appropriate format
- def configString(lines, desc=''):
- text = ''
- if lines.strip() != '':
- if desc != '':
- text += '/* ' + desc + ' */\n'
- text += lines + '\n\n'
- return text
- #
- # headers
- for header in headers:
- description = "Define to 1 if you have the <%s> header file." % header[0]
- if (header[2] == 'c' and conf.CheckCHeader(header[0])) or \
- (header[2] == 'cxx' and conf.CheckCXXHeader(header[0])):
- result[header[1]] = True
- cont += configString('#define %s 1' % header[1], desc = description)
- else:
- result[header[1]] = False
- cont += configString('/* #undef %s */' % header[1], desc = description)
- # functions
- for func in functions:
- description = "Define to 1 if you have the `%s' function." % func[0]
- if conf.CheckFunc(func[0], header=func[2]):
- result[func[1]] = True
- cont += configString('#define %s 1' % func[1], desc = description)
- else:
- result[func[1]] = False
- cont += configString('/* #undef %s */' % func[1], desc = description)
- # types
- for t in types:
- description = "Define to 1 if you have the `%s' type." % t[0]
- if conf.CheckType(t[0], includes=t[2]):
- result[t[1]] = True
- cont += configString('#define %s 1' % t[1], desc = description)
- else:
- result[t[1]] = False
- cont += configString('/* #undef %s */' % t[1], desc = description)
- # libraries
- for lib in libs:
- description = "Define to 1 if you have the `%s' library (-l%s)." % (lib[0], lib[0])
- if type(lib[0]) is type(''):
- lib_list = [lib[0]]
- else:
- lib_list = lib[0]
- # check if any of the lib exists
- result[lib[1]] = False
- # if user want the name of the lib detected
- if len(lib) == 3:
- result[lib[2]] = None
- for ll in lib_list:
- if conf.CheckLib(ll):
- result[lib[1]] = True
+ config_pre = '', config_post = '',
+ headers = [], functions = [], declarations = [], types = [], libs = [],
+ custom_tests = [], extra_items = []):
+ ''' create a configuration file, with options
+ config_file: which file to create
+ config_pre: first part of the config file
+ config_post: last part of the config file
+ headers: header files to check, in the form of a list of
+ ('file', 'HAVE_FILE', 'c'/'c++')
+ functions: functions to check, in the form of a list of
+ ('func', 'HAVE_func', 'include lines'/None)
+ declarations: function declarations to check, in the form of a list of
+ ('func', 'HAVE_DECL_func', header_files)
+ types: types to check, in the form of a list of
+ ('type', 'HAVE_TYPE', 'includelines'/None)
+ libs: libraries to check, in the form of a list of
+ ('lib', 'HAVE_LIB', 'LIB_NAME'). HAVE_LIB will be set if 'lib' exists,
+ or any of the libs exists if 'lib' is a list of libs.
+ Optionally, user can provide another key LIB_NAME, that will
+ be set to the detected lib (or None otherwise).
+ custom_tests: extra tests to perform, in the form of a list of
+ (test (True/False), 'key', 'desc', 'true config line', 'false config line')
+ If the last two are ignored, '#define key 1' '/*#undef key */'
+ will be used.
+ extra_items: extra configuration lines, in the form of a list of
+ ('config', 'description')
+ Return:
+ The result of each test, as a dictioanry of
+ res['XXX'] = True/False
+ XXX are keys defined in each argument.
+ '''
+ cont = config_pre + '\n'
+ result = {}
+ # add to this string, in appropriate format
+ def configString(lines, desc=''):
+ text = ''
+ if lines.strip() != '':
+ if desc != '':
+ text += '/* ' + desc + ' */\n'
+ text += lines + '\n\n'
+ return text
+ #
+ # headers
+ for header in headers:
+ description = "Define to 1 if you have the <%s> header file." % header[0]
+ if (header[2] == 'c' and conf.CheckCHeader(header[0])) or \
+ (header[2] == 'cxx' and conf.CheckCXXHeader(header[0])):
+ result[header[1]] = 1
+ cont += configString('#define %s 1' % header[1], desc = description)
+ else:
+ result[header[1]] = 0
+ cont += configString('/* #undef %s */' % header[1], desc = description)
+ # functions
+ for func in functions:
+ description = "Define to 1 if you have the `%s' function." % func[0]
+ if conf.CheckFunc(func[0], header=func[2]):
+ result[func[1]] = 1
+ cont += configString('#define %s 1' % func[1], desc = description)
+ else:
+ result[func[1]] = 0
+ cont += configString('/* #undef %s */' % func[1], desc = description)
+ for decl in declarations:
+ description = "Define to 1 if you have the declaration of `%s', and to 0 if you don't." % decl[0]
+ if conf.CheckDeclaration(decl[0], decl[2]):
+ result[decl[1]] = 1
+ cont += configString('#define %s 1' % decl[1], desc = description)
+ else:
+ result[decl[1]] = 0
+ cont += configString('/* #undef %s */' % decl[1], desc = description)
+ # types
+ for t in types:
+ description = "Define to 1 if you have the `%s' type." % t[0]
+ if conf.CheckType(t[0], includes=t[2]):
+ result[t[1]] = 1
+ cont += configString('#define %s 1' % t[1], desc = description)
+ else:
+ result[t[1]] = 0
+ cont += configString('/* #undef %s */' % t[1], desc = description)
+ # libraries
+ for lib in libs:
+ description = "Define to 1 if you have the `%s' library (-l%s)." % (lib[0], lib[0])
+ if type(lib[0]) is type(''):
+ lib_list = [lib[0]]
+ else:
+ lib_list = lib[0]
+ # check if any of the lib exists
+ result[lib[1]] = 0
+ # if user want the name of the lib detected