From owner-freebsd-questions Tue Oct 2 3:29:12 2001 Delivered-To: freebsd-questions@freebsd.org Received: from arpa.com (arpa.com [199.245.173.5]) by hub.freebsd.org (Postfix) with ESMTP id 9235437B406 for ; Tue, 2 Oct 2001 03:29:07 -0700 (PDT) Received: by arpa.com (Postfix, from userid 1004) id ABA62BBD3; Tue, 2 Oct 2001 06:29:06 -0400 (EDT) Date: Tue, 2 Oct 2001 06:29:06 -0400 From: Chip Norkus To: Wayne Pascoe Cc: freebsd-questions@freebsd.org Subject: Re: autoconf project problem - OS detection / definition Message-ID: <20011002062906.A30146@anduril.org> References: <86snd2wgay.fsf@pan.ehsrealtime.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <86snd2wgay.fsf@pan.ehsrealtime.com>; from wayne.pascoe@ehsrealtime.com on Tue, Oct 02, 2001 at 10:18:45AM +0100 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue Oct 02, 2001; 10:18AM +0100 Wayne Pascoe used 0.8K bytes of bandwidth to send the following: > Hi all, > > I'm trying to convert a project that I have to use autoconf. The main > problem that I am having at the moment is OS detection. I see that I > can use config.guess and that will make the os available as > ${target_os} to my configure scripts. > > My problem is that in my code I have several sections like > > #ifdef HAVE_LINUX > do stuff > . > . > #endif > > #ifdef HAVE_FREEBSD > do other stuff > . > . > #endif > > How do I use the ${target_os} to define the OS in my config.h file ? I > don't need it to be HAVE_FREEBSD or HAVE_LINUX, it just needs to be a > unique def for each OS. > In your configure.in script, add a line: AC_CANONCIAL_HOST then, later, you can do: case "$target_os" in linux*) AC_DEFINE(HAVE_LINUX) ;; freebsd*) AC_DEFINE(HAVE_FREEBSD) ;; ... esac Unless you're support cross compiling (which I bet you're not), you can use "$host_os" as well as "$target_os" The reason for the pattern instead of a straight name (that is 'linux*' instead of 'linux') is that the version number of the system is also supplised. Obviously, if you're using AC_DEFINE, your autoconf config header of choice will need to contain all the necessary entries (that is, for each OS, you'll want to add an '#undef HAVE_HOST') > TIA, > > -- > Wayne Pascoe > > Things fall apart; the center cannot hold; > Mere anarchy is loosed upon the world. - Yeats > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message HTH, -wd -- chip norkus(rl); white_dragon('net'); wd@arpa.com "That's Tron. He fights for the users." http://telekinesis.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message