Comments on pmake diffs for building on Linux
M. Warner Losh
imp at bsdimp.com
Tue Mar 4 14:52:04 UTC 2008
In message: <20080304083038.GB90914 at kobe.laptop>
Giorgos Keramidas <keramida at ceid.upatras.gr> writes:
: On 2008-03-03 22:42, "M. Warner Losh" <imp at bsdimp.com> wrote:
: > Greetings,
: >
: > here's a set of diffs that will allow FreeBSD's usr.bin/make to build
: > on Linux. I'm sure they are gross, and I don't plan to commit them
: > (at least not all of them), but I thought I'd post them here to see
: > what people think.
: >
: > I think that the extra config.h includes, the errc -> errx patches and
: > the Makefile.dist patches may be good for the tree. The rest may not
: > meet FreeBSD's source tree policies.
: >
: > Comments?
: >
: > Warner
: >
: > diff -ur pmake.orig/config.h pmake/config.h
: > --- pmake.orig/config.h 2005-02-01 03:50:35.000000000 -0700
: > +++ pmake/config.h 2008-03-03 22:24:16.745493000 -0700
: > @@ -108,4 +108,27 @@
: > # endif
: > #endif
: >
: > +#ifndef TAILQ_HEAD_INITIALIZER
: > +#define TAILQ_HEAD_INITIALIZER(head) { NULL, &(head).tqh_first }
: > +#endif
: > +
: > +#ifndef TAILQ_FOREACH
: > +#define TAILQ_FOREACH(var, head, field) \
: > + for ((var) = TAILQ_FIRST((head)); \
: > + (var); \
: > + (var) = TAILQ_NEXT((var), field))
: > +#endif
: > +
: > +#ifndef TAILQ_FIRST
: > +#define TAILQ_FIRST(head) ((head)->tqh_first)
: > +#endif
: > +
: > +#ifndef TAILQ_NEXT
: > +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
: > +#endif
: > +
: > +#ifndef TAILQ_EMPTY
: > +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
: > +#endif
: > +
: > #endif /* config_h_efe0765e */
:
: In a Solaris-based project I'm involved with, I used our own "queue.h"
: pretty much verbatim. Only STAILQ_LAST() seems to use __offsetof(),
: which may be a bit tricky to 'port over'.
:
: That's not to say that I don't like the above change, but I am just
: `thinking aloud' about the possibility of importing sys/queue.h into
: `http://hg.hellug.gr/bmake' to avoid the need for the #ifdef trick.
:
: The TAILQ_*() macros are pretty simple, so it's fairly easy to copy them
: verbatim. In the long run, they may get `stale' though, so a full
: import of sys/queue.h looks like a `safe' thing. It also stands a
: chance of working on Solaris, which doesn't have a sys/queue.h header
: at all.
Yea. I'm not sure the right way to cope with systems that have
sys/queue.h, but have one that isn't sufficient for our needs. I'll
fully admit that the above is a hack.
Maybe there needs to be an autoconfig-like step...
: > --- pmake.orig/main.c 2007-12-18 15:58:14.000000000 -0700
: > +++ pmake/main.c 2008-03-03 22:25:47.543349000 -0700
: > @@ -660,11 +664,9 @@
: > int level = (value == NULL) ? 0 : atoi(value);
: >
: > if (level < 0) {
: > - errc(2, EAGAIN, "Invalid value for recursion level (%d).",
: > - level);
: > + errx(2, "Invalid value for recursion level (%d).", level);
: > } else if (level > MKLVL_MAXVAL) {
: > - errc(2, EAGAIN, "Max recursion level (%d) exceeded.",
: > - MKLVL_MAXVAL);
: > + errx(2, "Max recursion level (%d) exceeded.", MKLVL_MAXVAL);
: > } else {
: > char new_value[32];
: > sprintf(new_value, "%d", level + 1);
:
: Hohoho! I didn't realize errx() was already available on Linux. Last
: night, when I ran `man errx' there was no manpage, but I forgot that
: glibc prefers Info manuals :)
Yea. I don't even know why we do a errc, which is fairly recent bsd
invention.
Warner
More information about the freebsd-hackers
mailing list