Subject: Re: [RFC] iproute: Support cross-compiling.

From: Pádraig Brady <[email-masked]>
Date: Wed, 16 Nov 2011 10:53:11 +0000

On 11/16/2011 01:04 AM, [email-masked] wrote:
> From: Ben Greear <[email-masked]>
> 
> This lets users use their own compiler instead of
> hard-coding to use gcc.
> 
> Also adds tests to disable some things that were not supported
> in my ARM cross-compile toolchain.
> 
> Signed-off-by: Ben Greear <[email-masked]>
> ---
> :100644 100644 c6e4943... 3b00076... M	Makefile
> :100755 100755 f5c3d40... 680fdcb... M	configure
> :100644 100644 8d03993... 5c91e18... M	ip/Makefile
> :100644 100644 e41a598... 773f7cb... M	ip/ipnetns.c
> :100644 100644 8c25381... d04358d... M	misc/Makefile
>  Makefile      |    2 +-
>  configure     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
>  ip/Makefile   |    8 +++++
>  ip/ipnetns.c  |   17 +++++++++++
>  misc/Makefile |    5 +++
>  5 files changed, 114 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c6e4943..3b00076 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -27,7 +27,7 @@ ADDLIB+=dnet_ntop.o dnet_pton.o
>  #options for ipx
>  ADDLIB+=ipx_ntop.o ipx_pton.o
>  
> -CC = gcc
> +CC ?= gcc

Right that allows one to override at build time,
supporting clang, ccache, ...

>  HOSTCC = gcc
>  CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall
>  CFLAGS = $(CCOPTS) -I../include $(DEFINES)
> diff --git a/configure b/configure
> index f5c3d40..680fdcb 100755
> --- a/configure
> +++ b/configure
> @@ -3,6 +3,11 @@
>  #
>  INCLUDE=${1:-"$PWD/include"}
>  
> +if [ "_$CC" == "_" ]
> +then
> +    CC=gcc
> +fi

Ditto at configure time.
Note the shell idiom for this is
: ${var:="value"}
Note the leading : is required for portability.
Not applicable here, but if you want to set only if unset
(rather than the above which also handles empty), do:
: ${var="value"}

cheers,
Pádraig.