~ubuntu-branches/ubuntu/wily/xmms2/wily

1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
1
# encoding: utf-8
2
#
3
# WAF build scripts for XMMS2
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
4
# Copyright (C) 2006-2009 XMMS2 Team
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
5
#
6
7
import sys
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
8
if sys.version_info < (2,4):
9
    raise RuntimeError("Python 2.4 or newer is required")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
10
11
import os
12
import optparse
13
14
# Waf removes the current dir from the python path. We readd it to
15
# import waftools stuff.
16
sys.path.insert(0,os.getcwd())
17
18
from waftools import gittools
19
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
20
import Options
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
21
import Utils
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
22
import Build
23
import Configure
24
from logging import fatal, warning
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
25
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
26
BASEVERSION="0.6 DrMattDestruction"
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
27
APPNAME='xmms2'
28
29
srcdir='.'
30
blddir = '_build_'
31
32
####
33
## Initialization
34
####
35
def init():
36
    import gc
37
    gc.disable()
38
39
subdirs = """
40
          src/lib/xmmstypes
41
          src/lib/xmmssocket
42
          src/lib/xmmsipc
43
          src/lib/xmmsutils
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
44
          src/lib/xmmsvisualization
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
45
          src/clients/lib/xmmsclient
46
          src/clients/lib/xmmsclient-glib
47
          src/include
48
          src/includepriv
49
          """.split()
50
51
optional_subdirs = ["src/clients/cli",
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
52
                    "src/clients/nycli",
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
53
                    "src/clients/launcher",
54
                    "src/clients/et",
55
                    "src/clients/mdns/dns_sd",
56
                    "src/clients/mdns/avahi",
57
                    "src/clients/medialib-updater",
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
58
                    "src/clients/vistest",
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
59
                    "src/clients/lib/xmmsclient-ecore",
60
                    "src/clients/lib/xmmsclient++",
61
                    "src/clients/lib/xmmsclient++-glib",
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
62
                    "src/clients/lib/xmmsclient-cf",
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
63
                    "src/clients/lib/python",
64
                    "src/clients/lib/perl",
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
65
                    "src/clients/lib/ruby",
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
66
                    "tests",
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
67
                    "pixmaps"]
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
68
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
69
def is_plugin(x):
70
    return os.path.exists(os.path.join("src/plugins", x, "wscript"))
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
71
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
72
all_optionals = set(os.path.basename(o) for o in optional_subdirs)
73
all_plugins = set(p for p in os.listdir("src/plugins") if is_plugin(p))
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
74
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
75
####
76
## Build
77
####
78
def build(bld):
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
79
    if bld.env["BUILD_XMMS2D"]:
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
80
        subdirs.append("src/xmms")
81
82
    newest = max([os.stat(os.path.join(sd, "wscript")).st_mtime for sd in subdirs])
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
83
    if bld.env['NEWEST_WSCRIPT_SUBDIR'] and newest > bld.env['NEWEST_WSCRIPT_SUBDIR']:
84
        fatal("You need to run waf configure")
85
        raise SystemExit
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
86
87
    # Process subfolders
88
    bld.add_subdirs(subdirs)
89
90
    # Build configured plugins
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
91
    plugins = bld.env['XMMS_PLUGINS_ENABLED']
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
92
    bld.add_subdirs(["src/plugins/%s" % plugin for plugin in plugins])
93
94
    # Build the clients
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
95
    bld.add_subdirs(bld.env['XMMS_OPTIONAL_BUILD'])
96
97
    for name, lib in bld.env['XMMS_PKGCONF_FILES']:
98
        obj = bld.new_task_gen('subst')
99
        obj.source = 'xmms2.pc.in'
100
        obj.target = name + '.pc'
101
        obj.dict = {
102
               'NAME': name,
103
                'LIB': lib,
104
             'PREFIX': bld.env['PREFIX'],
105
             'BINDIR': os.path.join("${prefix}", "bin"),
106
             'LIBDIR': os.path.join("${prefix}", "lib"),
107
         'INCLUDEDIR': os.path.join("${prefix}", "include", "xmms2"),
108
            'VERSION': bld.env["VERSION"],
109
        }
110
        obj.install_path = '${PKGCONFIGDIR}'
111
112
    bld.install_files('${SHAREDDIR}', 'mind.in.a.box-lament_snipplet.ogg')
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
113
114
115
####
116
## Configuration
117
####
118
def _configure_optionals(conf):
119
    """Process the optional xmms2 subprojects"""
120
    def _check_exist(optionals, msg):
121
        unknown_optionals = optionals.difference(all_optionals)
