|
From: | Paolo Bonzini |
Subject: | Re: "The `-a', `-o', `(', and `)' operands are not portable": please clarify |
Date: | Wed, 12 Aug 2009 12:12:43 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Lightning/1.0pre Thunderbird/3.0b2 |
On 08/12/2009 02:37 AM, Reuben Thomas wrote:
2009/8/7 Paolo Bonzini<address@hidden>:AS_INIT ensures that you can define shell functions normally using foo () { # body } Alternatively, there is AS_REQUIRE_SHELL_FN that provides a way to define shell functions from within a m4 macro,So when should one use AS_INIT, and when should one prefer AS_REQUIRE _SHELL_FN?
It's different things.AS_INIT initializes m4sh, including ensuring that the current shell supports functions. After that you can define shell functions with the normal syntax.
If you write a m4sh script, you can then define shell functions normally using shell syntax. Even if write a library like Autotest, shell functions that are always needed can be defined normally using shell syntax.
AS_REQUIRE_SHELL_FN is a separate thing. It provides a convenience for defining a shell function, and will expand the function definition just once. Also, the function definition will be placed early in the file, just after the initialization code.
AS_REQUIRE_SHELL_FN is useful if you do not know in advance which functions will be needed, or what code they will expand to.
For example, AC_CHECK_FUNC does two things: 1) it uses AS_REQUIRE_SHELL_FN to generate a shell function with the test code, and 2) it produces a call to the function. The call ends up where AC_CHECK_FUNC was in the configure.ac file, while the shell function is placed early in the configure script.
AC_CHECK_FUNC uses AS_REQUIRE_SHELL_FN because Autoconf scripts may not all need the check-function test code, and because the body of the function is not known, say, when AC_INIT is executed (because it depends on the language being tested).
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |