Date: Tue, 2 Oct 2001 06:29:06 -0400 From: Chip Norkus <wd@arpa.com> To: Wayne Pascoe <wayne.pascoe@ehsrealtime.com> Cc: freebsd-questions@freebsd.org Subject: Re: autoconf project problem - OS detection / definition Message-ID: <20011002062906.A30146@anduril.org> In-Reply-To: <86snd2wgay.fsf@pan.ehsrealtime.com>; from wayne.pascoe@ehsrealtime.com on Tue, Oct 02, 2001 at 10:18:45AM %2B0100 References: <86snd2wgay.fsf@pan.ehsrealtime.com>
index | next in thread | previous in thread | raw e-mail
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 <wayne.pascoe@ehsrealtime.com>
>
> 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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011002062906.A30146>