122
        if unknown_optionals:
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
123
            fatal(msg % {'unknown_optionals': ', '.join(unknown_optionals)})
124
            raise SystemExit(1)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
125
        return optionals
126
127
    conf.env['XMMS_OPTIONAL_BUILD'] = []
128
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
129
    if Options.options.enable_optionals != None:
130
        selected_optionals = _check_exist(set(Options.options.enable_optionals),
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
131
                                           "The following optional(s) were requested, "
132
                                           "but don't exist: %(unknown_optionals)s")
133
        optionals_must_work = True
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
134
    elif Options.options.disable_optionals != None:
135
        disabled_optionals = _check_exist(set(Options.options.disable_optionals),
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
136
                                          "The following optional(s) were disabled, "
137
                                          "but don't exist: %(unknown_optionals)s")
138
        selected_optionals = all_optionals.difference(disabled_optionals)
139
        optionals_must_work = False
140
    else:
141
        selected_optionals = all_optionals
142
        optionals_must_work = False
143
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
144
    failed_optionals = set()
145
    succeeded_optionals = set()
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
146
147
    for o in selected_optionals:
148
        x = [x for x in optional_subdirs if os.path.basename(x) == o][0]
149
        if conf.sub_config(x):
150
            conf.env.append_value('XMMS_OPTIONAL_BUILD', x)
151
            succeeded_optionals.add(o)
152
        else:
153
            failed_optionals.add(o)
154
155
    if optionals_must_work and failed_optionals:
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
156
        fatal("The following required optional(s) failed to configure: "
157
              "%s" % ', '.join(failed_optionals))
158
        raise SystemExit(1)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
159
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
160
    disabled_optionals = set(all_optionals)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
161
    disabled_optionals.difference_update(succeeded_optionals)
162
163
    return succeeded_optionals, disabled_optionals
164
165
def _configure_plugins(conf):
166
    """Process all xmms2d plugins"""
167
    def _check_exist(plugins, msg):
168
        unknown_plugins = plugins.difference(all_plugins)
169
        if unknown_plugins:
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
170
            fatal(msg % {'unknown_plugins': ', '.join(unknown_plugins)})
171
            raise SystemExit(1)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
172
        return plugins
173
174
    conf.env['XMMS_PLUGINS_ENABLED'] = []
175
176
    # If an explicit list was provided, only try to process that
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
177
    if Options.options.enable_plugins != None:
178
        selected_plugins = _check_exist(set(Options.options.enable_plugins),
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
179
                                        "The following plugin(s) were requested, "
180
                                        "but don't exist: %(unknown_plugins)s")
181
        disabled_plugins = all_plugins.difference(selected_plugins)
182
        plugins_must_work = True
183
    # If a disable list was provided, we try all plugins except for those.
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
184
    elif Options.options.disable_plugins != None:
185
        disabled_plugins = _check_exist(set(Options.options.disable_plugins),
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
186
                                        "The following plugins(s) were disabled, "
187
                                        "but don't exist: %(unknown_plugins)s")
188
        selected_plugins = all_plugins.difference(disabled_plugins)
189
        plugins_must_work = False
190
    # If we don't have the daemon we don't build plugins.
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
191
    elif Options.options.without_xmms2d:
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
192
        disabled_plugins = all_plugins
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
193
        selected_plugins = set()
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
194
        plugins_must_work = False
195
    # Else, we try all plugins.
196
    else:
197
        selected_plugins = all_plugins
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
198
        disabled_plugins = set()
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
199
        plugins_must_work = False
200
201
202
    for plugin in selected_plugins:
203
        conf.sub_config("src/plugins/%s" % plugin)
204
        if (not conf.env["XMMS_PLUGINS_ENABLED"] or
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
205
            (len(conf.env["XMMS_PLUGINS_ENABLED"]) > 0 and
206
            conf.env['XMMS_PLUGINS_ENABLED'][-1] != plugin)):
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
207
            disabled_plugins.add(plugin)
208
209
    # If something failed and we don't tolerate failure...
210
    if plugins_must_work:
211
        broken_plugins = selected_plugins.intersection(disabled_plugins)
212
        if broken_plugins:
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
213
            fatal("The following required plugin(s) failed to configure: "
214
                  "%s" % ', '.join(broken_plugins))
215
            raise SystemExit(1)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
216
217
    return conf.env['XMMS_PLUGINS_ENABLED'], disabled_plugins
218
219
def _output_summary(enabled_plugins, disabled_plugins,
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
220
                    enabled_optionals, disabled_optionals,
221
                    output_plugins):
222
    print("\nOptional configuration:\n======================")
