-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjhbuildrc
301 lines (247 loc) · 11.2 KB
/
jhbuildrc
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# -*- mode: python -*-
#
# Copyright (C) 2006, 2007, 2008 Imendio AB
# Copyright 2009, 2010, 2011 John Ralls, Fremont, CA
# Copyright 2016 Philip Chimento
#
# Default setup for building GTK+ on Mac OS X. Note that you should
# normally never need to edit this file. Any custom settings should be
# done in ~/.jhbuildrc-custom.
import sys
import re
def _popen(cmd_arg):
from subprocess import Popen, PIPE
devnull = open('/dev/null')
cmd = Popen(cmd_arg, stdout=PIPE, stderr=devnull, shell=True)
retval = cmd.stdout.read().strip()
err = cmd.wait()
cmd.stdout.close()
devnull.close()
if err:
raise RuntimeError, 'Failed to close %s stream' % cmd_arg
return retval
# Determine the native system:
def osx_ver():
vstring = _popen('uname -r')
mstring = _popen('machine')
exp = re.compile(r'(\d+\.\d+)\.\d+')
vernum = exp.match(vstring)
return float(vernum.group(1)) - 4.0
# Determine the XCode Version:
def xcode_ver():
devdir = _popen('xcode-select -p')
if devdir != '/Library/Developer/CommandLineTools':
ver = _popen('xcodebuild -version')
exp = re.compile(r'Xcode (\d+\.\d+)')
vernum = exp.match(ver)
if vernum:
_xcode_ver = float(vernum.group(1))
if _xcode_ver < 5.0:
raise EnvironmentError('Xcode Version %f is not supported. Xcode 5.0 or later is required.' % _xcode_ver)
return _xcode_ver
raise EnvironmentError('No suitable Xcode found. Xcode 5.0 or later is required.')
else: # Command-Line Tools instead of Xcode
ver_str = _popen('pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version*')
exp = re.compile(r'version: (\d+\.\d+)')
vernum = exp.match(ver_str)
if vernum:
return float(vernum.group(1))
return 8.0
# Some utility functions used here and in custom files:
def environ_append(key, value, separator=' '):
old_value = os.environ.get(key)
if old_value is not None:
value = old_value + separator + value
os.environ[key] = value
def environ_prepend(key, value, separator=' '):
old_value = os.environ.get(key)
if old_value is not None:
value = value + separator + old_value
os.environ[key] = value
def environ_remove(key, value, separator=':'):
old_value = os.environ.get(key)
if old_value is not None:
old_value_split = old_value.split(separator)
value_split = [x for x in old_value_split if x != value]
value = separator.join(value_split)
os.environ[key] = value
def append_module_extra_env(module, var, value, separator=' '):
extra_env = module_extra_env.get(module, {})
old_value = extra_env.get(var, os.environ[var])
new_value = old_value + separator + value
extra_env[var] = new_value
module_extra_env[module] = extra_env
def append_autogenargs(module, args):
old_value = module_autogenargs.get(module, autogenargs)
module_autogenargs[module] = old_value + ' ' + args
def remove_autogenargs(module, args):
arg_string = module_autogenargs.get(module, autogenargs)
module_autogenargs[module] = arg_string.replace(args, '')
# Call either setup_debug or setup_release in your .jhbuildrc-custom
# or other customization file to get the compilation flags.
def setup_debug():
environ_prepend('CFLAGS', '-O0 -g')
environ_prepend('CXXFLAGS', '-O0 -g')
environ_prepend('OBJCFLAGS', '-O0 -g')
def setup_release():
environ_prepend('CFLAGS', '-O2')
environ_prepend('CXXFLAGS', '-O2')
environ_prepend('OBJCFLAGS', '-O2')
# Set up the environment for building against particular SDK.
# This is the workhorse of the setup. Call this function from
# .jhbuildrc-custom to configure compile and link flags. Optionally
# specify a minimum MacOS version (10.9, 10.10, 10.11, etc.)
#
# For most users accepting the defaults is the right course.
def setup_sdk(target=None):
xcodeversion = xcode_ver()
osx_version = osx_ver()
if target is None:
target = '10.%d' % osx_version
os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
sdkdir = _popen('xcrun --show-sdk-path')
if sdkdir:
sdk_includedir = os.path.join(sdkdir, 'usr', 'include')
sdk_libdir = os.path.join(sdkdir, 'usr', 'lib')
environ_prepend('LDFLAGS', '-L' + sdk_libdir)
environ_prepend('CFLAGS', '-I' + sdk_includedir)
environ_prepend('CXXFLAGS', '-I' + sdk_includedir)
environ_prepend('OBJCFLAGS', '-I' + sdk_includedir)
environ_prepend('CPPFLAGS', '-I' + sdk_includedir)
environ_prepend('CMAKE_PREFIX_PATH', os.path.join(sdkdir, 'usr'), ':')
environ_prepend('LIBRARY_PATH', sdk_libdir, ':')
# It's often necessary to look for things in the SDK when
# developing, and it takes a lot of typing, so define a
# convenience environment variable:
environ_append('SDKDIR', sdkdir)
environ_append('SDKROOT', sdkdir)
# Apple Documentation says that "-syslibroot" is the arg to pass to the
# linker, but we are using the compiler to control the linker, and
# everything seems to be working correctly.
environ_append('CFLAGS', '-isysroot ' + sdkdir)
environ_append('CPPFLAGS', '-isysroot ' + sdkdir)
environ_append('CXXFLAGS', '-isysroot ' + sdkdir)
environ_append('OBJCFLAGS', '-isysroot ' + sdkdir)
environ_append('LDFLAGS', '-isysroot ' + sdkdir)
# To pick up cups-config from the right place.
os.environ['CUPS_CONFIG'] = os.path.join(sdkdir, 'usr', 'bin', 'cups-config')
environ_append('CFLAGS', '-mmacosx-version-min=' + target)
environ_append('CXXFLAGS', '-mmacosx-version-min=' + target)
environ_append('OBJCFLAGS', '-mmacosx-version-min=' + target)
environ_append('LDFLAGS', '-mmacosx-version-min=' + target)
gcc = _popen('xcrun -f gcc')
gpp = _popen('xcrun -f g++')
ld = _popen('xcrun -f ld')
os.environ['CC'] = gcc
os.environ['OBJC'] = gcc
os.environ['CXX'] = gpp
os.environ['LD'] = ld
# El Capitan needs bash to work around SIP. If you're using a
# common bootstrap directory (e.g. $HOME/.local) then override
# CONFIG_SHELL in .jhbuildrc-custom after calling setup_sdk().
config_shell = os.path.join(prefix, 'bin', 'bash')
if osx_version < 11.0:
skip.append('bash')
elif os.path.exists(config_shell):
os.environ['CONFIG_SHELL'] = config_shell
if not sdkdir:
sdkdir = '/'
if os.path.exists(os.path.join(sdkdir, 'usr', 'include', 'openssl')):
skip.append('openssl') # openssl removed in El Capitan
# macOS ships libuuid, but no pkg-config file. Symbols are in libSystem, per
# http://lists.apple.com/archives/unix-porting/2009/Aug/msg00006.html
skip.append('libuuid')
os.environ['UUID_CFLAGS'] = '-I' + os.path.join(sdk_includedir, 'uuid')
os.environ['UUID_LIBS'] = '-lSystem'
return sdkdir
###### End Function Definitions #######
##### The following configuration can be overridden in custom files ######
# Check and warn if jhbuild is started from within jhbuild, since that
# will mess up environment variables, especially if different build
# setups are used.
if os.environ.get('JHBUILD_PREFIX', '') != '':
print 'Warning: jhbuild is started from within a jhbuild session.'
# Moduleset to use. You can override this in .jhbuildrc-custom or on
# the command line.
moduleset = [
'gnome-apps-3.24',
'macos-sysdeps',
'macos-overrides',
]
# A list of the modules to build. You can override this in
# .jhbuildrc-custom or on the command line.
modules = [ 'meta-gnome-extended-devel-platform' ]
# Use the included install-check program if available. It won't update
# timestamps if the header hasn't changed, which speeds up builds.
_path = os.path.expanduser('~/.local/bin/install-check')
if os.path.exists(_path):
os.environ['INSTALL'] = _path
conditions.add('64-bit')
# Modules that have new enough versions shipped with macOS >= 10.9
skip.append('m4')
# The option "headerpad_max_install_names" is there to leave some room for
# changing the library locations with install_name_tool. Note that GNU
# libtool seems to drop the option if we don't use -W here.
environ_append('LDFLAGS', '-Wl,-headerpad_max_install_names')
# Make sure we don't link against XQuartz whose freetype-config is on PATH
# when XQuartz is installed by removing it from PATH
environ_remove('PATH', '/opt/X11/bin')
# Glib has issues with endianness
append_autogenargs('glib', 'ac_cv_c_bigendian=no')
# Set glib's build parameter so that it builds the
# correct atomic asm functions
append_autogenargs('glib', '--build=x86_64-apple-darwin')
append_autogenargs('gmp', '--host=x86_64-apple-darwin ABI=64')
append_autogenargs('gnutls', '--host=x86_64-apple-darwin')
# Need to override the global autogenargs for libnettle, since otherwise
# --disable-static will be added after it
module_autogenargs['libnettle'] = '--enable-static'
# Berkeley DB version shipped with macOS has a different API; C++11 required
# because of linking to ICU; and the Vala bindings are just an e-d-s build
# bug, apparently.
module_cmakeargs['evolution-data-server'] = \
'-DWITH_LIBDB=NO -DENABLE_VALA_BINDINGS=OFF -DCMAKE_CXX_FLAGS="-std=c++11"'
# Built python doesn't have ssl, we need system Python to set up virtualenv
module_extra_env['mozjs38'] = {
'PYTHON': '/usr/bin/python2.7',
}
###### Import Customizations ######
# Import optional user RC for further customization. You can override
# the prefix or default build setup for example, or CFLAGS or
# module_autogenargs, etc.
#
_userrc = os.path.join(os.environ['HOME'], '.jhbuildrc-custom')
if os.path.exists(_userrc):
execfile(_userrc)
###### Everything Below Uses (and Overrides) customizations! #######
# Any changes to packages that affect environment variables, or make use of the
# "prefix", "checkoutroot", or "tarballdir" variables, must occur below here.
os.environ['JHBUILD_PREFIX'] = prefix
os.environ['JHBUILD_SOURCE'] = checkoutroot
_libdir = os.path.join(prefix, 'lib')
# Make sure we find our installed modules before other versions.
environ_prepend('LDFLAGS', '-L' + _libdir)
environ_prepend('CPPFLAGS', '-I' + prefix + '/include')
# Some autogens detect that it's a Mac and use glibtoolize if it's
# available. Override this behavior.
os.environ.setdefault('LIBTOOLIZE', os.path.join(prefix, 'bin', 'libtoolize'))
# Make sure that ltdl can find our libraries
addpath('LTDL_LIBRARY_PATH', _libdir)
# Not sure why this is not autodetected
append_module_extra_env('glade', 'CFLAGS', '-ObjC')
# openssl doesn't understand DESTDIR, but luckily it has its own mechanism.
module_extra_env['openssl'] = {
'INSTALL_PREFIX': os.path.join(prefix, '_jhbuild', 'root-openssl'),
}
# This is how to get cmake to set -install_name
cmakeargs += ' -DCMAKE_INSTALL_NAME_DIR=' + _libdir
# Find our docbook XML catalogs
os.environ['XML_CATALOG_FILES'] = os.path.join(prefix, 'share', 'xml',
'catalog')
# Overcome Python's obnoxious misconfiguration of portable builds
os.environ['BUILDCFLAGS'] = os.environ['CFLAGS']
# Finally when building normally we need to force CFLAGS_FOR_BUILD
# to our current CFLAGS so that everything will link with other
# build products. Note that this will generally break
# cross-compilation, not that it works anyway.
os.environ['CFLAGS_FOR_BUILD'] = os.environ['CFLAGS']