summaryrefslogtreecommitdiff
path: root/config/linux.config
blob: 3bf2f9e60c14347fc5d26b1928a76704099f2e4c (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
# 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

if 'noalsa' not in variants:
    variants.append('alsa')
if 'nox11' not in variants:
    variants.append('x11')
if 'nopulse' not in variants:
    variants.append('pulse')
if 'nocdparanoia' not in variants:
    variants.append('cdparanoia')
if 'nov4l2' not in variants:
    variants.append('v4l2')
if 'nosdl' not in variants:
    variants.append('sdl')
if 'nogtk2' not in variants:
    variants.append('gtk2')
if 'nogtk3' not in variants:
    variants.append('gtk3')
if 'nogi' not in variants:
    variants.append('gi')
if 'nounwind' not in variants:
    variants.append('unwind')

for f in ['CPPFLAGS', 'CFLAGS', 'CCASFLAGS', 'CXXFLAGS', 'LDFLAGS',
          'OBJCFLAGS']:
    os.environ[f] = os.environ.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]:
    if target_arch == Architecture.ARMv7:
       arch_flags += ' -march=armv7-a '
    _host = 'arm-linux-gnueabi'
    os.environ['glib_cv_stack_grows'] = 'no'
    os.environ['glib_cv_uscore'] = 'no'
    os.environ['ac_cv_func_posix_getgrgid_r'] = 'yes'
    os.environ['ac_cv_func_posix_getpwuid_r'] = 'yes'
    os.environ['ac_cv_func_register_printf_specifier'] = 'no'
    os.environ['ac_cv_func_register_printf_function'] = 'no'

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:
    os.environ['CPPFLAGS'] += ' -isysroot %s' % (isysroot)
    os.environ['CFLAGS'] += ' -isysroot %s' % (isysroot)
    os.environ['CXXFLAGS'] += ' -isysroot %s' % (isysroot)
    os.environ['OBJCFLAGS'] += ' -isysroot %s' % (isysroot)

if sysroot is not None:
    os.environ['CPPFLAGS'] += ' --sysroot=%s' % (sysroot)
    os.environ['CFLAGS'] += ' --sysroot=%s' % (sysroot)
    os.environ['CXXFLAGS'] += ' --sysroot=%s' % (sysroot)
    os.environ['OBJCFLAGS'] += ' --sysroot=%s' % (sysroot)
    os.environ['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 = ''
if target_arch != arch:
    workaround_cflags = ' -Wl,-rpath-link=%s/lib ' % (prefix)
    # Disable gi if we are cross-compiling
    if 'gi' in variants:
        variants.remove('gi')

os.environ['CFLAGS'] += ' -Wall -g -O2' + arch_flags + workaround_cflags
os.environ['CXXFLAGS'] += ' -Wall -g -O2' + arch_flags
os.environ['OBJCFLAGS'] += ' -Wall -g -O2' + arch_flags
os.environ['CCASFLAGS'] += ' -Wall -g -O2' + arch_flags
os.environ['LDFLAGS'] += arch_flags
os.environ['am_cv_python_pyexecdir'] = '%s/%s/site-packages' % (prefix, py_prefix)
os.environ['am_cv_python_pythondir'] = '%s/%s/site-packages' % (prefix, py_prefix)

def cmd(command):
    return '%s%s' % (tools_prefix, command)

os.environ['CC']= cmd('gcc')
os.environ['CXX']= cmd('g++')
os.environ['LD']= cmd('ld')
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')

if use_ccache:
    comp = os.environ.get('CC', 'gcc')
    if not 'ccache' in comp:
        os.environ['CC'] = 'ccache ' + comp
    comp = os.environ.get('CXX', 'g++')
    if not 'ccache' in comp:
        os.environ['CXX'] = 'ccache ' + comp