223
    sys.stdout.write("Enabled: ")
224
    Utils.pprint('BLUE', ', '.join(sorted(enabled_optionals)))
225
    sys.stdout.write("Disabled: ")
226
    Utils.pprint('BLUE', ", ".join(sorted(disabled_optionals)))
227
    print("\nPlugins configuration:\n======================")
228
229
    enabled_plugins = [x for x in enabled_plugins if x not in output_plugins]
230
231
    print("Output:")
232
    Utils.pprint('BLUE', ", ".join(sorted(output_plugins)))
233
    print("XForm/Other:")
234
    Utils.pprint('BLUE', ", ".join(sorted(enabled_plugins)))
235
    print("Disabled:")
236
    Utils.pprint('BLUE', ", ".join(sorted(disabled_plugins)))
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
237
238
def configure(conf):
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
239
    if os.environ.has_key('PKG_CONFIG_PREFIX'):
240
        prefix = os.environ['PKG_CONFIG_PREFIX']
241
        if not os.path.isabs(prefix):
242
            prefix = os.path.abspath(prefix)
243
        conf.env['PKG_CONFIG_DEFINES'] = {'prefix':prefix}
244
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
245
    conf.env["BUILD_XMMS2D"] = False
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
246
    if not Options.options.without_xmms2d == True:
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
247
        conf.env["BUILD_XMMS2D"] = True
248
        subdirs.insert(0, "src/xmms")
249
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
250
    if Options.options.manualdir:
251
        conf.env["MANDIR"] = Options.options.manualdir
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
252
    else:
253
        conf.env["MANDIR"] = os.path.join(conf.env["PREFIX"], "share", "man")
254
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
255
    conf.check_tool('man', tooldir=os.path.abspath('waftools'))
256
    conf.check_tool('misc')
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
257
    conf.check_tool('gcc')
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
258
    conf.check_tool('g++')
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
259
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
260
    try:
261
        conf.check_tool('winres')
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
262
        conf.env['WINRCFLAGS'] = '-I' + os.path.abspath('pixmaps')
263
        conf.env['xmms_icon'] = True
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
264
    except Configure.ConfigurationError:
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
265
        conf.env['xmms_icon'] = False
266
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
267
    if Options.options.target_platform:
268
        Options.platform = Options.options.target_platform
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
269
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
270
    nam,changed = gittools.get_info()
271
    conf.check_message("git commit id", "", True, nam)
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
272
    if Options.options.customversion:
273
        conf.env["VERSION"] = BASEVERSION + " (%s + %s)" % (nam, Options.options.customversion)
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
274
    else:
275
        dirty=""
276
        if changed:
277
            dirty="-dirty"
278
        conf.check_message("uncommitted changes", "", bool(changed))
279
        conf.env["VERSION"] = BASEVERSION + " (git commit: %s%s)" % (nam, dirty)
280
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
281
    conf.env["CCFLAGS"] = Utils.to_list(conf.env["CCFLAGS"]) + ['-g', '-O0']
282
    conf.env["CXXFLAGS"] = Utils.to_list(conf.env["CXXFLAGS"]) + ['-g', '-O0']
283
    conf.env['XMMS_PKGCONF_FILES'] = []
284
    conf.env['XMMS_OUTPUT_PLUGINS'] = [(-1, "NONE")]
285
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
286
    if Options.options.bindir:
287
        conf.env["BINDIR"] = Options.options.bindir
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
288
    else:
289
        conf.env["BINDIR"] = os.path.join(conf.env["PREFIX"], "bin")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
290
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
291
    if Options.options.libdir:
292
        conf.env["LIBDIR"] = Options.options.libdir
293
    else:
294
        conf.env["LIBDIR"] = os.path.join(conf.env["PREFIX"], "lib")
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
295
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
296
    if Options.options.pkgconfigdir:
297
        conf.env['PKGCONFIGDIR'] = Options.options.pkgconfigdir
298
        print(conf.env['PKGCONFIGDIR'])
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
299
    else:
300
        conf.env['PKGCONFIGDIR'] = os.path.join(conf.env["PREFIX"], "lib", "pkgconfig")
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
301
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
302
    if Options.options.config_prefix:
303
        for dir in Options.options.config_prefix:
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
304
            if not os.path.isabs(dir):
305
                dir = os.path.abspath(dir)
306
            conf.env.prepend_value("LIBPATH", os.path.join(dir, "lib"))
307
            conf.env.prepend_value("CPPPATH", os.path.join(dir, "include"))
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
308
309
    # Our static libraries may link to dynamic libraries
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
310
    if Options.platform != 'win32':
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
311
        conf.env["staticlib_CCFLAGS"] += ['-fPIC', '-DPIC']
