From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 4 16:25:52 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 E25591065679 for ; Tue, 4 Mar 2008 16:25:52 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) Received: from smtp-1.dlr.de (smtp-1.dlr.de [195.37.61.185]) by mx1.freebsd.org (Postfix) with ESMTP id 76D388FC14 for ; Tue, 4 Mar 2008 16:25:52 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) Received: from knop-beagle.kn.op.dlr.de ([129.247.173.6]) by smtp-1.dlr.de over TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); Tue, 4 Mar 2008 17:12:32 +0100 Date: Tue, 4 Mar 2008 17:12:34 +0100 (CET) From: Harti Brandt X-X-Sender: brandt_h@knop-beagle.kn.op.dlr.de To: "M. Warner Losh" In-Reply-To: <20080304.085245.2040341894.imp@bsdimp.com> Message-ID: <20080304170934.X893@knop-beagle.kn.op.dlr.de> References: <20080304.083350.1661915009.imp@bsdimp.com> <20080304153651.I41184@fledge.watson.org> <20080304154542.GC61036@kobe.laptop> <20080304.085245.2040341894.imp@bsdimp.com> X-OpenPGP-Key: harti@freebsd.org MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 04 Mar 2008 16:12:32.0886 (UTC) FILETIME=[8D84C960:01C87E12] 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 Reply-To: Harti Brandt 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:25:53 -0000 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. harti