how to check for HAVE_FOO_PROTO ?
David Faure
faure at kde.org
Sun Jan 15 20:07:18 CET 2006
On Sunday 15 January 2006 14:39, Alexander Neundorf wrote:
> On Sunday 15 January 2006 01:33, David Faure wrote:
> > On Saturday 14 January 2006 17:25, Alexander Neundorf wrote:
> > > Hi,
> > >
> > > in kdelibs/ there are configure checks for really a lot of stuff.
> > > What does HAVE_FOO_PROTO mean ? (with FOO = GETHOSTNAME, INITGROUPS,
> > > MKDTEMP, MKSTEMP, RANDOM and others)
> > > How should be tested for it ?
> > >
> > > cmake has a check_function_exists(), which tries to compile and link a
> > > small executable calling this function. But what should be done for
> > > HAVE_FOO_PROTO ?
> >
> > This is about the functions that libkdefakes can provide if the system
> > doesn't. If the system doesn't have it, there are still 2 cases : it has
> > the prototype in a system header or it doesn't. If it doesn't, then a file
> > like config.h must provide it, hence the HAVE_FOO_PROTO check in the m4
> > implementation (which is used by the ifdefs in config.h.bot)
> > But if you prefer, read my bksys implementation of those checks in
> > bksys/kdefakes.py As you can see there, there is no need for the _PROTO
> > intermediary if the configure check directly writes out the prototype to
> > the config-kdefakes.h file when it's needed.
>
> ret = context.TryLink(code, '.cpp')
> if ret:
> import string
> dest.write("#define HAVE_%s 1\n" % (string.upper(function_name)))
> context.Result(ret)
> else:
> context.Result('ok - in libkdefakes')
> dest.write("""
> #ifdef __cplusplus
> extern "C" {
> #endif
> %(prototype)s;
> #ifdef __cplusplus
> }
> #endif
>
> Doesn't this mean the declaration is written to config.h if the test
> application didn't link, but no matter whether the header actually contained
> the prototype or not ?
Ah yeah, silly me. I describe the original intent of the acinclude.m4.in implementation,
but when I implemented the bksys one I found out that it wasn't really necessary
to do so.... Hmm. Well, maybe it is. It looks like a workaround for a broken system
though [why would a system have a prototype for a function it doesn't provide],
so I think I wanted to try the clean way first and add the proto check only if necessary.
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the Kde-buildsystem
mailing list