312
    else:
313
        # As we have to change target platform after the tools
314
        # have been loaded there are a few variables that needs
315
        # to be initiated if building for win32.
316
317
        # Make sure we don't have -fPIC and/or -DPIC in our CCFLAGS
318
        conf.env["shlib_CCFLAGS"] = []
319
320
        # Setup various prefixes
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
321
        conf.env["shlib_PATTERN"] = 'lib%s.dll'
322
        conf.env['program_PATTERN'] = '%s.exe'
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
323
324
    # Add some specific OSX things
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
325
    if Options.platform == 'darwin':
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
326
        conf.env["LINKFLAGS"] += ['-multiply_defined suppress']
327
        conf.env["explicit_install_name"] = True
328
    else:
329
        conf.env["explicit_install_name"] = False
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
330
331
    # Check for support for the generic platform
332
    has_platform_support = os.name in ('nt', 'posix')
333
    conf.check_message("platform code for", os.name, has_platform_support)
334
    if not has_platform_support:
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
335
        fatal("xmms2 only has platform support for Windows "
336
              "and POSIX operating systems.")
337
        raise SystemExit(1)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
338
339
    # Check sunOS socket support
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
340
    if Options.platform == 'sunos':
341
        conf.check_cc(function_name='socket', lib='socket', header_name='sys/socket.h', uselib_store='socket')
342
        if not conf.env["HAVE_SOCKET"]:
343
            fatal("xmms2 requires libsocket on Solaris.")
344
            raise SystemExit(1)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
345
        conf.env.append_unique('CCFLAGS', '-D_POSIX_PTHREAD_SEMANTICS')
346
        conf.env.append_unique('CCFLAGS', '-D_REENTRANT')
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
347
        conf.env.append_unique('CCFLAGS', '-std=gnu99')
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
348
        conf.env['socket_impl'] = 'socket'
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
349
    # Check win32 (winsock2) socket support
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
350
    elif Options.platform == 'win32':
351
        if Options.options.winver:
352
            major, minor = [int(x) for x in Options.options.winver.split('.')]
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
353
        else:
354
            try:
355
                major, minor = sys.getwindowsversion()[:2]
356
            except AttributeError, e:
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
357
                warning('No Windows version found and no version set. ' +
358
                        'Defaulting to 5.1 (XP). You will not be able ' +
359
                        'to use this build of XMMS2 on older Windows ' +
360
                        'versions.')
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
361
                major, minor = (5, 1)
362
        need_wspiapi = True
363
        if (major >= 5 and minor >= 1):
364
            need_wspiapi = False
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
365
366
        conf.check_cc(lib="wsock32", uselib_store="socket", mandatory=1)
367
        conf.check_cc(lib="ws2_32", uselib_store="socket", mandatory=1)
368
        conf.check_cc(header_name="windows.h", uselib="socket", mandatory=1)
369
        conf.check_cc(header_name="ws2tcpip.h", uselib="socket", mandatory=1)
370
        conf.check_cc(header_name="winsock2.h", uselib="socket", mandatory=1)
371
        code = """
372
            #include <ws2tcpip.h>
373
            #include <wspiapi.h>
374
375
            int main() {
376
                return 0;
377
            }
378
        """
379
        if not conf.check_cc(header_name="wspiapi.h", fragment=code,
380
                             uselib="socket", mandatory=need_wspiapi):
381
            warning('This XMMS2 will only run on Windows XP and newer ' +
382
                    'machines. If you are planning to use XMMS2 on older ' +
383
                    'versions of Windows or are packaging a binary, please ' +
384
                    'consider installing the WSPiApi.h header for ' +
385
                    'compatibility. It is provided by the Platform SDK.')
386
387
        conf.env['CCDEFINES_socket'] += [
388
            '_WIN32_WINNT=0x%02x%02x' % (major, minor),
389
            'HAVE_WINSOCK2', 1
390
        ]
391
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
392
        conf.env['socket_impl'] = 'wsock32'
393
    # Default POSIX sockets
394
    else:
395
        conf.env['socket_impl'] = 'posix'
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
396
397
    # Glib is required by everyone, so check for it here and let them
398
    # assume its presence.
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
399
    conf.check_cfg(package='glib-2.0', atleast_version='2.8.0', uselib_store='glib2', args='--cflags --libs', mandatory=1)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
400
401
    enabled_plugins, disabled_plugins = _configure_plugins(conf)
402
    enabled_optionals, disabled_optionals = _configure_optionals(conf)
