|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
How to test if preprocessor defines foobar in macro?I'm trying to modify this macro
http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_count_cpus.m4 which attempt to get the number of CPUs in a system. I'd like to extend it to cover Solaris, AIX and HP-UX. 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 or I could check if __hpux__ is defined or not. Can anyone show me how to modify the above autoconf macro to do the test using either uname, a macro that the pre-processor defines, or other that allows me to execute a bit of code on only one platform. method. There's another macro I've seen used for determine cache sizes of processors. http://www.nongnu.org/autoconf-archive/ax_cache_size.html which depends on the CPU being an x86 one, 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. Dave _______________________________________________ Autoconf mailing list Autoconf@... http://lists.gnu.org/mailman/listinfo/autoconf |
|
|
Re: How to test if preprocessor defines foobar in macro?* 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 _______________________________________________ Autoconf mailing list Autoconf@... http://lists.gnu.org/mailman/listinfo/autoconf |
|
|
Re: How to test if preprocessor defines foobar in macro?On Wed, Oct 14, 2009 at 05:36:36AM +0100, Dr. David Kirkby wrote:
> I'm trying to modify this macro > > http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_count_cpus.m4 > > which attempt to get the number of CPUs in a system. I'd like to extend > it to cover Solaris, AIX and HP-UX. > > 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 > > or I could check if __hpux__ is defined or not. generally omit explicit assumptions about the right test for a certain system type. Instead, try each test unconditionally and use the first one that works. The code you reference currently does this. Consider checking processor count and cache characteristics at runtime. If a OS distribution ships binaries of your software, they will run on a wide range of processor configurations. You might need `configure'-time checks to verify the availability of the APIs you would use at runtime. _______________________________________________ Autoconf mailing list Autoconf@... http://lists.gnu.org/mailman/listinfo/autoconf |
|
|
Re: How to test if preprocessor defines foobar in macro?On Wednesday 14 October 2009 00:36:36 Dr. David Kirkby wrote:
> I'm trying to modify this macro > > http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m > 4/ax_count_cpus.m4 > > which attempt to get the number of CPUs in a system. I'd like to extend > it to cover Solaris, AIX and HP-UX. there are so many reasons why this is wrong (some of which people have pointed out). you havent really said why you want this information, but presumably it isnt for usage in the configure script (since that's about the only place this info would be valid). if it's being passed to source code, you should be querying the proc count at runtime with sysconf(_SC_NPROCESSORS_CONF). if your system isnt POSIX complaint, then usually it provides some other way of getting this info. -mike _______________________________________________ Autoconf mailing list Autoconf@... http://lists.gnu.org/mailman/listinfo/autoconf |
| Free embeddable forum powered by Nabble | Forum Help |