1*8f44c3f5SXin Li#!/bin/sh 2*8f44c3f5SXin Li# 3*8f44c3f5SXin Li# A small script used to rebuild the Android goldfish kernel image 4*8f44c3f5SXin Li# See docs/KERNEL.TXT for usage instructions. 5*8f44c3f5SXin Li# 6*8f44c3f5SXin Li 7*8f44c3f5SXin Liexport LANG=C 8*8f44c3f5SXin Liexport LC_ALL=C 9*8f44c3f5SXin Li 10*8f44c3f5SXin LiPROGNAME=$(basename "$0") 11*8f44c3f5SXin Li 12*8f44c3f5SXin LiMACHINE=goldfish 13*8f44c3f5SXin LiVARIANT=goldfish 14*8f44c3f5SXin LiOUTPUT=/tmp/kernel-qemu 15*8f44c3f5SXin LiCROSSPREFIX=arm-linux-androideabi- 16*8f44c3f5SXin LiCONFIG=goldfish 17*8f44c3f5SXin LiGCC_VERSION=4.9 18*8f44c3f5SXin Li 19*8f44c3f5SXin LiVALID_ARCHS="arm x86 x86_64 mips arm64 mips64" 20*8f44c3f5SXin Li 21*8f44c3f5SXin Li# Determine the host architecture, and which default prebuilt tag we need. 22*8f44c3f5SXin Li# For the toolchain auto-detection. 23*8f44c3f5SXin Li# 24*8f44c3f5SXin LiHOST_OS=`uname -s` 25*8f44c3f5SXin Licase "$HOST_OS" in 26*8f44c3f5SXin Li Darwin) 27*8f44c3f5SXin Li HOST_OS=darwin 28*8f44c3f5SXin Li HOST_TAG=darwin-x86 29*8f44c3f5SXin Li BUILD_NUM_CPUS=$(sysctl -n hw.ncpu) 30*8f44c3f5SXin Li ;; 31*8f44c3f5SXin Li Linux) 32*8f44c3f5SXin Li # note that building 32-bit binaries on x86_64 is handled later 33*8f44c3f5SXin Li HOST_OS=linux 34*8f44c3f5SXin Li HOST_TAG=linux-x86 35*8f44c3f5SXin Li BUILD_NUM_CPUS=$(grep -c processor /proc/cpuinfo) 36*8f44c3f5SXin Li ;; 37*8f44c3f5SXin Li *) 38*8f44c3f5SXin Li echo "ERROR: Unsupported OS: $HOST_OS" 39*8f44c3f5SXin Li exit 1 40*8f44c3f5SXin Liesac 41*8f44c3f5SXin Li 42*8f44c3f5SXin Li# Default number of parallel jobs during the build: cores * 2 43*8f44c3f5SXin LiJOBS=$(( $BUILD_NUM_CPUS * 2 )) 44*8f44c3f5SXin Li 45*8f44c3f5SXin LiARCH=arm 46*8f44c3f5SXin Li 47*8f44c3f5SXin LiOPTION_HELP=no 48*8f44c3f5SXin LiOPTION_ARMV7=yes 49*8f44c3f5SXin LiOPTION_OUT= 50*8f44c3f5SXin LiOPTION_CROSS= 51*8f44c3f5SXin LiOPTION_ARCH= 52*8f44c3f5SXin LiOPTION_CONFIG= 53*8f44c3f5SXin LiOPTION_SAVEDEFCONFIG=no 54*8f44c3f5SXin LiOPTION_JOBS= 55*8f44c3f5SXin LiOPTION_VERBOSE= 56*8f44c3f5SXin LiOPTION_GCC_VERSION= 57*8f44c3f5SXin LiCCACHE= 58*8f44c3f5SXin Li 59*8f44c3f5SXin Licase "$USE_CCACHE" in 60*8f44c3f5SXin Li "") 61*8f44c3f5SXin Li CCACHE= 62*8f44c3f5SXin Li ;; 63*8f44c3f5SXin Li *) 64*8f44c3f5SXin Li # use ccache bundled in AOSP source tree 65*8f44c3f5SXin Li CCACHE=${ANDROID_BUILD_TOP:-$(dirname $0)/../..}/prebuilts/misc/$HOST_TAG/ccache/ccache 66*8f44c3f5SXin Li [ -x $CCACHE ] || CCACHE= 67*8f44c3f5SXin Li ;; 68*8f44c3f5SXin Liesac 69*8f44c3f5SXin Li 70*8f44c3f5SXin Lifor opt do 71*8f44c3f5SXin Li optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 72*8f44c3f5SXin Li case $opt in 73*8f44c3f5SXin Li --help|-h|-\?) OPTION_HELP=yes 74*8f44c3f5SXin Li ;; 75*8f44c3f5SXin Li --arch=*) 76*8f44c3f5SXin Li OPTION_ARCH=$optarg 77*8f44c3f5SXin Li ;; 78*8f44c3f5SXin Li --armv5) 79*8f44c3f5SXin Li OPTION_ARMV7=no 80*8f44c3f5SXin Li ;; 81*8f44c3f5SXin Li --armv7) 82*8f44c3f5SXin Li OPTION_ARMV7=yes 83*8f44c3f5SXin Li ;; 84*8f44c3f5SXin Li --ccache=*) 85*8f44c3f5SXin Li CCACHE=$optarg 86*8f44c3f5SXin Li ;; 87*8f44c3f5SXin Li --config=*) 88*8f44c3f5SXin Li OPTION_CONFIG=$optarg 89*8f44c3f5SXin Li ;; 90*8f44c3f5SXin Li --cross=*) 91*8f44c3f5SXin Li OPTION_CROSS=$optarg 92*8f44c3f5SXin Li ;; 93*8f44c3f5SXin Li --gcc-version=*) 94*8f44c3f5SXin Li OPTION_GCC_VERSION=$optarg 95*8f44c3f5SXin Li ;; 96*8f44c3f5SXin Li -j*|--jobs=*) 97*8f44c3f5SXin Li OPTION_JOBS=$optarg 98*8f44c3f5SXin Li ;; 99*8f44c3f5SXin Li --out=*) 100*8f44c3f5SXin Li OPTION_OUT=$optarg 101*8f44c3f5SXin Li ;; 102*8f44c3f5SXin Li --savedefconfig) 103*8f44c3f5SXin Li OPTION_SAVEDEFCONFIG=yes 104*8f44c3f5SXin Li ;; 105*8f44c3f5SXin Li --verbose) 106*8f44c3f5SXin Li OPTION_VERBOSE=true 107*8f44c3f5SXin Li ;; 108*8f44c3f5SXin Li *) 109*8f44c3f5SXin Li echo "unknown option '$opt', use --help" 110*8f44c3f5SXin Li exit 1 111*8f44c3f5SXin Li esac 112*8f44c3f5SXin Lidone 113*8f44c3f5SXin Li 114*8f44c3f5SXin Liif [ $OPTION_HELP = "yes" ] ; then 115*8f44c3f5SXin Li echo "Rebuild the prebuilt kernel binary for Android's emulator." 116*8f44c3f5SXin Li echo "" 117*8f44c3f5SXin Li echo "options (defaults are within brackets):" 118*8f44c3f5SXin Li echo "" 119*8f44c3f5SXin Li echo " --help print this message" 120*8f44c3f5SXin Li echo " --arch=<arch> change target architecture [$ARCH]" 121*8f44c3f5SXin Li echo " --armv5 build ARMv5 binaries" 122*8f44c3f5SXin Li echo " --armv7 build ARMv7 binaries (default. see note below)" 123*8f44c3f5SXin Li echo " --out=<directory> output directory [$OUTPUT]" 124*8f44c3f5SXin Li echo " --cross=<prefix> cross-toolchain prefix [$CROSSPREFIX]" 125*8f44c3f5SXin Li echo " --config=<name> kernel config name [$CONFIG]" 126*8f44c3f5SXin Li echo " --savedefconfig run savedefconfig" 127*8f44c3f5SXin Li echo " --ccache=<path> use compiler cache [${CCACHE:-not set}]" 128*8f44c3f5SXin Li echo " --gcc-version=<version> use specific GCC version [$GCC_VERSION]" 129*8f44c3f5SXin Li echo " --verbose show build commands" 130*8f44c3f5SXin Li echo " -j<number> launch <number> parallel build jobs [$JOBS]" 131*8f44c3f5SXin Li echo "" 132*8f44c3f5SXin Li echo "NOTE: --armv7 is equivalent to --config=goldfish_armv7. It is" 133*8f44c3f5SXin Li echo " ignored if --config=<name> is used." 134*8f44c3f5SXin Li echo "" 135*8f44c3f5SXin Li exit 0 136*8f44c3f5SXin Lifi 137*8f44c3f5SXin Li 138*8f44c3f5SXin Liif [ ! -f include/linux/vermagic.h ]; then 139*8f44c3f5SXin Li echo "ERROR: You must be in the top-level kernel source directory to run this script." 140*8f44c3f5SXin Li exit 1 141*8f44c3f5SXin Lifi 142*8f44c3f5SXin Li 143*8f44c3f5SXin Li# Extract kernel version, we'll need to put this in the final binaries names 144*8f44c3f5SXin Li# to ensure the emulator can trivially know it without probing the binary with 145*8f44c3f5SXin Li# 'file' or other unreliable heuristics. 146*8f44c3f5SXin LiKERNEL_MAJOR=$(awk '$1 == "VERSION" { print $3; }' Makefile) 147*8f44c3f5SXin LiKERNEL_MINOR=$(awk '$1 == "PATCHLEVEL" { print $3; }' Makefile) 148*8f44c3f5SXin LiKERNEL_PATCH=$(awk '$1 == "SUBLEVEL" { print $3; }' Makefile) 149*8f44c3f5SXin LiKERNEL_VERSION="$KERNEL_MAJOR.$KERNEL_MINOR.$KERNEL_PATCH" 150*8f44c3f5SXin Liecho "Found kernel version: $KERNEL_VERSION" 151*8f44c3f5SXin Li 152*8f44c3f5SXin Liif [ -n "$OPTION_ARCH" ]; then 153*8f44c3f5SXin Li ARCH=$OPTION_ARCH 154*8f44c3f5SXin Lifi 155*8f44c3f5SXin Li 156*8f44c3f5SXin Liif [ -n "$OPTION_GCC_VERSION" ]; then 157*8f44c3f5SXin Li GCC_VERSION=$OPTION_GCC_VERSION 158*8f44c3f5SXin Lielse 159*8f44c3f5SXin Li if [ "$ARCH" = "x86" ]; then 160*8f44c3f5SXin Li # Work-around a nasty bug. 161*8f44c3f5SXin Li # Hence 132637 is 2.6.29. 162*8f44c3f5SXin Li if [ "$KERNEL_VERSION" = "2.6.29" ]; then 163*8f44c3f5SXin Li GCC_VERSION=4.6 164*8f44c3f5SXin Li echo "WARNING: android-goldfish-$KERNEL_VERSION doesn't build --arch=$ARCH with GCC 4.7" 165*8f44c3f5SXin Li fi 166*8f44c3f5SXin Li fi 167*8f44c3f5SXin Li if [ "$ARCH" = "arm64" ]; then 168*8f44c3f5SXin Li # There is no GCC 4.7 toolchain to build AARCH64 binaries. 169*8f44c3f5SXin Li GCC_VERSION=4.8 170*8f44c3f5SXin Li fi 171*8f44c3f5SXin Li if [ "$ARCH" = "mips64" ]; then 172*8f44c3f5SXin Li GCC_VERSION=4.9 173*8f44c3f5SXin Li fi 174*8f44c3f5SXin Li if [ "$ARCH" = "mips" ]; then 175*8f44c3f5SXin Li GCC_VERSION=4.9 176*8f44c3f5SXin Li fi 177*8f44c3f5SXin Li echo "Autoconfig: --gcc-version=$GCC_VERSION" 178*8f44c3f5SXin Lifi 179*8f44c3f5SXin Li 180*8f44c3f5SXin Liif [ -n "$OPTION_CONFIG" ]; then 181*8f44c3f5SXin Li CONFIG=$OPTION_CONFIG 182*8f44c3f5SXin Lielse 183*8f44c3f5SXin Li case $ARCH in 184*8f44c3f5SXin Li arm) 185*8f44c3f5SXin Li CONFIG=goldfish_armv7 186*8f44c3f5SXin Li if [ "$OPTION_ARMV7" = "no" ]; then 187*8f44c3f5SXin Li CONFIG=goldfish 188*8f44c3f5SXin Li fi 189*8f44c3f5SXin Li ;; 190*8f44c3f5SXin Li x86) 191*8f44c3f5SXin Li # Warning: this is ambiguous, should be 'goldfish' before 3.10, 192*8f44c3f5SXin Li # and 'i386_emu" after it. 193*8f44c3f5SXin Li if [ -f "arch/x86/configs/i386_emu_defconfig" ]; then 194*8f44c3f5SXin Li CONFIG=i386_emu 195*8f44c3f5SXin Li else 196*8f44c3f5SXin Li CONFIG=goldfish 197*8f44c3f5SXin Li fi 198*8f44c3f5SXin Li ;; 199*8f44c3f5SXin Li x86_64) 200*8f44c3f5SXin Li CONFIG=x86_64_emu 201*8f44c3f5SXin Li ;; 202*8f44c3f5SXin Li mips) 203*8f44c3f5SXin Li CONFIG=goldfish 204*8f44c3f5SXin Li ;; 205*8f44c3f5SXin Li mips64) 206*8f44c3f5SXin Li CONFIG=ranchu64 207*8f44c3f5SXin Li ;; 208*8f44c3f5SXin Li arm64) 209*8f44c3f5SXin Li CONFIG=ranchu 210*8f44c3f5SXin Li ;; 211*8f44c3f5SXin Li *) 212*8f44c3f5SXin Li echo "ERROR: Invalid arch '$ARCH', try one of $VALID_ARCHS" 213*8f44c3f5SXin Li exit 1 214*8f44c3f5SXin Li esac 215*8f44c3f5SXin Li echo "Auto-config: --config=$CONFIG" 216*8f44c3f5SXin Lifi 217*8f44c3f5SXin Li 218*8f44c3f5SXin Li# Check output directory. 219*8f44c3f5SXin Liif [ -n "$OPTION_OUT" ] ; then 220*8f44c3f5SXin Li if [ ! -d "$OPTION_OUT" ] ; then 221*8f44c3f5SXin Li echo "Output directory '$OPTION_OUT' does not exist ! Aborting." 222*8f44c3f5SXin Li exit 1 223*8f44c3f5SXin Li fi 224*8f44c3f5SXin Li OUTPUT=$OPTION_OUT 225*8f44c3f5SXin Lielse 226*8f44c3f5SXin Li OUTPUT=$OUTPUT/${ARCH}-${KERNEL_VERSION} 227*8f44c3f5SXin Li case $CONFIG in 228*8f44c3f5SXin Li vbox*) 229*8f44c3f5SXin Li OUTPUT=${OUTPUT}-vbox 230*8f44c3f5SXin Li ;; 231*8f44c3f5SXin Li goldfish) 232*8f44c3f5SXin Li if [ "$ARCH" = "arm" ]; then 233*8f44c3f5SXin Li OUTPUT=${OUTPUT}-armv5 234*8f44c3f5SXin Li fi 235*8f44c3f5SXin Li ;; 236*8f44c3f5SXin Li esac 237*8f44c3f5SXin Li echo "Auto-config: --out=$OUTPUT" 238*8f44c3f5SXin Li mkdir -p $OUTPUT 239*8f44c3f5SXin Lifi 240*8f44c3f5SXin Li 241*8f44c3f5SXin Liif [ -n "$OPTION_CROSS" ] ; then 242*8f44c3f5SXin Li CROSSPREFIX="$OPTION_CROSS" 243*8f44c3f5SXin Li CROSSTOOLCHAIN=${CROSSPREFIX}$GCC_VERSION 244*8f44c3f5SXin Lielse 245*8f44c3f5SXin Li case $ARCH in 246*8f44c3f5SXin Li arm) 247*8f44c3f5SXin Li CROSSPREFIX=arm-linux-androideabi- 248*8f44c3f5SXin Li ;; 249*8f44c3f5SXin Li x86) 250*8f44c3f5SXin Li CROSSPREFIX=x86_64-linux-android- 251*8f44c3f5SXin Li # NOTE: kernel-toolchain/toolbox.sh will add -m32 252*8f44c3f5SXin Li ;; 253*8f44c3f5SXin Li x86_64) 254*8f44c3f5SXin Li CROSSPREFIX=x86_64-linux-android- 255*8f44c3f5SXin Li ;; 256*8f44c3f5SXin Li mips) 257*8f44c3f5SXin Li CROSSPREFIX=mips64el-linux-android- 258*8f44c3f5SXin Li ;; 259*8f44c3f5SXin Li mips64) 260*8f44c3f5SXin Li CROSSPREFIX=mips64el-linux-android- 261*8f44c3f5SXin Li ;; 262*8f44c3f5SXin Li arm64) 263*8f44c3f5SXin Li CROSSPREFIX=aarch64-linux-android- 264*8f44c3f5SXin Li ;; 265*8f44c3f5SXin Li *) 266*8f44c3f5SXin Li echo "ERROR: Unsupported architecture!" 267*8f44c3f5SXin Li exit 1 268*8f44c3f5SXin Li ;; 269*8f44c3f5SXin Li esac 270*8f44c3f5SXin Li CROSSTOOLCHAIN=${CROSSPREFIX}$GCC_VERSION 271*8f44c3f5SXin Li echo "Auto-config: --cross=$CROSSPREFIX" 272*8f44c3f5SXin Lifi 273*8f44c3f5SXin Li 274*8f44c3f5SXin LiZIMAGE=zImage 275*8f44c3f5SXin Li 276*8f44c3f5SXin Licase $ARCH in 277*8f44c3f5SXin Li x86|x86_64) 278*8f44c3f5SXin Li ZIMAGE=bzImage 279*8f44c3f5SXin Li ;; 280*8f44c3f5SXin Li arm64) 281*8f44c3f5SXin Li ZIMAGE=Image 282*8f44c3f5SXin Li ;; 283*8f44c3f5SXin Li mips) 284*8f44c3f5SXin Li ZIMAGE= 285*8f44c3f5SXin Li ;; 286*8f44c3f5SXin Li mips64) 287*8f44c3f5SXin Li ZIMAGE= 288*8f44c3f5SXin Li ;; 289*8f44c3f5SXin Liesac 290*8f44c3f5SXin Li 291*8f44c3f5SXin Li# If the cross-compiler is not in the path, try to find it automatically 292*8f44c3f5SXin LiCROSS_COMPILER="${CROSSPREFIX}gcc" 293*8f44c3f5SXin LiCROSS_COMPILER_VERSION=$($CROSS_COMPILER --version 2>/dev/null) 294*8f44c3f5SXin Liif [ $? != 0 ] ; then 295*8f44c3f5SXin Li BUILD_TOP=$ANDROID_BUILD_TOP 296*8f44c3f5SXin Li if [ -z "$BUILD_TOP" ]; then 297*8f44c3f5SXin Li # Assume this script is under external/qemu/distrib/ in the 298*8f44c3f5SXin Li # Android source tree. 299*8f44c3f5SXin Li BUILD_TOP=$(dirname $0)/../.. 300*8f44c3f5SXin Li if [ ! -d "$BUILD_TOP/prebuilts" ]; then 301*8f44c3f5SXin Li BUILD_TOP= 302*8f44c3f5SXin Li else 303*8f44c3f5SXin Li BUILD_TOP=$(cd $BUILD_TOP && pwd) 304*8f44c3f5SXin Li fi 305*8f44c3f5SXin Li fi 306*8f44c3f5SXin Li case $ARCH in 307*8f44c3f5SXin Li x86_64) 308*8f44c3f5SXin Li # x86_46 binaries are under prebuilts/gcc/<host>/x86 !! 309*8f44c3f5SXin Li PREBUILT_ARCH=x86 310*8f44c3f5SXin Li ;; 311*8f44c3f5SXin Li arm64) 312*8f44c3f5SXin Li PREBUILT_ARCH=aarch64 313*8f44c3f5SXin Li ;; 314*8f44c3f5SXin Li mips64) 315*8f44c3f5SXin Li PREBUILT_ARCH=mips 316*8f44c3f5SXin Li ;; 317*8f44c3f5SXin Li *) 318*8f44c3f5SXin Li PREBUILT_ARCH=$ARCH 319*8f44c3f5SXin Li ;; 320*8f44c3f5SXin Li esac 321*8f44c3f5SXin Li CROSSPREFIX=$BUILD_TOP/prebuilts/gcc/$HOST_TAG/$PREBUILT_ARCH/$CROSSTOOLCHAIN/bin/$CROSSPREFIX 322*8f44c3f5SXin Li echo "Checking for ${CROSSPREFIX}gcc" 323*8f44c3f5SXin Li if [ "$BUILD_TOP" -a -f ${CROSSPREFIX}gcc ]; then 324*8f44c3f5SXin Li echo "Auto-config: --cross=$CROSSPREFIX" 325*8f44c3f5SXin Li else 326*8f44c3f5SXin Li echo "It looks like $CROSS_COMPILER is not in your path ! Aborting." 327*8f44c3f5SXin Li exit 1 328*8f44c3f5SXin Li fi 329*8f44c3f5SXin Lifi 330*8f44c3f5SXin Li 331*8f44c3f5SXin Liif [ "$CCACHE" ] ; then 332*8f44c3f5SXin Li echo "Using ccache program: $CCACHE" 333*8f44c3f5SXin Li CROSSPREFIX="$CCACHE $CROSSPREFIX" 334*8f44c3f5SXin Lifi 335*8f44c3f5SXin Li 336*8f44c3f5SXin Liexport CROSS_COMPILE="$CROSSPREFIX" ARCH SUBARCH=$ARCH 337*8f44c3f5SXin Li 338*8f44c3f5SXin Liif [ "$OPTION_JOBS" ]; then 339*8f44c3f5SXin Li JOBS=$OPTION_JOBS 340*8f44c3f5SXin Lielse 341*8f44c3f5SXin Li echo "Auto-config: -j$JOBS" 342*8f44c3f5SXin Lifi 343*8f44c3f5SXin Li 344*8f44c3f5SXin Li 345*8f44c3f5SXin Li# Special magic redirection with our magic toolbox script 346*8f44c3f5SXin Li# This is needed to add extra compiler flags to compiler. 347*8f44c3f5SXin Li# See kernel-toolchain/android-kernel-toolchain-* for details 348*8f44c3f5SXin Li# 349*8f44c3f5SXin Liexport REAL_CROSS_COMPILE="$CROSS_COMPILE" 350*8f44c3f5SXin LiCROSS_COMPILE=$(dirname "$0")/kernel-toolchain/android-kernel-toolchain- 351*8f44c3f5SXin Li 352*8f44c3f5SXin LiMAKE_FLAGS= 353*8f44c3f5SXin Liif [ "$OPTION_VERBOSE" ]; then 354*8f44c3f5SXin Li MAKE_FLAGS="$MAKE_FLAGS V=1" 355*8f44c3f5SXin Lifi 356*8f44c3f5SXin Li 357*8f44c3f5SXin Licase $CONFIG in 358*8f44c3f5SXin Li defconfig) 359*8f44c3f5SXin Li MAKE_DEFCONFIG=$CONFIG 360*8f44c3f5SXin Li ;; 361*8f44c3f5SXin Li *) 362*8f44c3f5SXin Li MAKE_DEFCONFIG=${CONFIG}_defconfig 363*8f44c3f5SXin Li ;; 364*8f44c3f5SXin Liesac 365*8f44c3f5SXin Li 366*8f44c3f5SXin LiORG_ARCH=$ARCH 367*8f44c3f5SXin Licase $ARCH in 368*8f44c3f5SXin Li mips64) 369*8f44c3f5SXin Li # MIPS64 Kernel code base is under arch/mips 370*8f44c3f5SXin Li ARCH=mips 371*8f44c3f5SXin Li ;; 372*8f44c3f5SXin Liesac 373*8f44c3f5SXin Li 374*8f44c3f5SXin Li# Do the build 375*8f44c3f5SXin Li# 376*8f44c3f5SXin Lirm -f include/asm && 377*8f44c3f5SXin Limake $MAKE_DEFCONFIG && # configure the kernel 378*8f44c3f5SXin Limake -j$JOBS $MAKE_FLAGS # build it 379*8f44c3f5SXin Li 380*8f44c3f5SXin Liif [ $? != 0 ] ; then 381*8f44c3f5SXin Li echo "Could not build the kernel. Aborting !" 382*8f44c3f5SXin Li exit 1 383*8f44c3f5SXin Lifi 384*8f44c3f5SXin Li 385*8f44c3f5SXin Liif [ "$OPTION_SAVEDEFCONFIG" = "yes" ]; then 386*8f44c3f5SXin Li case $ARCH in 387*8f44c3f5SXin Li x86_64) 388*8f44c3f5SXin Li DEFCONFIG_ARCH=x86 389*8f44c3f5SXin Li ;; 390*8f44c3f5SXin Li *) 391*8f44c3f5SXin Li DEFCONFIG_ARCH=$ARCH 392*8f44c3f5SXin Li ;; 393*8f44c3f5SXin Li esac 394*8f44c3f5SXin Li make savedefconfig 395*8f44c3f5SXin Li mv -f defconfig arch/$DEFCONFIG_ARCH/configs/${CONFIG}_defconfig 396*8f44c3f5SXin Lifi 397*8f44c3f5SXin Li 398*8f44c3f5SXin Li# Note: The exact names of the output files are important for the Android build, 399*8f44c3f5SXin Li# do not change the definitions lightly. 400*8f44c3f5SXin LiKERNEL_PREFIX=kernel-$KERNEL_VERSION 401*8f44c3f5SXin Li 402*8f44c3f5SXin Li# Naming conventions for the kernel image files: 403*8f44c3f5SXin Li# 404*8f44c3f5SXin Li# 1) The kernel image is called kernel-qemu, except for 32-bit ARM 405*8f44c3f5SXin Li# where it must be called kernel-qemu-armv7 406*8f44c3f5SXin Li# 407*8f44c3f5SXin Li# 2) The debug symbol file is called vmlinux-qemu, except for 32-bit 408*8f44c3f5SXin Li# ARM where it must be called vmlinux-qemu-armv7 409*8f44c3f5SXin Li# 410*8f44c3f5SXin LiOUTPUT_KERNEL=kernel-qemu 411*8f44c3f5SXin LiOUTPUT_VMLINUX=vmlinux-qemu 412*8f44c3f5SXin Liif [ "$CONFIG" = "goldfish_armv7" ]; then 413*8f44c3f5SXin Li OUTPUT_KERNEL=${OUTPUT_KERNEL}-armv7 414*8f44c3f5SXin Li OUTPUT_VMLINUX=${OUTPUT_VMLINUX}-armv7 415*8f44c3f5SXin Lifi 416*8f44c3f5SXin Li 417*8f44c3f5SXin Licp -f vmlinux $OUTPUT/$OUTPUT_VMLINUX 418*8f44c3f5SXin Liif [ ! -z $ZIMAGE ]; then 419*8f44c3f5SXin Li cp -f arch/$ARCH/boot/$ZIMAGE $OUTPUT/$OUTPUT_KERNEL 420*8f44c3f5SXin Lielse 421*8f44c3f5SXin Li cp -f vmlinux $OUTPUT/$OUTPUT_KERNEL 422*8f44c3f5SXin Lifi 423*8f44c3f5SXin Liecho "Kernel $CONFIG prebuilt images ($OUTPUT_KERNEL and $OUTPUT_VMLINUX) copied to $OUTPUT successfully !" 424*8f44c3f5SXin Li 425*8f44c3f5SXin Licp COPYING $OUTPUT/LINUX_KERNEL_COPYING 426*8f44c3f5SXin Li 427*8f44c3f5SXin Licat > $OUTPUT/README <<EOF 428*8f44c3f5SXin LiThis directory contains kernel images to be used with the Android emulator 429*8f44c3f5SXin Liprogram, for the $ORG_ARCH CPU architecture. It was built with the $PROGNAME 430*8f44c3f5SXin Liscript. For more details, read: 431*8f44c3f5SXin Li 432*8f44c3f5SXin Li \$AOSP/external/qemu/docs/ANDROID-KERNEL.TXT 433*8f44c3f5SXin Li 434*8f44c3f5SXin LiEOF 435*8f44c3f5SXin Li 436*8f44c3f5SXin Liexit 0 437