Re: weird AC_REQUIRE expansion issue

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

 



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


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux