1#!/bin/sh 2# 3# This is a wrapper around our x86 toolchain that allows us to add a few 4# compiler flags. 5# The issue is that our x86 toolchain is NDK-compatible, and hence enforces 6# -mfpmath=sse and -fpic by default. When building the kernel, we need to 7# disable this. 8# 9# Also support ccache compilation if USE_CCACHE is defined as "1" 10# 11 12# REAL_CROSS_COMPILE must be defined, and its value must be one of the 13# CROSS_COMPILE values that are supported by the Kernel build system 14# (e.g. "i686-android-linux-") 15# 16if [ -z "$REAL_CROSS_COMPILE" ]; then 17 echo "ERROR: The REAL_CROSS_COMPILE environment variable should be defined!" 18 exit 1 19fi 20 21# ARCH must also be defined before calling this script, e.g. 'arm' or 'x86' 22# 23if [ -z "$ARCH" ]; then 24 echo "ERROR: ARCH must be defined!" 25 exit 1 26fi 27 28# Common prefix for all fake toolchain programs, which are all really 29# symlinks to this script, i.e. 30# 31# $PROGPREFIX-gcc --> $0 32# $PROGPREFIX-ld --> $0 33# etc... 34# 35PROGPREFIX=android-kernel-toolchain- 36 37# Get program name, must be of the form $PROGPREFIX-<suffix>, where 38# <suffix> can be 'gcc', 'ld', etc... We expect that the fake toolchain 39# files are all symlinks to this script. 40# 41PROGNAME=$(basename "$0") 42PROGSUFFIX=${PROGNAME##$PROGPREFIX} 43 44EXTRA_FLAGS= 45 46# Special case #1: For x86, disable SSE FPU arithmetic, and PIC code 47if [ "$ARCH" = "x86" -a "$PROGSUFFIX" = gcc ]; then 48 EXTRA_FLAGS=$EXTRA_FLAGS" -mfpmath=387 -fno-pic" 49fi 50 51# Invoke real cross-compiler toolchain program now 52${REAL_CROSS_COMPILE}$PROGSUFFIX $EXTRA_FLAGS "$@" 53