-
Notifications
You must be signed in to change notification settings - Fork 28
/
jhbuildrc-gtk-osx
338 lines (283 loc) · 11.5 KB
/
jhbuildrc-gtk-osx
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# -*- mode: python -*-
#
# Copyright (C) 2006, 2007, 2008 Imendio AB
#
# 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.
#
# Specific builds can be set up by creating files named
# ~/.jhbuildrc-<build>. When setting the environment variable JHB to
# such a name, the corresponding rc file will be read (e.g.:
# JHB=mybuild jhbuild shell).
#
# Use .jhbuildrc-custom to override the moduleset, modules to build,
# the source checkout location, installation prefix, or svn usernames
# etc.
#
# Please email [email protected] if you have suggestions for
# improving this setup, or have any patches that you would like to get
# included.
import sys
import errno
# Register an extra command to get the checkout dir for a module.
#
import jhbuild
class _cmd_get_srcdir(jhbuild.commands.Command):
doc = 'Display information about one or more modules'
from jhbuild.errors import FatalError
name = 'gtk-osx-get-srcdir'
usage_args = 'module'
def run(self, config, options, args):
module_set = jhbuild.moduleset.load(config)
if args:
modname = args[0]
try:
module = module_set.get_module(modname, ignore_case = True)
except KeyError:
raise FatalError(_('unknown module %s') % modname)
print module.get_srcdir(None)
else:
raise FatalError('no module specified')
jhbuild.commands.register_command(_cmd_get_srcdir)
# Some utitily 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 parse_custom_argument(key):
for i, arg in enumerate(sys.argv[:-1]):
if arg == key:
return sys.argv[i+1]
return None
def set_branch(module, branch):
# Keep any overriden repo name here to keep custom usernames set
# up in a custom setup.
#
repo = repos.get("svn.gnome.org", "http://svn.gnome.org/svn")
if repo.endswith("/"):
repo = repo[:-1]
branches[module] = repo + "/" + module + "/" + branch
def append_autogenargs(module, args):
old_value = module_autogenargs.get(module, autogenargs)
module_autogenargs[module] = old_value + " " + args
# Set up the environment for building against 10.4 SDK.
#
def setup_sdk_10_4():
target = "10.4"
sdk = "MacOSX10.4u.sdk"
sdkdir = os.path.join("/Developer/SDKs", sdk)
# To pick up cups-config from the right place. NOTE: Change this as
# soon as GTK+ is fixed, and only set CUPS_CONFIG instead (GTK+ 2.13
# is fixed).
#
prependpath("PATH", os.path.join(sdkdir, "usr/bin"))
os.environ["MACOSX_DEPLOYMENT_TARGET"] = target
# Seems like we need this since many libraries otherwise only look for
# various dependencies (e.g. libiconv) in /usr/lib, hence pulling in
# the wrong -L that doesn't have fat binaries on pre-10.5.
#
environ_prepend("LDFLAGS", "-L" + sdkdir + "/usr/lib")
environ_prepend("CPPFLAGS", "-I" + sdkdir + "/usr/include")
# It looks like -isysroot is broken on 10.4, causing link
# problems. But we don't really need to set it for 10.4 so just
# skip that.
#
if not _osx_version.startswith("8."):
environ_append("CFLAGS", "-isysroot " + sdkdir)
environ_append("CXXFLAGS", "-isysroot " + sdkdir)
environ_append("LDFLAGS", "-isysroot " + sdkdir)
environ_append("CFLAGS", "-mmacosx-version-min=" + target)
environ_append("LDFLAGS", "-mmacosx-version-min=" + target)
return sdkdir
def autogenargs_for_arch(root, arch, original_cflags, original_cxxflags, original_ldflags):
if root is not None and not _osx_version.startswith("8."):
rootstr = " -isysroot " + root
else:
rootstr = ""
archstr = " -arch " + arch
return \
'CFLAGS="' + original_cflags + rootstr + archstr + '" ' + \
'CXXFLAGS="' + original_cxxflags + rootstr + archstr + '" ' + \
'LDFLAGS="' + original_ldflags + archstr + '"'
_osx_version = os.popen("uname -r").read().strip()
# Moduleset to use.
#
moduleset = 'gtk-osx'
use_local_modulesets = True
# A list of the modules to build.
#
modules = [ 'meta-gtk-osx-core' ]
# A list of modules to skip.
#
skip.append('gmp')
skip.append('guile')
# Source and installation locations.
#
_root = os.path.expanduser("~/gtk")
checkoutroot = os.path.join(_root, "source")
prefix = os.path.join(_root, "inst")
# Extra arguments to pass to all autogen.sh scripts.
#
autogenargs='--disable-static --disable-gtk-doc --disable-docs --disable-scrollkeeper'
alwaysautogen = True
# Set debugging format to the old one from Tiger and earlier since the
# new default in Leopard breaks many things. Also set gnu89 as the new
# default gnu99 changes how extern inline works, breaking, glib's
# inline setup, until glib is fixed. FIXME: Make it possible to
# override the optimization flag and also don't overwrite any user set
# CFLAGS/CXXFLAGS.
#
os.environ['CFLAGS'] = "-O2 -gstabs+3 -std=gnu89"
os.environ['CXXFLAGS'] = "-O2 -gstabs+3"
# 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('~/bin/install-check')
if os.path.exists(_path):
os.environ['INSTALL'] = _path
# When building on intel, force build to be 486, since glib won't
# enable asm atomic operations otherwise.
#
try:
_f = os.popen("uname -p")
if _f.read().startswith("i386"):
append_autogenargs("glib", "--build=i486-apple-darwin")
except:
pass
# Prefix to use in the shell, can be overridden in the custom rc file
# or in specific setups. Can be set to None to be removed.
#
_gtk_osx_prompt_prefix = "JH"
_gtk_osx_default_build = ""
if _osx_version.startswith("7."):
print "Error: Mac OS X 10.4 or newer is required, exiting."
raise SystemExit
elif _osx_version.startswith("8."):
# Tiger, we want to use the python version from jhbuild.
_gtk_osx_use_jhbuild_python = True
else:
# Leopard or newer.
_gtk_osx_use_jhbuild_python = False
# 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)
# Allow including different variants depending on the environment
# variable JHB. This can be used to have different setups for SDK
# builds, for example.
#
_build = os.environ.get('JHB', _gtk_osx_default_build)
# Check and warn if jhbuild is started from within jhbuild, since that
# will mess up environment variables, especially if different build
# setups are used.
#
_old_prefix = os.environ.get('JHBUILD_PREFIX', "")
_old_build = os.environ.get('JHBUILD_CONFIG', "")
_ran_recursively = _old_prefix != ""
if _ran_recursively:
if _old_build != _build:
print "Error: jhbuild is already running with a different build setup, exiting."
raise SystemExit
print "Warning: jhbuild is started from within a jhbuild session."
if _build != "":
try:
execfile(os.path.join(os.environ['HOME'], '.jhbuildrc-' + _build))
except EnvironmentError, e:
print "Couldn't find the file '.jhbuildrc-" + _build + "', exiting."
raise SystemExit
tarballdir = os.path.join(checkoutroot, 'pkgs')
os.environ['PREFIX'] = prefix # Deprecated, please move to JHBUILD_PREFIX.
os.environ['JHBUILD_PREFIX'] = prefix
os.environ['JHBUILD_SOURCE'] = checkoutroot
os.environ['LIBTOOLIZE'] = prefix + '/bin/libtoolize'
# By default, we want the system perl and python, not from macports or
# so.
#
os.environ["PERL"] = "/usr/bin/perl"
os.environ["INTLTOOL_PERL"] = "/usr/bin/perl"
if not _gtk_osx_use_jhbuild_python:
skip.append('python')
if os.environ.get("PYTHON", "") == "":
os.environ["PYTHON"] = "/usr/bin/python"
else:
os.environ["PYTHON"] = prefix + "/bin/python"
# Use libxml/libxslt from the system. Append to the pkg-config path to
# get the system versions picked up.
#
skip.append("libxml2")
skip.append("libxslt")
addpath("PKG_CONFIG_PATH", "/usr/lib/pkgconfig")
# 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 find our installed modules, and before other versions.
environ_prepend('LDFLAGS', '-L' + prefix + '/lib')
environ_prepend('CPPFLAGS', '-I' + prefix + '/include')
# Add additional Python/Perl paths so that our modules can be found.
#
_version = 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1])
prependpath('PYTHONPATH', prefix + '/lib/' + _version + '/site-packages/gtk-2.0')
prependpath('PERL5LIB', prefix + '/lib/perl5/vendor_perl')
prependpath('PERL5LIB', prefix + '/lib/perl5/site_perl')
# Point gtk-doc and other xlstproc users to our XML catalog.
#
os.environ['XML_CATALOG_FILES'] = prefix + '/etc/xml/catalog'
# Speed up gettext build by disabling unneeded stuff.
#
append_autogenargs("gettext", "--without-emacs --disable-java --disable-native-java --disable-libasprintf --disable-csharp")
# Support prepending frameworks to the setup so they are picked up
# instead of things from the prefix or /usr.
#
_frameworks = os.environ.get("JHB_PREPEND_FRAMEWORKS", "")
for _framework in _frameworks.split(":"):
if _framework != "" and os.path.exists(_framework):
# Use prependpath to ensure our paths are added in front of
# the ones jhbuild sets up.
if os.path.exists(_framework + "/Headers"):
prependpath("C_INCLUDE_PATH", _framework + "/Headers")
prependpath("CPLUS_INCLUDE_PATH", _framework + "/Headers")
if os.path.exists(_framework + "/Resources/dev/bin"):
prependpath("PATH", _framework + "/Resources/dev/bin")
if os.path.exists(_framework + "/Resources/dev/lib/pkgconfig"):
prependpath("PKG_CONFIG_PATH", _framework + "/Resources/dev/lib/pkgconfig")
if os.path.exists(_framework + "/Resources/dev/lib"):
# FIXME: Need fix in jhbuild for this to work:
#prependpath("LDFLAGS", "-L" + _framework + "/Resources/dev/lib")
environ_prepend("LDFLAGS", "-L" + _framework + "/Resources/dev/lib", " ")
if os.path.exists(_framework + "/Resources/dev/share/aclocal"):
prependpath("ACLOCAL_FLAGS", _framework + "/Resources/dev/share/aclocal")
# We do some crude extra argument parsing just to add support for
# getting environment variables. Used in framework creation to pick up
# the jhbuild prefix.
#
_value = parse_custom_argument("getenv")
if _value:
print os.environ.get(_value, "")
raise SystemExit
if _build:
if "shell" in sys.argv:
print "Build setup: %s, prefix: %s" % (_build, prefix)
os.environ["JHBUILD_CONFIG"] = _build
else:
if "shell" in sys.argv:
print "Prefix: %s" % (prefix)
if not _ran_recursively and _gtk_osx_prompt_prefix:
os.environ["JHBUILD_PROMPT"] = "[" + _gtk_osx_prompt_prefix + "] "
# Unset this so we don't mess with the check for not starting
# recursively.
os.unsetenv("JHB")
if "shell" in sys.argv:
print "Entered jhbuild shell, type 'exit' to return."