[PATCH] tools: Makefile: Checking CC before direcly assign $(CROSS_COMPILE)gcc

4 views
Skip to first unread message

Peng Fan

unread,
Aug 31, 2016, 2:17:54 AM8/31/16
to jailho...@googlegroups.com, jan.k...@siemens.com, Peng Fan
To some toolchains, need to pass sysroot to gcc.
If directly assign $(CROSS_COMPILE)gcc to CC, there is
no chance to pass sysroot to gcc.

So, checking whether CC is set in user bash environment,
if not set, choose $(CROSS_COMPILE)gcc.

In my case, I have this in my bash script:
export CC="aarch64-poky-linux-gcc --sysroot=$SDKTARGETSYSROOT"

Signed-off-by: Peng Fan <peng...@nxp.com>
---
tools/Makefile | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/Makefile b/tools/Makefile
index 6975a76..9f62f2a 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -10,7 +10,9 @@
# the COPYING file in the top-level directory.
#

+ifeq ($(CC), )
CC = $(CROSS_COMPILE)gcc
+endif

CFLAGS = -g -O3 -I../driver -DLIBEXECDIR=\"$(libexecdir)\" \
-Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Werror \
--
2.6.6

Jan Kiszka

unread,
Aug 31, 2016, 9:07:59 AM8/31/16
to Peng Fan, jailho...@googlegroups.com, Peng Fan
On 2016-08-31 02:17, Peng Fan wrote:
> To some toolchains, need to pass sysroot to gcc.
> If directly assign $(CROSS_COMPILE)gcc to CC, there is
> no chance to pass sysroot to gcc.
>
> So, checking whether CC is set in user bash environment,
> if not set, choose $(CROSS_COMPILE)gcc.
>
> In my case, I have this in my bash script:
> export CC="aarch64-poky-linux-gcc --sysroot=$SDKTARGETSYSROOT"
>
> Signed-off-by: Peng Fan <peng...@nxp.com>
> ---
> tools/Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/Makefile b/tools/Makefile
> index 6975a76..9f62f2a 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -10,7 +10,9 @@
> # the COPYING file in the top-level directory.
> #
>
> +ifeq ($(CC), )
> CC = $(CROSS_COMPILE)gcc
> +endif

Let's use "CC ?= ..." for this.

Jan
Reply all
Reply to author
Forward
0 new messages