build-kernel.sh: Support 'arm64' architecture.

This patch adds support for --arch=arm64 to the build-kernel.sh
script. Note that this requires android-goldfish-3.10 or higher,
and is currently limited to the 'defconfig' default config.

This is enough to build an AARCH64 kernel, but there is no guarantee
at this point that it can run under either QEMU or the Android emulator.

Change-Id: Idc3ecc3e3b9b8f06aeba9c4710903f55c64331df
diff --git a/distrib/build-kernel.sh b/distrib/build-kernel.sh
index 9b3bc9d..3d50e9a 100755
--- a/distrib/build-kernel.sh
+++ b/distrib/build-kernel.sh
@@ -158,6 +158,10 @@
             echo "WARNING: android-goldfish-$KERNEL_VERSION doesn't build --arch=$ARCH with GCC 4.7"
         fi
     fi
+    if [ "$ARCH" = "arm64" ]; then
+        # There is no GCC 4.7 toolchain to build AARCH64 binaries.
+        GCC_VERSION=4.8
+    fi
     echo "Autoconfig: --gcc-version=$GCC_VERSION"
 fi
 
@@ -186,6 +190,10 @@
         mips)
             CONFIG=goldfish
             ;;
+        arm64)
+            # TODO(digit): Provide better config.
+            CONFIG=defconfig
+            ;;
         *)
             echo "ERROR: Invalid arch '$ARCH', try one of $VALID_ARCHS"
             exit 1
@@ -220,6 +228,9 @@
         mips)
             CROSSPREFIX=mipsel-linux-android-
             ;;
+        arm64)
+            CROSSPREFIX=aarch64-linux-android-
+            ;;
         *)
             echo "ERROR: Unsupported architecture!"
             exit 1
@@ -235,6 +246,9 @@
     x86|x86_64)
         ZIMAGE=bzImage
         ;;
+    arm64)
+        ZIMAGE=Image.gz
+        ;;
     mips)
         ZIMAGE=
         ;;
@@ -260,6 +274,9 @@
             # x86_46 binaries are under prebuilts/gcc/<host>/x86 !!
             PREBUILT_ARCH=x86
             ;;
+        arm64)
+            PREBUILT_ARCH=aarch64
+            ;;
         *)
             PREBUILT_ARCH=$ARCH
             ;;
@@ -300,10 +317,19 @@
   MAKE_FLAGS="$MAKE_FLAGS V=1"
 fi
 
+case $CONFIG in
+    defconfig)
+        MAKE_DEFCONFIG=$CONFIG
+        ;;
+    *)
+        MAKE_DEFCONFIG=${CONFIG}_defconfig
+        ;;
+esac
+
 # Do the build
 #
 rm -f include/asm &&
-make ${CONFIG}_defconfig &&    # configure the kernel
+make $MAKE_DEFCONFIG &&    # configure the kernel
 make -j$JOBS $MAKE_FLAGS       # build it
 
 if [ $? != 0 ] ; then