Comments on pmake diffs for building on Linux
Giorgos Keramidas
keramida at ceid.upatras.gr
Tue Mar 4 15:47:29 UTC 2008
On 2008-03-04 15:38, Robert Watson <rwatson at freebsd.org> wrote:
> On Tue, 4 Mar 2008, M. Warner Losh wrote:
>
>> : In most ports of FreeBSD parts to Linux that I've seen, the preferred solution
>> : has to been to bring the entire FreeBSD queue.h with you rather than relying
>> : on the native Linux queue.h. This is what we do for OpenBSM, for example;
>> : this also helps out when you get to Mac OS X, Solaris, etc, where all the
>> : queue.h's continue to vary in subtle ways. This depends a fair amount on a
>> : lack of header pollution in the OS's own include files, of course...
>>
>> I was rather hoping for something that could be used without any of that
>> nonsense...
>
> Sadly, nonsense seems to be the name of the game in software portability.
> Here's the broken autoconf garbage I use to pick out adequate queue.h's
> from inadequate ones:
>
> # sys/queue.h exists on most systems, but its capabilities vary a great deal.
> # test for LIST_FIRST and TAILQ_FOREACH_SAFE, which appears to not exist in
> # all of them, and are necessary for OpenBSM.
> AC_TRY_LINK([
> #include <sys/queue.h>
> ], [
>
> #ifndef LIST_FIRST
> #error LIST_FIRST missing
> #endif
> #ifndef TAILQ_FOREACH_SAFE
> #error TAILQ_FOREACH_SAFE
> #endif
> ], [
> AC_DEFINE(HAVE_FULL_QUEUE_H,, Define if queue.h includes LIST_FIRST)
> ])
>
> Note that there are at least a couple of mostly stylistic bugs there (could
> use compile rather than link, definition description is poor, errors are
> inconsistent). :-) I found that on both Linux and Mac OS X, the queue.h's
> didn't have everything I wanted.
Nice! Thank you Robert. Can I copy parts of this and add them to the
autoconf glue I'm adding now?
To test just cpp(1) stuff, autoconf supports AC_PREPROC_IFELSE() too,
which I used when I tried writing a check for __FBSDID():
AC_PREPROC_IFELSE(
[AC_LANG_PROGRAM([[#include <sys/cdefs.h>
#ifndef __FBSDID
#error No __FBSDID definition.
#endif]])],
[AC_DEFINE([HAVE_FBSDID_MACRO], [1],
[Define to 1 if you have the __FBSDID macro.])])
I can probably improve a bit the queue.h check using what you wrote
above and AC_PREPROC_IFELSE().
More information about the freebsd-hackers
mailing list