root/wscript @ bda0255efb0f775f9fb57dad383a75a6119da9a6

Revision bda0255efb0f775f9fb57dad383a75a6119da9a6, 13.3 KB (checked in by Nedko Arnaudov <nedko@…>, 3 years ago)

fix ticket 14, waf configure now fails if expat is not found

  • Property mode set to 100644
Line 
1#! /usr/bin/env python
2# encoding: utf-8
3
4import os
5import Options
6import Utils
7import shutil
8import re
9
10APPNAME='ladish'
11VERSION='0.2'
12DBUS_NAME_BASE = 'org.ladish'
13
14# these variables are mandatory ('/' are converted automatically)
15srcdir = '.'
16blddir = 'build'
17
18def display_msg(conf, msg="", status = None, color = None):
19    if status:
20        conf.check_message_1(msg)
21        conf.check_message_2(status, color)
22    else:
23        Utils.pprint('NORMAL', msg)
24
25def display_raw_text(conf, text, color = 'NORMAL'):
26    Utils.pprint(color, text, sep = '')
27
28def display_line(conf, text, color = 'NORMAL'):
29    Utils.pprint(color, text, sep = os.linesep)
30
31def yesno(bool):
32    if bool:
33        return "yes"
34    else:
35        return "no"
36
37def set_options(opt):
38    opt.tool_options('compiler_cc')
39    opt.tool_options('compiler_cxx')
40    opt.tool_options('boost')
41    opt.add_option('--enable-pkg-config-dbus-service-dir', action='store_true', default=False, help='force D-Bus service install dir to be one returned by pkg-config')
42    opt.add_option('--enable-liblash', action='store_true', default=False, help='Build LASH compatibility library')
43
44def add_cflag(conf, flag):
45    conf.env.append_unique('CXXFLAGS', flag)
46    conf.env.append_unique('CCFLAGS', flag)
47
48def configure(conf):
49    conf.check_tool('compiler_cc')
50    conf.check_tool('compiler_cxx')
51    conf.check_tool('boost')
52
53    conf.check_cfg(
54        package = 'dbus-1',
55        atleast_version = '1.0.0',
56        mandatory = True,
57        errmsg = "not installed, see http://dbus.freedesktop.org/",
58        args = '--cflags --libs')
59
60    dbus_dir = conf.check_cfg(package='dbus-1', args='--variable=session_bus_services_dir', msg="Retrieving D-Bus services dir")
61    if not dbus_dir:
62        return
63
64    dbus_dir = dbus_dir.strip()
65    conf.env['DBUS_SERVICES_DIR_REAL'] = dbus_dir
66
67    if Options.options.enable_pkg_config_dbus_service_dir:
68        conf.env['DBUS_SERVICES_DIR'] = dbus_dir
69    else:
70        conf.env['DBUS_SERVICES_DIR'] = os.path.join(os.path.normpath(conf.env['PREFIX']), 'share', 'dbus-1', 'services')
71
72    conf.env['BUILD_LIBLASH'] = Options.options.enable_liblash
73
74    conf.check_cfg(
75        package = 'uuid',
76        mandatory = True,
77        errmsg = "not installed, see http://e2fsprogs.sourceforge.net/",
78        args = '--cflags --libs')
79
80    conf.check(
81        header_name='expat.h',
82        mandatory = True,
83        errmsg = "not installed, see http://expat.sourceforge.net/")
84
85    conf.env['LIB_EXPAT'] = ['expat']
86
87    build_gui = True
88
89    if build_gui and not conf.check_cfg(
90        package = 'glib-2.0',
91        mandatory = False,
92        errmsg = "not installed, see http://www.gtk.org/",
93        args = '--cflags --libs'):
94        build_gui = False
95
96    if build_gui and not conf.check_cfg(
97        package = 'dbus-glib-1',
98        mandatory = False,
99        errmsg = "not installed, see http://dbus.freedesktop.org/",
100        args = '--cflags --libs'):
101        build_gui = False
102
103    if build_gui and not conf.check_cfg(
104        package = 'gtk+-2.0',
105        mandatory = False,
106        errmsg = "not installed, see http://www.gtk.org/",
107        args = '--cflags --libs'):
108        build_gui = False
109
110    if build_gui and not conf.check_cfg(
111        package = 'libglade-2.0',
112        mandatory = False,
113        errmsg = "not installed, see http://ftp.gnome.org/pub/GNOME/sources/libglade/",
114        args = '--cflags --libs'):
115        build_gui = False
116
117    if build_gui and not conf.check_cfg(
118        package = 'flowcanvas',
119        mandatory = False,
120        atleast_version = '0.5.3',
121        errmsg = "not installed, see http://drobilla.net/software/flowcanvas/",
122        args = '--cflags --libs'):
123        build_gui = False
124
125    if build_gui:
126        # We need the boost headers package (e.g. libboost-dev)
127        # shared_ptr.hpp and weak_ptr.hpp
128        build_gui = conf.check_boost(errmsg="not found, see http://boost.org/")
129
130    conf.env['BUILD_GLADISH'] = build_gui
131
132    add_cflag(conf, '-g')
133    add_cflag(conf, '-Wall')
134    add_cflag(conf, '-Werror')
135
136    conf.define('DATA_DIR', os.path.normpath(os.path.join(conf.env['PREFIX'], 'share', APPNAME)))
137    conf.define('PACKAGE_VERSION', VERSION)
138    conf.define('DBUS_NAME_BASE', DBUS_NAME_BASE)
139    conf.define('DBUS_BASE_PATH', '/' + DBUS_NAME_BASE.replace('.', '/'))
140    conf.define('BASE_NAME', APPNAME)
141    conf.define('_GNU_SOURCE', 1)
142    conf.write_config_header('config.h')
143
144    display_msg(conf)
145
146    display_msg(conf, "==================")
147    version_msg = APPNAME + "-" + VERSION
148
149    if os.access('version.h', os.R_OK):
150        data = file('version.h').read()
151        m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
152        if m != None:
153            version_msg += " exported from " + m.group(1)
154    elif os.access('.git', os.R_OK):
155        version_msg += " git revision will checked and eventually updated during build"
156
157    display_msg(conf, version_msg)
158
159    display_msg(conf)
160    display_msg(conf, "Install prefix", conf.env['PREFIX'], 'CYAN')
161
162    display_msg(conf, 'Build gladish', yesno(conf.env['BUILD_GLADISH']))
163    display_msg(conf, 'Build liblash', yesno(Options.options.enable_liblash))
164
165    if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
166        display_msg(conf)
167        display_line(conf,     "WARNING: D-Bus session services directory as reported by pkg-config is", 'RED')
168        display_raw_text(conf, "WARNING:", 'RED')
169        display_line(conf,      conf.env['DBUS_SERVICES_DIR_REAL'], 'CYAN')
170        display_line(conf,     'WARNING: but service file will be installed in', 'RED')
171        display_raw_text(conf, "WARNING:", 'RED')
172        display_line(conf,      conf.env['DBUS_SERVICES_DIR'], 'CYAN')
173        display_line(conf,     'WARNING: You may need to adjust your D-Bus configuration after installing ladish', 'RED')
174        display_line(conf,     'WARNING: You can override dbus service install directory', 'RED')
175        display_line(conf,     'WARNING: with --enable-pkg-config-dbus-service-dir option to this script', 'RED')
176
177    display_msg(conf)
178
179def build(bld):
180    daemon = bld.new_task_gen('cc', 'program')
181    daemon.target = 'ladishd'
182    daemon.includes = "build/default" # XXX config.h version.h and other generated files
183    daemon.uselib = 'DBUS-1 UUID EXPAT'
184    daemon.ver_header = 'version.h'
185    daemon.env.append_value("LINKFLAGS", ["-lutil", "-ldl", "-Wl,-E"])
186
187    daemon.source = [
188        'jack_proxy.c',
189        'graph_proxy.c',
190        'catdup.c',
191        ]
192
193    for source in [
194        'main.c',
195        'loader.c',
196        'log.c',
197        'dirhelpers.c',
198        'sigsegv.c',
199        'proctitle.c',
200        'appdb.c',
201        'procfs.c',
202        'control.c',
203        'studio.c',
204        'graph.c',
205        'client.c',
206        'port.c',
207        'jack_dispatch.c',
208        'dict.c',
209        'graph_dict.c',
210        'escape.c',
211        'studio_jack_conf.c',
212        'studio_load.c',
213        'studio_save.c',
214        'cmd_load_studio.c',
215        'cmd_new_studio.c',
216        'cmd_rename_studio.c',
217        'cmd_save_studio.c',
218        'cmd_start_studio.c',
219        'cmd_stop_studio.c',
220        'cmd_unload_studio.c',
221        'cqueue.c',
222        ]:
223        daemon.source.append(os.path.join("daemon", source))
224
225    for source in [
226        'signal.c',
227        'method.c',
228        'error.c',
229        'object_path.c',
230        'interface.c',
231        'helpers.c',
232        ]:
233        daemon.source.append(os.path.join("dbus", source))
234
235    daemon.source.append(os.path.join("common", "safety.c"))
236
237    # process name.arnaudov.nedko.ladish.service.in -> name.arnaudov.nedko.ladish.service
238    import misc
239    obj = bld.new_task_gen('subst')
240    obj.source = os.path.join('daemon', 'dbus.service.in')
241    obj.target = DBUS_NAME_BASE + '.service'
242    obj.dict = {'dbus_object_path': DBUS_NAME_BASE,
243                'daemon_bin_path': os.path.join(bld.env['PREFIX'], 'bin', daemon.target)}
244    obj.install_path = bld.env['DBUS_SERVICES_DIR'] + os.path.sep
245    obj.fun = misc.subst_func
246
247    if bld.env['BUILD_LIBLASH']:
248        liblash = bld.new_task_gen('cc', 'shlib')
249        liblash.includes = "build/default" # XXX config.h version.h and other generated files
250        liblash.uselib = 'DBUS-1'
251        liblash.target = 'lash'
252        liblash.vnum = "1.1.1"
253        liblash.defines = ['LOG_OUTPUT_STDOUT']
254        liblash.source = [os.path.join("lash_compat", "liblash", 'lash.c')]
255
256    # pkgpyexec_LTLIBRARIES = _lash.la
257    # INCLUDES = $(PYTHON_INCLUDES)
258    # _lash_la_LDFLAGS = -module -avoid-version ../liblash/liblash.la
259    # _lash_la_SOURCES = lash.c lash.h lash_wrap.c
260    # pkgpyexec_SCRIPTS = lash.py
261    # CLEANFILES = lash_wrap.c lash.py lash.pyc zynjacku.defs
262    # EXTRA_DIST = test.py lash.i lash.py
263    # lash_wrap.c lash.py: lash.i lash.h
264    #   swig -o lash_wrap.c -I$(top_srcdir) -python $(top_srcdir)/$(subdir)/lash.i
265
266    #####################################################
267    # gladish
268    if bld.env['BUILD_GLADISH']:
269        gladish = bld.new_task_gen('cxx', 'program')
270        gladish.features.append('cc')
271        gladish.target = 'gladish'
272        gladish.defines = ['LOG_OUTPUT_STDOUT']
273        gladish.includes = "build/default" # XXX config.h version.h and other generated files
274        gladish.uselib = 'DBUS-1 DBUS-GLIB-1 LIBGLADE-2.0 FLOWCANVAS'
275
276        gladish.source = [
277            'jack_proxy.c',
278            'graph_proxy.c',
279            'studio_proxy.c',
280            'catdup.c',
281            ]
282
283        for source in [
284            'main.c',
285            #'lash_client.cpp',
286            #'lash_proxy.cpp',
287            #'load_projects_dialog.cpp',
288            #'project.cpp',
289            'world_tree.c',
290            'graph_view.c',
291            #'project_properties.cpp',
292            #'session.cpp',
293            #'a2j_proxy.cpp',
294            'dbus_helpers.c',
295            'canvas.cpp',
296            'graph_canvas.c',
297            'glade.c',
298            'control_proxy.c',
299            'ask_dialog.c',
300            ]:
301            gladish.source.append(os.path.join("gui", source))
302
303        for source in [
304            'method.c',
305            'helpers.c',
306            ]:
307            gladish.source.append(os.path.join("dbus", source))
308
309        # Glade UI definitions (XML)
310        bld.install_files(bld.env['DATA_DIR'], 'gui/gui.glade')
311   
312    bld.install_files('${PREFIX}/bin', 'ladish_control', chmod=0755)
313
314    # 'Desktop' file (menu entry, icon, etc)
315    #obj = bld.create_obj('subst')
316    #obj.source = 'patchage.desktop.in'
317    #obj.target = 'patchage.desktop'
318    #obj.dict = {
319    #    'BINDIR'           : bld.env()['BINDIR'],
320    #    'APP_INSTALL_NAME' : bld.env()['APP_INSTALL_NAME'],
321    #    'APP_HUMAN_NAME'   : bld.env()['APP_HUMAN_NAME'],
322    #}
323    #install_as(os.path.normpath(bld.env()['DATADIR'] + 'applications/'), bld.env()['APP_INSTALL_NAME'] + '.desktop', 'build/default/patchage.desktop')
324
325    # Icons
326    #
327    # Installation layout (with /usr prefix)
328    # /usr/bin/patchage
329    # /usr/share/applications/patchage.desktop
330    # /usr/share/icons/hicolor/16x16/apps/patchage.png
331    # /usr/share/icons/hicolor/22x22/apps/patchage.png
332    # /usr/share/icons/hicolor/24x24/apps/patchage.png
333    # /usr/share/icons/hicolor/32x32/apps/patchage.png
334    # /usr/share/icons/hicolor/48x48/apps/patchage.png
335    # /usr/share/icons/hicolor/scalable/apps/patchage.svg
336    # /usr/share/patchage/patchage.glade
337    #
338    # icon cache is updated using:
339    # gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
340
341    # Dave disabled this, ask why before removing this
342    #install_as(os.path.normpath(bld.env()['PREFIX'] + '/share/icons/hicolor/scalable/apps/'), bld.env()['APP_INSTALL_NAME'] + '.svg', 'icons/scalable/patchage.svg')
343
344    #icon_sizes = ['16x16', '22x22', '24x24', '32x32', '48x48']
345    #for icon_size in icon_sizes:
346    #    install_as(os.path.normpath(bld.env()['DATADIR'] + '/icons/hicolor/' + icon_size + '/apps/'), bld.env()['APP_INSTALL_NAME'] + '.png', 'icons/' + icon_size + '/patchage.png')
347
348def dist_hook():
349    shutil.copy('../build/default/version.h', "./")
350
351import commands
352from Constants import RUN_ME
353from TaskGen import feature, after
354import Task, Utils
355
356@feature('cc')
357@after('apply_core')
358def process_git(self):
359    if getattr(self, 'ver_header', None):
360        tsk = self.create_task('git_ver')
361        tsk.set_outputs(self.path.find_or_declare(self.ver_header))
362
363def git_ver(self):
364    header = self.outputs[0].abspath(self.env)
365    if os.access('../version.h', os.R_OK):
366        shutil.copy('../version.h', header)
367        data = file(header).read()
368        m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
369        if m != None:
370            self.ver = m.group(1)
371            Utils.pprint('BLUE', "tarball from git revision " + self.ver)
372        else:
373            self.ver = "tarball"
374        return
375
376    if os.access('../.git', os.R_OK):
377        self.ver = commands.getoutput("LANG= git rev-parse HEAD").splitlines()[0]
378        if commands.getoutput("LANG= git diff-index --name-only HEAD").splitlines():
379            self.ver += "-dirty"
380
381        Utils.pprint('BLUE', "git revision " + self.ver)
382    else:
383        self.ver = "unknown"
384
385    fi = open(header, 'w')
386    fi.write('#define GIT_VERSION "%s"\n' % self.ver)
387    fi.close()
388
389cls = Task.task_type_from_func('git_ver', vars=[], func=git_ver, color='BLUE', before='cc')
390
391def always(self):
392    return RUN_ME
393cls.runnable_status = always
394
395def post_run(self):
396    sg = Utils.h_list(self.ver)
397    node = self.outputs[0]
398    variant = node.variant(self.env)
399    self.generator.bld.node_sigs[variant][node.id] = sg
400cls.post_run = post_run
Note: See TracBrowser for help on using the browser.