[PATCH] configure: Add sanity checking for environment variables

Tomi Ollila tomi.ollila at iki.fi
Wed May 20 01:48:28 PDT 2015


On Wed, May 20 2015, David Bremner <david at tethera.net> wrote:

> Passing in environment variables incompatible with the compiler may
> cause other parts of the configure script to fail in hard to
> understand ways, so we abort early.
> ---
>
> meh, the previous version was borken by lazy evaluation of CXXFLAGS
> using make syntax. Better suggestions for how to do this?

Final try, I promise ;D

>
>  configure | 31 +++++++++++++++++++++++++++++--
>  1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/configure b/configure
> index 4af7ba9..650b976 100755
> --- a/configure
> +++ b/configure
> @@ -269,6 +269,35 @@ dependencies are available:
>  EOF
>  
>  errors=0
> +printf "int main(void){return 0;}\n" > minimal.c
> +
> +printf "Sanity checking C compilation environment... "
> +if ${CC} ${CFLAGS} ${CPPFLAGS}  minimal.c ${LDFLAGS} -o minimal > /dev/null 2>&1

if ${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal > /dev/null 2>&1

> +then
> +    printf "OK.\n"
> +else
> +    printf "Fail.\n"
> +    errors=$((errors + 1))
> +fi

if [ "$CXXFLAGS" = '$(CFLAGS)' ]
then
   CXXFLAGS_for_sh=$CFLAGS
else
   CXXFLAGS_for_sh=$CXXFLAGS
fi

the above is basically safe as if there are slight chages in string
'$(CFLAGS)' the CXXFLAGS_for_sh=$CXXFLAGS applies and if it is borken
then we notice it.

> +
> +printf "Sanity checking C++ compilation environment... "
> +if ${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal > /dev/null 2>&1
> +then
> +    printf "OK.\n"
> +else
> +    printf "Fail.\n"
> +    errors=$((errors + 1))
> +fi

unset CXXFLAGS_for_sh

> +
> +if [ $errors -gt 0 ]; then
> +    cat <<EOF
> +*** Error: Initial sanity checking of environment failed.  Please try
> +running configure in a clean environment, and if the problem persists,
> +report a bug.
> +EOF
> +    rm -f minimal minimal.c
> +    exit 1
> +fi
>  
>  if pkg-config --version > /dev/null 2>&1; then
>      have_pkg_config=1
> @@ -690,8 +719,6 @@ else
>  fi
>  rm -f compat/check_asctime
>  
> -printf "int main(void){return 0;}\n" > minimal.c
> -
>  printf "Checking for rpath support... "
>  if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
>  then
> -- 
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list