Comments on pmake diffs for building on Linux
M. Warner Losh
imp at bsdimp.com
Tue Mar 4 16:26:35 UTC 2008
In message: <20080304170934.X893 at knop-beagle.kn.op.dlr.de>
Harti Brandt <hartmut.brandt at dlr.de> writes:
: On Tue, 4 Mar 2008, M. Warner Losh wrote:
:
: MWL>In message: <20080304154542.GC61036 at kobe.laptop>
: MWL> Giorgos Keramidas <keramida at ceid.upatras.gr> writes:
: MWL>: On 2008-03-04 15:38, Robert Watson <rwatson at freebsd.org> wrote:
: MWL>: > On Tue, 4 Mar 2008, M. Warner Losh wrote:
: MWL>: >
: MWL>: >> : In most ports of FreeBSD parts to Linux that I've seen, the preferred solution
: MWL>: >> : has to been to bring the entire FreeBSD queue.h with you rather than relying
: MWL>: >> : on the native Linux queue.h. This is what we do for OpenBSM, for example;
: MWL>: >> : this also helps out when you get to Mac OS X, Solaris, etc, where all the
: MWL>: >> : queue.h's continue to vary in subtle ways. This depends a fair amount on a
: MWL>: >> : lack of header pollution in the OS's own include files, of course...
: MWL>: >>
: MWL>: >> I was rather hoping for something that could be used without any of that
: MWL>: >> nonsense...
: MWL>: >
: MWL>: > Sadly, nonsense seems to be the name of the game in software portability.
: MWL>: > Here's the broken autoconf garbage I use to pick out adequate queue.h's
: MWL>: > from inadequate ones:
: MWL>: >
: MWL>: > # sys/queue.h exists on most systems, but its capabilities vary a great deal.
: MWL>: > # test for LIST_FIRST and TAILQ_FOREACH_SAFE, which appears to not exist in
: MWL>: > # all of them, and are necessary for OpenBSM.
: MWL>: > AC_TRY_LINK([
: MWL>: > #include <sys/queue.h>
: MWL>: > ], [
: MWL>: >
: MWL>: > #ifndef LIST_FIRST
: MWL>: > #error LIST_FIRST missing
: MWL>: > #endif
: MWL>: > #ifndef TAILQ_FOREACH_SAFE
: MWL>: > #error TAILQ_FOREACH_SAFE
: MWL>: > #endif
: MWL>: > ], [
: MWL>: > AC_DEFINE(HAVE_FULL_QUEUE_H,, Define if queue.h includes LIST_FIRST)
: MWL>: > ])
: MWL>: >
: MWL>: > Note that there are at least a couple of mostly stylistic bugs there (could
: MWL>: > use compile rather than link, definition description is poor, errors are
: MWL>: > inconsistent). :-) I found that on both Linux and Mac OS X, the queue.h's
: MWL>: > didn't have everything I wanted.
: MWL>:
: MWL>: Nice! Thank you Robert. Can I copy parts of this and add them to the
: MWL>: autoconf glue I'm adding now?
: MWL>:
: MWL>: To test just cpp(1) stuff, autoconf supports AC_PREPROC_IFELSE() too,
: MWL>: which I used when I tried writing a check for __FBSDID():
: MWL>:
: MWL>: AC_PREPROC_IFELSE(
: MWL>: [AC_LANG_PROGRAM([[#include <sys/cdefs.h>
: MWL>: #ifndef __FBSDID
: MWL>: #error No __FBSDID definition.
: MWL>: #endif]])],
: MWL>: [AC_DEFINE([HAVE_FBSDID_MACRO], [1],
: MWL>: [Define to 1 if you have the __FBSDID macro.])])
: MWL>:
: MWL>: I can probably improve a bit the queue.h check using what you wrote
: MWL>: above and AC_PREPROC_IFELSE().
: MWL>
: MWL>The alternative to uglifying the make sources with #ifdefs would be to
: MWL>just always use the compat includes when building... No autoconf
: MWL>needed, and minimal changes to the base make, if any.
:
: Yes, please, please don't put #ifdefs into make. It took months to get rid
: of the cruft that was there and to make it at least somewhat readable. A
: single compat.h or whatever header file plus, maybe a compat.c file should
: be sufficient. They can, of course, contain ifdefs. Just include compat.h
: in all make's c-files.
So far I've seen a need only for one ifdef for the pc98 hack. The
rest can be papered over with compat files.
Warner
More information about the freebsd-hackers
mailing list