automake
[Top][All Lists]
Advanced

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

Re: Manual Example


From: Ralf Wildenhues
Subject: Re: Manual Example
Date: Fri, 26 May 2006 13:39:04 +0200
User-agent: Mutt/1.5.11

Hi Paulo,

* Paulo J. Matos wrote on Fri, May 26, 2006 at 11:40:31AM CEST:
> 
> AC_ARG_ENABLE(debug,
>     [  --enable-debug    Turn on debugging],
>     [case "${enableval}" in
>       yes) debug=true ;;
>       no)  debug=false ;;
>       *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
>     esac],[debug=false])
>     AM_CONDITIONAL(DEBUG, test x$debug = xtrue)

> - is enableval always defined?

Yes, inside the third argument of AC_ARG_ENABLE.

> It's the value given by the uer for the ARG?

I don't fully understand the question.
If the user passes              then enableval is
   nothing                      (empty)
   --enable-debug               yes
   --disable-debug              no 
   --enable-debug=<some_value>  <some_value>

> - AM_CONDITIONAL has a x$debug and xtrue. What is this? A typo? Shouldn't 
> it be:
>     AM_CONDITIONAL(DEBUG, test "$debug" = "true")

Well.  The two different ways of writing it protect against different
issues: quoting ("$debug") ensures that the expansion of this ends up
being exactly one argument.  Otherwise, without quotes it could end up
being expanded as zero arguments to test, or more than one, both of
which would seriously confuse `test'.  The x before the variable ensures
that the first argument to `test' does not start with a `-'.  The
problem here is that it confuses some older implementations of `test'
(or the shell that possibly implements it as a builtin command), when
$debug happens to be `-z', for example.

FWIW, I'd write the above as follows, with more consistent M4 quoting
(as we've put in the Autoconf manual not too long ago), and with
precautions for both above-mentioned issues.

AC_ARG_ENABLE([debug],
    AS_HELP_STRING([--enable-debug], [Turn on debugging]),
    [case $enableval in
      yes) debug=true ;;
      no)  debug=false ;;
      *) AC_MSG_ERROR([bad value $enableval for --enable-debug]) ;;
    esac], [debug=false])
AM_CONDITIONAL([DEBUG], [test "x$debug" = xtrue])

Hope that helps.

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]