autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to test if preprocessor defines foobar in macro?


From: Ralf Wildenhues
Subject: Re: How to test if preprocessor defines foobar in macro?
Date: Wed, 14 Oct 2009 06:55:54 +0200
User-agent: Mutt/1.5.20 (2009-08-09)

* Dr. David Kirkby wrote on Wed, Oct 14, 2009 at 06:36:36AM CEST:
> http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_count_cpus.m4

This macro does not look well-designed.  It does the wrong thing when
cross-compiling, or even only compiling for a different system (which
happens to be use the same architecture).

A better approach would be to provide the user with a switch, or prefer
a user override of CPU_COUNT.  If that switch/variable was not used, and
cross compilation is not enabled, then one can try to use the $build
system features; but even then you should be cautious about the result.

> which attempt to get the number of CPUs in a system. I'd like to
> extend it to cover Solaris, AIX and HP-UX.

How do you find out this information on those systems?

> It seems sensible to me to only do a test on a platform it will work
> on, so I think thinking of something like
> 
> if `uname` = "HP-UX"
>   write test for HP-UX
> fi

uname gives you $build system info.  AC_CANONICAL_HOST sets $host which
helps better, and gives fairly uniform info.  See config.guess for a
number of strings to match.

> There's another macro I've seen used for determine cache sizes of
> processors.
> 
> http://www.nongnu.org/autoconf-archive/ax_cache_size.html

This has similar problems.

> which depends on the CPU being an x86 one,

Not only that.  IIUC it also depends on running on non-ancient Linux
only.

> which it will often not
> be. I don't fancy the task of trying to work out cache sizes for
> every processor used on machines running Solaris, AIX or HP-UX, so
> will try to modify that so it returns a sensible guess (say 1 MB) on
> processors it does not know about. The test is causing a script to
> crash on HP-UX.

HTH.

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]