Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 1999 10:34:06 -0400 (EDT)
From:      Chuck Robey <chuckr@picnic.mat.net>
To:        Dan Nelson <dnelson@emsphone.com>
Cc:        Roger Hardiman <roger@cs.strath.ac.uk>, hackers@FreeBSD.ORG
Subject:   Re: Is there anything like #ifdef BSD
Message-ID:  <Pine.BSF.4.10.9910271029030.29073-100000@picnic.mat.net>
In-Reply-To: <19991027091949.A38799@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 27 Oct 1999, Dan Nelson wrote:

> In the last episode (Oct 27), Roger Hardiman said:
> > I'm working with someone porting linux code to FreeBSD. Actually,
> > they want to port it to all BSDs.
> > 
> > So, rather than having
> > #if defined (FreeBSD) || defined (NetBSD)
> >     || defined (OpenBSD || defined (bsdi)
> > 
> > I am looking for a
> > #if defined (BSD)
> > or #ifdef BSD
> 
> Do you know that the code you will be putting inside this #ifdef is
> BSD-only code (and won't be used by OSF/1, HP-UX, Solaris, etc), or
> should you rather be using autoconf and checking for specific functions
> (setproctitle() as an example)?

What make are you using?  If it's either a BSD make or a GNU make, then
it's smart enough to be able to conditionally set a variable, if a file
exists.  Look for sys/param.h, and include it if it's there.  It has
inside it, for all BSD's, the lines:

#define BSD     199506          /* System version (year & month). */
#define BSD4_3  1
#define BSD4_4  1
#undef __FreeBSD_version
#define __FreeBSD_version 400011        /* Master, propagated to newvers
*/

The above is from a FreeBSD-current system, but probably, you'd not want
to use the __FreeBSD_version.  Use the BSD4_3 or BSD4_4, depending on what
you're doing.

What I'd do is detect the existence of sys/param.h and use it to set
HAS_SYS_PARAM_H to 1, and then use that in your files to include
sys/param.h.  In the sensitive sections of code, condition them against,
say, BSD4_4.

> 
> 

----------------------------------------------------------------------------
Chuck Robey                | Interests include C programming, Electronics,
213 Lakeside Dr. Apt. T-1  | communications, and signal processing.
Greenbelt, MD 20770        | I run picnic.mat.net: FreeBSD-current(i386) and
(301) 220-2114             |       jaunt.mat.net : FreeBSD-current(Alpha)
----------------------------------------------------------------------------



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9910271029030.29073-100000>