summaryrefslogtreecommitdiff
path: root/config/android.config
blob: 7a4c7525673195a1645ea6eb778fcff92534bcfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# 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

variants += ['nogtk', 'noclutter', 'nopython', 'notestspackage']

if not toolchain_prefix:
    toolchain_prefix = os.path.join(home_dir, 'android-ndk-r9')

toolchain_path = None

if target_arch == Architecture.ARM or target_arch == Architecture.ARMv7:
    tools_prefix = 'arm-linux-androideabi'
    host = "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'
    host = "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
elif target_arch == Architecture.UNIVERSAL:
    _arch = ''
    tools_prefix = ''
    toolchain_path = '.'
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'