From owner-freebsd-hackers Wed Oct 27 7:34:50 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from picnic.mat.net (picnic.mat.net [206.246.122.133]) by hub.freebsd.org (Postfix) with ESMTP id D3AB214C92 for ; Wed, 27 Oct 1999 07:34:45 -0700 (PDT) (envelope-from chuckr@picnic.mat.net) Received: from localhost (chuckr@localhost [127.0.0.1]) by picnic.mat.net (8.9.3/8.9.3) with ESMTP id KAA13987; Wed, 27 Oct 1999 10:34:06 -0400 (EDT) (envelope-from chuckr@picnic.mat.net) Date: Wed, 27 Oct 1999 10:34:06 -0400 (EDT) From: Chuck Robey To: Dan Nelson Cc: Roger Hardiman , hackers@FreeBSD.ORG Subject: Re: Is there anything like #ifdef BSD In-Reply-To: <19991027091949.A38799@dan.emsphone.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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