build: Introduce HOSTCC flag
authordp-arm <dimitris.papastamos@arm.com>
Tue, 2 May 2017 10:09:11 +0000 (11:09 +0100)
committerdp-arm <dimitris.papastamos@arm.com>
Wed, 24 May 2017 13:24:49 +0000 (14:24 +0100)
Tools are built using the compiler specified in `HOSTCC` instead of
reusing the `CC` variable.  By default, gcc is used.

Change-Id: I83636a375c61f4804b4e80784db9d061fe20af87
Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
Makefile
tools/cert_create/Makefile
tools/fiptool/Makefile

index 5396c0ed50a255f885a636bcbfb3050e8fbf674b..15d418290ce1338e7fc0c710b1fd979b6bc2ab6c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -113,6 +113,9 @@ endif
 # Toolchain
 ################################################################################
 
+HOSTCC                 :=      gcc
+export HOSTCC
+
 CC                     :=      ${CROSS_COMPILE}gcc
 CPP                    :=      ${CROSS_COMPILE}cpp
 AS                     :=      ${CROSS_COMPILE}gcc
index 8a216495b744154a476d756d2607d579a6a48fa8..efd1f25d5833f298a9c5c776504f6be7ecd01456 100644 (file)
@@ -64,7 +64,7 @@ INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
 LIB_DIR := -L ${OPENSSL_DIR}/lib
 LIB := -lssl -lcrypto
 
-CC := gcc
+HOSTCC ?= gcc
 
 .PHONY: all clean realclean
 
@@ -75,11 +75,11 @@ ${BINARY}: ${OBJECTS} Makefile
        @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
                 const char platform_msg[] = "${PLAT_MSG}";' | \
                 ${CC} -c ${CFLAGS} -xc - -o src/build_msg.o
-       ${Q}${CC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
+       ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
 
 %.o: %.c
        @echo "  CC      $<"
-       ${Q}${CC} -c ${CFLAGS} ${INC_DIR} $< -o $@
+       ${Q}${HOSTCC} -c ${CFLAGS} ${INC_DIR} $< -o $@
 
 clean:
        $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
index 29eac2a7901cd7372b372efac7c41c0b492eba34..ee674b7f9f6660e30b4c5c2b0d9163f77e9d2a7a 100644 (file)
@@ -29,7 +29,7 @@ endif
 
 INCLUDE_PATHS := -I. -I../../include/tools_share
 
-CC := gcc
+HOSTCC ?= gcc
 
 .PHONY: all clean distclean
 
@@ -37,7 +37,7 @@ all: ${PROJECT} fip_create
 
 ${PROJECT}: ${OBJECTS} Makefile
        @echo "  LD      $@"
-       ${Q}${CC} ${OBJECTS} -o $@ ${LDLIBS}
+       ${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS}
        @${ECHO_BLANK_LINE}
        @echo "Built $@ successfully"
        @${ECHO_BLANK_LINE}
@@ -48,7 +48,7 @@ fip_create: fip_create.sh
 
 %.o: %.c %.h Makefile
        @echo "  CC      $<"
-       ${Q}${CC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@
+       ${Q}${HOSTCC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@
 
 clean:
        $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} fip_create)