[Flac-dev] detecting host machine in configure.in?

Matt Zimmerman mdz at debian.org
Tue May 22 19:52:59 PDT 2001


On Tue, May 22, 2001 at 05:15:36PM -0700, Josh Coalson wrote:

> I am trying to set up a flexible infrastructure for the assembly
> code.  Basically what I want is configure.in determination of
> basic machine type (intel/compatible, alpha, ppc), then within
> that (say intel) the code will detect variants like MMX, SSE,
> and use the right routines.
> 
> I know how to do the second, but what is a good way to do the first?
> Linux/Cygwin/Solaris seem to support the MACHTYPE environment variable.
> Is uname -m or uname -p more reliable?  Is there a simple way than
> knowing all the uname -m variants that mean intel 386 compatible?
> (i386, i586, i686, athlon?  etc).

The best way to do this is to let autoconf work its magic for you.  Use
AC_CANONICAL_TARGET in configure.in, and it will place canonical system type
for the target in the shell variable 'target' in the form
CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM.  Be sure to use the target, not
the host, to allow cross-compiling.  It will also be broken out into
target_cpu, target_vendor and target_os.  So you can use $target_cpu for your
tests.  A simple:

case $target_cpu in
  i*86) blahblah ;;
  powerpc) blahblah ;;
  sparc) blahblah ;;
esac

should do the trick.  If you'd rather do the computation in the makefile, you
can just AC_SUBST these in (automake might do this automagically; I'm not
sure).

For example, on this system, it's 'i686-pc-linux-gnu'.  On a Solaris system I
happened to check, it's 'sparc-sun-solaris2.8' (where kernel and operating
system give the same information, the latter is omitted).  This is computed by
the shell script config.guess, if you want to play around with it.  It has
evolved over the years to recognize many, many systems.

Athlon, AFAIK, is an i686.

-- 
 - mdz





More information about the Flac-dev mailing list