[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: weird AC_REQUIRE expansion issue
From: |
Stepan Kasal |
Subject: |
Re: weird AC_REQUIRE expansion issue |
Date: |
Mon, 29 Aug 2005 18:42:14 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello Ralf,
> AC_DEFUN([CX_COMPILER_CHECKS],
> [CX_STATUS([compiler checks])
> AC_PROG_CC
> AM_PROG_CC_C_O
> ...
> ])
Well, my previous answer was not accurate. The above code should expand
AC_PROG_CC between CX_STATUS and AM_PROG_CC_C_O, so it should work.
But as soon as CX_COMPILER_CHECKS is expanded inside another AC_DEFUNed
macro, there will be a danger that AC_PROG_CC will be skipped here,
and some later macro, which AC_REQUIREd AC_PROG_CC will complain.
So it's safer to AC_REQUIRE AC_PROG_CC, either directly, or indirectly
via AM_PROG_CC_C_O.
But we have to make sure that CX_STATUS([compiler checks]) is expanded
before AC_PROG_CC.
Short answer:
I think the following should work:
AC_DEFUN([CX_COMPILER_CHECKS],
[AC_REQUIRE([CX_STATUS([compiler checks])])
AM_PROG_CC_C_O
...
])
Long answer:
> where I can't AC_REQUIRE([CX_STATUS]), because that is supposed to be
> used several times, obviously, [...]
But you can create a special copy for the purpose of being required by
CX_COMPILER_CHECKS:
AC_DEFUN([_CX_STATUS_FOR_CX_COMPILER_CHECKS],
[CX_STATUS([compiler checks])])
AC_DEFUN([CX_COMPILER_CHECKS],
[AC_REQUIRE([_CX_STATUS_FOR_CX_COMPILER_CHECKS])
AM_PROG_CC_C_O
...
But AC_REQUIRE supports 2 parameters, so you don't have to actually define
the macro, just use the string as a tag:
AC_DEFUN([CX_COMPILER_CHECKS],
[AC_REQUIRE([_CX_STATUS_FOR_CX_COMPILER_CHECKS],
[CX_STATUS([compiler checks])])
AM_PROG_CC_C_O
...
But unless there is a danger that the macro is AC_REQUIREd somewhere else
with the same parameters, you can use the string
"CX_STATUS([compiler checks])"
as the tag.
[Excercice for the reader: modify the above example.]
But when the two parameters for AC_REQUIRE are identical, you can omit
the second one. And this yields the result mentioned in the "Short answer"
above.
HTH,
Stepan Kasal