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
|
# This file contains the default configuration to compile for Linux
# 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, Distro
# Set default values for some optional variants
variants.override(['alsa', 'x11', 'pulse', 'cdparanoia', 'v4l2', 'gi', 'unwind', 'rust'])
for f in ['CPPFLAGS', 'CFLAGS', 'CCASFLAGS', 'CXXFLAGS', 'LDFLAGS',
'OBJCFLAGS']:
env[f] = env.get(f, '')
arch_flags = ''
if target_arch == Architecture.X86:
arch_flags += ' -m32 '
_host = 'i686-linux-gnu'
elif target_arch == Architecture.X86_64:
arch_flags += ' -m64 '
_host = 'x86_64-linux-gnu'
if target_arch in [Architecture.ARM, Architecture.ARMv7, Architecture.ARM64]:
if target_arch == Architecture.ARMv7:
arch_flags += ' -march=armv7-a '
if target_arch == Architecture.ARM64:
_host = 'aarch64-linux-gnu'
else:
if distro == Distro.REDHAT:
_host = 'arm-linux-gnu'
else:
_host = 'arm-linux-gnueabi'
env['glib_cv_stack_grows'] = 'no'
env['glib_cv_uscore'] = 'no'
env['ac_cv_func_posix_getgrgid_r'] = 'yes'
env['ac_cv_func_posix_getpwuid_r'] = 'yes'
env['ac_cv_func_register_printf_specifier'] = 'no'
env['ac_cv_func_register_printf_function'] = 'no'
if toolchain_prefix:
gcc_toolchain_path = os.path.join (toolchain_prefix, 'bin')
env['PATH'] = '%s:%s:%s' % (toolchain_prefix, gcc_toolchain_path, env['PATH'])
if target_arch_flags is not None:
arch_flags += ' %s ' % (target_arch_flags)
if host is None and target_arch != arch:
host = _host
if tools_prefix is None:
if host is not None and host != '':
tools_prefix = '%s-' % host
else:
tools_prefix = ''
if isysroot is not None:
env['CPPFLAGS'] += ' -isysroot %s' % (isysroot)
env['CFLAGS'] += ' -isysroot %s' % (isysroot)
env['CXXFLAGS'] += ' -isysroot %s' % (isysroot)
env['OBJCFLAGS'] += ' -isysroot %s' % (isysroot)
if sysroot is not None:
env['CPPFLAGS'] += ' --sysroot=%s' % (sysroot)
env['CFLAGS'] += ' --sysroot=%s' % (sysroot)
env['CXXFLAGS'] += ' --sysroot=%s' % (sysroot)
env['OBJCFLAGS'] += ' --sysroot=%s' % (sysroot)
env['LDFLAGS'] += ' --sysroot=%s' % (sysroot)
# Some cross compilers have a bug in the search for indirect dependencies
# during linking.
# http://stackoverflow.com/questions/16593519/finding-shared-library-dependencies-when-linking-executable
workaround_cflags = ''
workaround_ldflags = ''
if target_arch != arch:
workaround_cflags = ' -Wl,-rpath-link=%s/lib ' % (prefix)
workaround_ldflags = ' -Wl,-rpath-link=%s/lib ' % (prefix)
# This needs to be added by hand on Fedora, for some reason
if distro == Distro.REDHAT:
workaround_cflags += '-I/usr/arm-linux-gnu/include'
# Disable gi if we are cross-compiling
variants.gi = False
env['CFLAGS'] += arch_flags + workaround_cflags
env['CXXFLAGS'] += arch_flags + workaround_cflags
env['OBJCFLAGS'] += arch_flags
env['CCASFLAGS'] += arch_flags
env['LDFLAGS'] += arch_flags + workaround_ldflags
def cmd(command):
return '%s%s' % (tools_prefix, command)
env['CC']= cmd('gcc')
env['CXX']= cmd('g++')
env['LD']= cmd('ld')
env['CPP']= cmd('cpp')
env['RANLIB']= cmd('ranlib')
env['AR']= cmd('ar')
env['AS']= cmd('as')
env['NM']= cmd('nm')
env['STRIP']= cmd('strip')
env['OBJCOPY']= cmd('objcopy')
if use_ccache:
comp = env.get('CC', 'gcc')
if not 'ccache' in comp:
env['CC'] = 'ccache ' + comp
comp = env.get('CXX', 'g++')
if not 'ccache' in comp:
env['CXX'] = 'ccache ' + comp
|