'Determine if function \'func\' is available by constructing a
source file that refers to \'func\', and compiles and links it.
If everything succeeds, returns true; otherwise returns false.
The constructed source file starts out by including the header
files listed in \'headers\'.  If \'decl\' is true, it then declares
\'func\' (as "int func()"); you probably shouldn\'t supply \'headers\'
and set \'decl\' true in the same call, or you might get errors about
a conflicting declarations for \'func\'.  Finally, the constructed
\'main()\' function either references \'func\' or (if \'call\' is true)
calls it.  \'libraries\' and \'library_dirs\' are used when
linking.'

def check_func(self, func, headers=None, include_dirs=None, libraries=None, library_dirs=None, decl=0, call=0):

    self._check_compiler()
    body = []
    if decl:
        body.append(('int    %s    ();' % func))
    body.append('int    main    ()    {')
    if call:
        body.append(('        %s();' % func))
    else:
        body.append(('        %s;' % func))
    body.append('}')
    body = ('\n'.join(body) + '\n')
    return self.try_link(body, headers, include_dirs, libraries, library_dirs)
