Comments on pkgsrc and DragonFly

Stephane Russell srussell at prodigeinfo.com
Fri Jan 7 20:39:54 PST 2011


Hi, thanks for your reply, which I read carefully.

>> - "BSD" is undefined in DragonFly, this isn't working:
>> #if (defined(BSD) && BSD >= 199306)
> 
> Never saw this one.
>
> All tests I encountered in third-party software were looking for full OS
> names or OS-specific defines like "__FreeBSD__" or "irix"
>

I think it was defined originally in BSD4.4 Lite. I contacted the NetBSD
pkgsrc's team to get some informations on common BSD defines. They
pointed me here:

«To distinguish between 4.4 BSD-derived systems and the rest of the
world, you should use the following code.

#include <sys/param.h>
#if (defined(BSD) && BSD >= 199306)
/* BSD-specific code goes here */
#else
/* non-BSD-specific code goes here */
#endif

If this distinction is not fine enough, you can also test for the
following macros.

FreeBSD     __FreeBSD__
DragonFly   __DragonFly__
Interix     __INTERIX
IRIX        __sgi (TODO: get a definite source for this)
Linux       linux, __linux, __linux__
NetBSD      __NetBSD__
OpenBSD     __OpenBSD__
Solaris     sun, __sun»

Ref: http://www.netbsd.org/docs/pkgsrc/fixes.html#fixes.build.cpp

Logically, I think that if a system is not defining "BSD", than it's
simply not a BSD, it's a BSD fork at most.

> These are a pain, but I don't think they are so pervasive; Darwin is
> also considered as a BSD system and has the same problem here.
> In all cases I've seen, it was fixed with a new test checking for the
> full OS name:
> 
>     case ${OSARCH} in
>     *BSD)
>         blah
>   + Darwin)
>   +     blah
> 

Yes, not that a problem, but some common tag would useful here too, when
possible. Also, like you say, Darwin is considered a BSD, but this
doesn't say much. It tells that BSD like code "might" compile. NetBSD's
pkgsrc, FreeBSD's popularity and Linux's widespread innovations, might
be the only things keeping some similarities between the BSD forks.

> Kde4 packages are also troublesome; if I remember correctly, they consider
> DragonFly as FreeBSD and fail at some stage during the compilation.

This is not a small problem with BSD forks. Large GUI applications like
KDE gets trully functionnal only if enough people are available to work
on it. Some "defaults" can be chosen (ex: KDE over Gnome like they did
with DragonFly) to overcome this partly. But on the end, there's always
some fonctionnalities not working fully or periodical crashes happening.
FreeBSD is performing better here, but it comes in one «like it or not»
variant, so their work can't be shared, sadly. And I don't think that
Apple's work on Darwin is of any benefit for the BSD world. So at most,
BSD forks can only be used seriously as strong servers. That's how I'm
using dfly.

> In other cases, adding an abstraction function such as isLinuxOrBSD may
> help replace a bunch of #defines.
> 

Yes, I never thought of using one define including them all. Also, a
"isBSD" alone would group BSD defines in the same way. That's what the
"BSD" define could have been useful at. Even if it would be for simple
stuff like using bcopy instead of strcpy, and other obvious BSD behaviors.

SR





More information about the Users mailing list