NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NetBSD macros



At Mon, 14 Dec 2009 17:38:44 +0000, Sad Clouds 
<cryintothebluesky%googlemail.com@localhost> wrote:
Subject: Re: NetBSD macros
> 
> On Monday 14 December 2009 16:55:33 Jonathan Schleifer wrote:
> 
> > System identifiers are NEVER a good way to control compiler-time
> > configuration, _NEVER_! You want to know features, _NOT_ operating
> > systems! The features can and _WILL_ change over time! Just doing
> > #ifdef __NetBSD__ will horribly fail, as features were removed over
> > time and others added. And once a new release comes out, you have to
> > update your code. Good luck updating your code whenever there's a new
> > release of any OS in the world that changes some feature!

I wasn't referring to __NetBSD__ alone -- I would include
<sys/param.h>'s __NetBSD_Version__ as well of course.

Neither should be used blindly either of course -- it's horrid to see
long trails of "#if defined(__NetBSD__) || defined(__FreeBSD__) ||
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__Darwin__)"
(with the only missing one being __Linux__ or whatever!)

None the less there are places where both __NetBSD_Version__ and
__NetBSD__ can be used effectively.


> I haven't used autoconf that much. I remember years ago I looked into and I 
> found it too complex and time consuming to understand. I know a lot of people 
> complain about autoconf for similar reasons. At the end of the day nobody 
> wants to spend a lot of time learning m4 and trying to figure out why 
> autoconf 
> does this, but fails to do that, etc.

I have looked into Autoconf (and Automake, and libtool) in great detail
and I have used them on a number of projects, as well as having
maintained and ported many more projects (hundreds!) which they use.
(I've also worked in great detail with Imake and Imake-using projects,
and I've worked extensively with some proprietary build-time
configuration systems as well.)

Autoconf _is_ far too complex and far too time consuming in all respects.

Sadly even NetBSD's pkgsrc doesn't make truly ideal use of Autoconf, and
in part it doesn't do so because Autconf users are not disciplined
enough overall to allow for such ideal use.  I.e. there's no system-wide
cache file being used to avoid having to run zillions of identical tests
over and over again with the build of each Autoconf-using pkgsrc module.
And this is just one example of how lame most use of autoconf has become
over the years.


> It's probably simpler just to look at operating system name and version 
> number 
> and use #ifdef. There will be some differences, but the major APIs don't 
> chance that much.

Indeed.

These days even if you're writing X11 applications (i.e. rather than
just plain POSIX command-line style programs) and hoping only to support
the most widely used platforms there's no need to use either Autoconf or
Imake.  Such code can be written in a portable way without even having
to resort to very many #ifdef's at all.

The problem of course with doing so is that few programmers have the
depth of experience of writing and maintaining code on all their target
platforms, as well has having a good understanding of historical
portability issues across all of unix-land.

-- 
                                                Greg A. Woods
                                                Planix, Inc.

<woods%planix.com@localhost>       +1 416 218 0099        http://www.planix.com/

Attachment: pgppepm4ZXpTv.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index