# This file contains the default configuration to compile for Android # platforms. It contains sensitive enviroment configuration that # shouldn't be modified unless you know what you are doing. # PLEASE, DO NOT EDIT THIS FILE import os from cerbero.config import Architecture, DistroVersion from cerbero.errors import FatalError import cerbero.utils.messages as m if not toolchain_prefix: toolchain_prefix = os.path.expanduser('~/cerbero/android-ndk-r9') toolchain_path = None if target_arch == Architecture.ARM or target_arch == Architecture.ARMv7: tools_prefix = 'arm-linux-androideabi' _arch = 'arm' for tc_version in ['4.8', '4.7', '4.6']: for tc_arch in ['linux-x86', 'linux-x86_64']: tmp = '%s/toolchains/arm-linux-androideabi-%s/prebuilt/%s/bin' % (toolchain_prefix, tc_version, tc_arch) if os.path.exists(tmp): toolchain_path = tmp break if toolchain_path: break elif target_arch == Architecture.X86: tools_prefix = 'i686-linux-android' _arch = 'x86' for tc_version in ['4.8', '4.7', '4.6']: for tc_arch in ['linux-x86', 'linux-x86_64']: tmp = '%s/toolchains/x86-%s/prebuilt/%s/bin' % (toolchain_prefix, tc_version, tc_arch) if os.path.exists(tmp): toolchain_path = tmp break if toolchain_path: break else: raise FatalError("Arch not supported") if not toolchain_path: m.warning ("Android NDK not found") if target_distro_version == DistroVersion.ANDROID_GINGERBREAD: v = '9' elif target_distro_version == DistroVersion.ANDROID_ICE_CREAM_SANDWICH: v = '14' elif target_distro_version == DistroVersion.ANDROID_JELLY_BEAN: v = '14' else: raise FatalError("DistroVersion not supported") sysroot = "%s/platforms/android-%s/arch-%s" % (toolchain_prefix, v, _arch) # Default compiler flags os.environ['CFLAGS'] = '-Wall -g -Os ' os.environ['CXXFLAGS'] = '-Wall -g -Os ' os.environ['OBJCFLAGS'] = '-Wall -g -Os ' ccache = use_ccache and 'ccache ' or '' defines = '-DANDROID -DPIC' cflags = '--sysroot=%s -I%s/usr/include -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fPIC' % (sysroot, sysroot) ldflags = '--sysroot=%s -fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,-dynamic-linker,/system/bin/linker -L%s/usr/lib ' % (sysroot, sysroot) # from android-ndk-r8b/toolchains/$NAME-$VERSION/setup.mk if target_arch in [Architecture.ARM, Architecture.ARMv7]: cflags += ' -mthumb -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 ' if target_arch == Architecture.ARM: defines += ' -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ ' cflags += ' -march=armv5te -mtune=xscale -msoft-float' elif target_arch == Architecture.ARMv7: defines += ' -D__ARM_ARCH_7A__ ' cflags += ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16' ldflags += "-march=armv7-a -Wl,--fix-cortex-a8 " if target_arch == Architecture.X86: cflags += ' -march=i686 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300' # Toolchain environment os.environ['CPPFLAGS'] = '--sysroot=%s -I%s/usr/include %s' % (sysroot, sysroot, defines) os.environ['CFLAGS'] += "%s %s -Wa,--noexecstack" % (cflags, defines) os.environ['CXXFLAGS'] = os.environ['CFLAGS'] os.environ['LDFLAGS'] = '%s' % (ldflags,) def cmd(command): return '%s-%s' % (tools_prefix, command) os.environ['CC']= '%s%s' % (ccache, cmd('gcc')) os.environ['CC'] += ' -fuse-ld=gold' os.environ['CXX']= '%s%s' % (ccache, cmd('g++')) os.environ['CXX'] += ' -fuse-ld=gold' os.environ['LD']= cmd('ld.gold') os.environ['CPP']= cmd('cpp') os.environ['RANLIB']= cmd('ranlib') os.environ['AR']= cmd('ar') os.environ['AS']= cmd('as') os.environ['NM']= cmd('nm') os.environ['STRIP']= cmd('strip') os.environ['OBJCOPY']= cmd('objcopy') os.environ['PATH'] = '%s:%s:%s' % (toolchain_prefix, toolchain_path, os.environ['PATH']) # For the libc.so dependency in i686-linux-android-as if target_arch == Architecture.X86: extra_lib_path = '%s/usr/lib' % (sysroot) # For GLib os.environ['glib_cv_stack_grows'] = 'yes' os.environ['glib_cv_uscore'] = 'no' os.environ['ac_cv_func_posix_getpwuid_r'] = 'no' os.environ['ac_cv_func_nonposix_getpwuid_r'] = 'no' os.environ['ac_cv_func_posix_getgrgid_r'] = 'no' os.environ['ac_cv_func_nonposix_getgrgid_r'] = 'no'