[Top][All Lists]

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

Re: Setting a default value for an AC_ARG_VAR

From: Nick Bowler
Subject: Re: Setting a default value for an AC_ARG_VAR
Date: Fri, 14 Dec 2018 09:51:20 -0500

On 12/14/18, Reuben Thomas <address@hidden> wrote:
> What's the right way to do this? I currently have:
>   [value of WORD_SIZE register [default: sizeof(long)]])
> if "$ac_cv_env_WORD_SIZE_set" != set; then
>   AC_CHECK_SIZEOF([long])
>   ac_cv_env_WORD_SIZE_value=SIZEOF_LONG
> fi
> which seems to work, but I'm conscious that I'm relying on undocumented
> variable names (ac_cv_env_*). I can't seem to get the same effect with, for
> example:
>   [value of WORD_SIZE register [default: sizeof(long)]])
> (the AC_SUBST overrides whatever AC_ARG_VAR does, it seems).

AC_ARG_VAR doesn't actually set the variable to anything.  That's up to
you.  In essence, the only thing it does is[1]:

  - Adds some help text to configure --help,
  - Causes configure to save its _original_ value from the environment,
    so that config.status --recheck can replay that value and work properly,
  - When using a cache, it makes it an error to change the value in the
    environment between configure runs (without cleaning first) because that
    probably invalidates the cached results.
  - It also does AC_SUBST on the variable because why not.

If you want to set a value to a variable only if the variable is
unset, a typical way to do that in shell programming is:

  : "${FOO=value-if-unset}"

Or if you prefer also to set it the variable is _empty_ (i.e., including
the case where it is set to the empty string):

  : "${FOO:=value-if-empty}"



reply via email to

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