[PATCH modular 2/3] build.sh: support CC, CPP, CPPFLAGS and CFLAGS

Dan Nicholson dbn.lists at gmail.com
Fri Dec 3 05:59:41 PST 2010


On Thu, Dec 2, 2010 at 4:52 PM, Gaetan Nadon <memsize at videotron.ca> wrote:
> There is a requirement for some build environment to set CC
> to something other than the Autoconf default.
>
> There is already a variable CONFCFLAGS in place that can handle C flags,
> however it was more a side-effect of adding -g option rather than
> a comprehensive support for C flags.
>
> The user interface for build.sh should closely follow the Autoconf one.
> Rather than inventing new variable names, let's use the ones
> Autoconf uses. The user will not have to learn two interfaces
> and do the mental mapping.
>
> Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
> ---
>  build.sh |   16 +++++++++++++++-
>  1 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/build.sh b/build.sh
> index 89d4266..9bb38f5 100755
> --- a/build.sh
> +++ b/build.sh
> @@ -15,6 +15,13 @@ global environment variables you may set to replace default functionality:
>             (default: git://anongit.freedesktop.org/git)
>
>  global environment variables you may set to augment functionality:
> +  CC          C compiler command
> +  CFLAGS      C compiler flags
> +  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
> +              nonstandard directory <lib dir>
> +  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
> +              you have headers in a nonstandard directory <include dir>
> +  CPP         C preprocessor
>   CONFFLAGS:  additional flags to pass to all configure scripts
>   CONFCFLAGS: additional compile flags to pass to all configure scripts
>   MAKEFLAGS:  additional flags to pass to all make invocations

If we're picking these up from the environment, then why do we need to
pass them to configure?

> @@ -348,7 +355,14 @@ process() {
>     if [ $needs_config -eq 1 ] || [ X"$NOAUTOGEN" = X ]; then
>        sh ${DIR_CONFIG}/${CONFCMD} --prefix=${PREFIX} ${LIB_FLAGS} \
>            ${QUIET:+--quiet} \
> -           ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "$CONFCFLAGS"
> +           ${CACHE:+--cache-file=}${CACHE} \
> +           ${CONFFLAGS} \
> +           ${CC:+CC=}${CC} \
> +           ${CPP:+CPP=}${CPP} \
> +           "${CPPFLAGS:+CPPFLAGS=}${CPPFLAGS}" \
> +           "${CFLAGS:+CFLAGS=}${CFLAGS}" \
> +           "${LDFLAGS:+LDFLAGS=}${LDFLAGS}" \
> +           "$CONFCFLAGS"

Should CC and CPP not be quoted? It's quite common that people want to
run CC="gcc -m32". Also, I'm not sure I understand why the brace
expansion is used like this. Typically people keep the whole
expression inside the braces:

${CFLAGS:+CFLAGS="$CFLAGS"}

The way the quoting is being used now, you'll end up with a bunch of
empty arguments to configure. E.g., if LDFLAGS is empty, the whole
expression will expand to "".

Sorry to ask one more question, but doesn't CFLAGS conflict with CONFCFLAGS?

--
Dan


More information about the xorg-devel mailing list