On 12/21/2010 07:16 AM, Olaf Lenz wrote: > I have attached my simplified attempt do this. When I run autoconf, I > get the warning > > configure.ac:4: warning: AC_REQUIRE: `AC_PROG_CC' was expanded before > it was required > > and configure doesn't seem to be looking for mpicc, but always finds gcc > first. > The problem seems to be that AC_PROG_CC doesn't work when using it in a > conditional, is that right? Is there any simple way to do what I want? The problem is that the autoconf AC_REQUIRE machinery can only be used to require a macro with default arguments. When you invoke AC_PROG_CC inside AS_IF, the AS_IF ends up hoisting the AC_PROG_CC body to occur early, but in the process, loses the arguments that you specified. Whether this can be fixed in future autoconf is another matter, but in general, AC_PROG_CC is special enough that if you ever want to pass non-default arguments, you must invoke it outside of conditionals. > After some trial and error I have found a solution for my problem that > is very simple. Now I wonder whether this is actually the correct way to > do it, or are there some hidden pitfalls? > > AC_ARG_WITH(mpi,,, [with_mpi=guess]) > if test x"$with_mpi" != xno; then > COMPILERS="mpicc hcc mpxlc_r mpxlc mpcc cmpicc gcc cc" > else > COMPILERS="gcc cc" > fi > AC_PROG_CC($COMPILERS) Yes, this is actually a quite decent solution, although you may be artificially limiting the set of $COMPILERS to something less than what AC_PROG_CC() would support by default. -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf