Makefile: optionally compile with clang

Different compilers can produce different warnings so having the option
to use gcc or clang lets us take advantage of that. Clang is also the
preferred compiler for Android projects.

The clang build fails at the moment but this adds the infrastructure to
select clang as the compiler with the `CLANG` environment variable:

    CLANG=1 make

Change-Id: I2dd5e8ce8e7fc20e93f5780348726a2f9b76239b
diff --git a/Makefile b/Makefile
index a094afd..7a0b08f 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,14 @@
 GLOBAL_OFFSET_SRCS :=
 $(foreach mod,$(MODULES),$(eval $(call include_module,$(mod))))
 
-CROSS_PREFIX := aarch64-linux-gnu-
+TARGET := aarch64-linux-gnu
+CROSS_PREFIX := $(TARGET)-
+
+ifeq ($(CLANG),1)
+  CC := clang -target $(TARGET)
+else
+  CC := $(CROSS_PREFIX)gcc
+endif
 
 #
 # Rules to build C files.
@@ -73,7 +80,7 @@
   REMAIN_SRCS := $$(filter-out $(1),$$(REMAIN_SRCS))
 $$(TGT): $(ROOT_DIR)$(1) | $$(dir $$(TGT))
 	$$(info CC $(ROOT_DIR)$1)
-	@$(CROSS_PREFIX)gcc $(COPTS) -c $(ROOT_DIR)$(1) -o $$@
+	@$(CC) $(COPTS) -c $(ROOT_DIR)$(1) -o $$@
 endef
 
 #
@@ -86,7 +93,7 @@
   GLOBAL_OFFSETS += $$(TGT)
 $$(TGT): $(ROOT_DIR)$(1) | $$(dir $$(TGT))
 	$$(info GENOFFSET $(ROOT_DIR)$1)
-	@$(CROSS_PREFIX)gcc $(COPTS) -MT $$@ -S -c $(ROOT_DIR)$(1) -o - | grep DEFINE_OFFSET | sed 's/\tDEFINE_OFFSET/#define/g' > $$@
+	@$(CC) $(COPTS) -MT $$@ -S -c $(ROOT_DIR)$(1) -o - | grep DEFINE_OFFSET | sed 's/\tDEFINE_OFFSET/#define/g' > $$@
 endef
 
 #
@@ -98,7 +105,7 @@
   REMAIN_SRCS := $$(filter-out $(1),$$(REMAIN_SRCS))
 $$(TGT): $(ROOT_DIR)$(1) $(GLOBAL_OFFSETS) | $$(dir $$(TGT))
 	$$(info AS $(ROOT_DIR)$1)
-	@$(CROSS_PREFIX)gcc $(COPTS) -c $(ROOT_DIR)$(1) -o $$@
+	@$(CC) $(COPTS) -c $(ROOT_DIR)$(1) -o $$@
 endef
 
 #