403
404
    newest = max([os.stat(os.path.join(sd, "wscript")).st_mtime for sd in subdirs])
405
    conf.env['NEWEST_WSCRIPT_SUBDIR'] = newest
406
407
    [conf.sub_config(s) for s in subdirs]
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
408
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
409
    output_plugins = [name for x,name in conf.env["XMMS_OUTPUT_PLUGINS"] if x > 0]
410
411
    _output_summary(enabled_plugins, disabled_plugins,
412
                    enabled_optionals, disabled_optionals,
413
                    output_plugins)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
414
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
415
    return True
416
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
417
418
####
419
## Options
420
####
421
def _list_cb(option, opt, value, parser):
422
    """Callback that lets you specify lists of targets."""
423
    vals = value.split(',')
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
424
    if vals == ['']:
425
        vals = []
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
426
    if getattr(parser.values, option.dest):
427
        vals += getattr(parser.values, option.dest)
428
    setattr(parser.values, option.dest, vals)
429
430
def set_options(opt):
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
431
    opt.add_option('--prefix', default=Options.default_prefix, dest='prefix',
432
                   help="installation prefix (configuration only) [Default: '%s']" % Options.default_prefix)
433
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
434
    opt.tool_options('gcc')
1.2.1 by Florian Ragwitz
Import upstream version 0.5DrLecter
435
436
    opt.add_option('--with-custom-version', type='string',
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
437
                   dest='customversion', help="Override git commit hash version")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
438
    opt.add_option('--with-plugins', action="callback", callback=_list_cb,
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
439
                   type="string", dest="enable_plugins", default=None,
440
                   help="Comma separated list of plugins to build")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
441
    opt.add_option('--without-plugins', action="callback", callback=_list_cb,
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
442
                   type="string", dest="disable_plugins", default=None,
443
                   help="Comma separated list of plugins to skip")
444
    opt.add_option('--with-default-output-plugin', type='string',
445
                   dest='default_output_plugin',
446
                   help="Force a default output plugin")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
447
    opt.add_option('--with-optionals', action="callback", callback=_list_cb,
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
448
                   type="string", dest="enable_optionals", default=None,
449
                   help="Comma separated list of optionals to build")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
450
    opt.add_option('--without-optionals', action="callback", callback=_list_cb,
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
451
                   type="string", dest="disable_optionals", default=None,
452
                   help="Comma separated list of optionals to skip")
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
453
    opt.add_option('--conf-prefix', action="callback", callback=_list_cb,
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
454
                   type='string', dest='config_prefix',
455
                   help="Specify a directory to prepend to configuration prefix")
456
    opt.add_option('--without-xmms2d', action='store_true', default=False,
457
                   dest='without_xmms2d', help="Skip build of xmms2d")
458
    opt.add_option('--with-mandir', type='string', dest='manualdir',
459
                   help="Specify directory where to install man pages")
460
    opt.add_option('--with-bindir', type='string', dest='bindir',
461
                   help="Specify directory where to install executables")
462
    opt.add_option('--with-libdir', type='string', dest='libdir',
463
                   help="Specify directory where to install libraries")
464
    opt.add_option('--with-pkgconfigdir', type='string', dest='pkgconfigdir',
465
                   help="Specify directory where to install pkg-config files")
1.1.4 by Benjamin Drung
Import upstream version 0.4DrKosmos
466
    opt.add_option('--with-target-platform', type='string',
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
467
                   dest='target_platform',
468
                   help="Force a target platform (cross-compilation)")
469
    opt.add_option('--with-windows-version', type='string', dest='winver',
470
                   help="Force a specific Windows version (cross-compilation)")
471
    opt.add_option('--run-tests', action='store_true', default=False,
472
                   dest='run_tests', help="Run test suite")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
473
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
474
    opt.sub_options("src/xmms")
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
475
    for o in optional_subdirs + subdirs:
476
        opt.sub_options(o)
477
478
def shutdown():
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
479
    if Options.commands['install'] and os.geteuid() == 0:
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
480
        ldconfig = '/sbin/ldconfig'
481
        if os.path.isfile(ldconfig):
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
482
            libprefix = Utils.subst_vars('${PREFIX}/lib', Build.bld.env)
483
            try: Utils.cmd_output(ldconfig + ' ' + libprefix)
1.1.3 by Zak B. Elep
Import upstream version 0.2DrJekyll
484
            except: pass
1.2.2 by Florian Ragwitz
Import upstream version 0.6DrMattDestruction
485
486
    if Options.options.run_tests:
487
        os.system(os.path.join(os.getenv('WAF_HOME'), "default/tests/test_xmmstypes"))