From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 4 16:26:35 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 638601065672; Tue, 4 Mar 2008 16:26:35 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 1039E8FC21; Tue, 4 Mar 2008 16:26:34 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m24GNbaX071971; Tue, 4 Mar 2008 09:23:37 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 04 Mar 2008 09:24:05 -0700 (MST) Message-Id: <20080304.092405.-491322594.imp@bsdimp.com> To: harti@freebsd.org, hartmut.brandt@dlr.de From: "M. Warner Losh" In-Reply-To: <20080304170934.X893@knop-beagle.kn.op.dlr.de> References: <20080304154542.GC61036@kobe.laptop> <20080304.085245.2040341894.imp@bsdimp.com> <20080304170934.X893@knop-beagle.kn.op.dlr.de> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: keramida@ceid.upatras.gr, hackers@freebsd.org, rwatson@freebsd.org Subject: Re: Comments on pmake diffs for building on Linux X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Mar 2008 16:26:35 -0000 In message: <20080304170934.X893@knop-beagle.kn.op.dlr.de> Harti Brandt writes: : On Tue, 4 Mar 2008, M. Warner Losh wrote: : : MWL>In message: <20080304154542.GC61036@kobe.laptop> : MWL> Giorgos Keramidas writes: : MWL>: On 2008-03-04 15:38, Robert Watson 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 : 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 : 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