13 DBUS_NAME_BASE
= 'org.ladish'
16 # these variables are mandatory ('/' are converted automatically)
20 def display_msg(conf
, msg
="", status
= None, color
= None):
22 conf
.check_message_1(msg
)
23 conf
.check_message_2(status
, color
)
25 Utils
.pprint('NORMAL', msg
)
27 def display_raw_text(conf
, text
, color
= 'NORMAL'):
28 Utils
.pprint(color
, text
, sep
= '')
30 def display_line(conf
, text
, color
= 'NORMAL'):
31 Utils
.pprint(color
, text
, sep
= os
.linesep
)
40 opt
.tool_options('compiler_cc')
41 opt
.tool_options('compiler_cxx')
42 opt
.tool_options('boost')
43 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')
44 opt
.add_option('--enable-liblash', action
='store_true', default
=False, help='Build LASH compatibility library')
45 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help="Build debuggable binaries")
46 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
47 opt
.add_option('--distnodeps', action
='store_true', default
=False, help="When creating distribution tarball, don't package git submodules")
49 def add_cflag(conf
, flag
):
50 conf
.env
.append_unique('CXXFLAGS', flag
)
51 conf
.env
.append_unique('CCFLAGS', flag
)
53 def add_linkflag(conf
, flag
):
54 conf
.env
.append_unique('LINKFLAGS', flag
)
56 def check_gcc_optimizations_enabled(flags
):
57 gcc_optimizations_enabled
= False
59 if len(flag
) < 2 or flag
[0] != '-' or flag
[1] != 'O':
62 gcc_optimizations_enabled
= True;
64 gcc_optimizations_enabled
= flag
[2] != '0';
65 return gcc_optimizations_enabled
67 def create_service_taskgen(bld
, target
, opath
, binary
):
68 obj
= bld
.new_task_gen('subst')
69 obj
.source
= os
.path
.join('daemon', 'dbus.service.in')
71 obj
.dict = {'dbus_object_path': opath
,
72 'daemon_bin_path': os
.path
.join(bld
.env
['PREFIX'], 'bin', binary
)}
73 obj
.install_path
= bld
.env
['DBUS_SERVICES_DIR'] + os
.path
.sep
74 obj
.fun
= misc
.subst_func
77 conf
.check_tool('compiler_cc')
78 conf
.check_tool('compiler_cxx')
79 conf
.check_tool('boost')
80 #conf.check_tool('ParallelDebug')
85 errmsg
= "not installed, see http://jackaudio.org/",
86 args
= '--cflags --libs')
90 atleast_version
= '1.0.0',
92 errmsg
= "not installed, see http://dbus.freedesktop.org/",
93 args
= '--cflags --libs')
95 dbus_dir
= conf
.check_cfg(package
='dbus-1', args
='--variable=session_bus_services_dir', msg
="Retrieving D-Bus services dir")
99 dbus_dir
= dbus_dir
.strip()
100 conf
.env
['DBUS_SERVICES_DIR_REAL'] = dbus_dir
102 if Options
.options
.enable_pkg_config_dbus_service_dir
:
103 conf
.env
['DBUS_SERVICES_DIR'] = dbus_dir
105 conf
.env
['DBUS_SERVICES_DIR'] = os
.path
.join(os
.path
.normpath(conf
.env
['PREFIX']), 'share', 'dbus-1', 'services')
107 conf
.env
['LIBDIR'] = os
.path
.join(os
.path
.normpath(conf
.env
['PREFIX']), 'lib')
109 conf
.env
['BUILD_LIBLASH'] = Options
.options
.enable_liblash
110 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
115 errmsg
= "not installed, see http://e2fsprogs.sourceforge.net/",
116 args
= '--cflags --libs')
119 header_name
='expat.h',
121 errmsg
= "not installed, see http://expat.sourceforge.net/")
123 conf
.env
['LIB_EXPAT'] = ['expat']
127 if build_gui
and not conf
.check_cfg(
128 package
= 'glib-2.0',
130 errmsg
= "not installed, see http://www.gtk.org/",
131 args
= '--cflags --libs'):
134 if build_gui
and not conf
.check_cfg(
135 package
= 'dbus-glib-1',
137 errmsg
= "not installed, see http://dbus.freedesktop.org/",
138 args
= '--cflags --libs'):
141 if build_gui
and not conf
.check_cfg(
142 package
= 'gtk+-2.0',
144 atleast_version
= '2.20.0',
145 errmsg
= "not installed, see http://www.gtk.org/",
146 args
= '--cflags --libs'):
149 if build_gui
and not conf
.check_cfg(
150 package
= 'flowcanvas',
152 atleast_version
= '0.6.4',
153 errmsg
= "not installed, see http://drobilla.net/software/flowcanvas/",
154 args
= '--cflags --libs'):
158 # We need the boost headers package (e.g. libboost-dev)
159 # shared_ptr.hpp and weak_ptr.hpp
160 build_gui
= conf
.check_boost(errmsg
="not found, see http://boost.org/")
162 conf
.env
['BUILD_GLADISH'] = build_gui
164 conf
.env
['BUILD_WERROR'] = not RELEASE
165 if conf
.env
['BUILD_WERROR']:
166 add_cflag(conf
, '-Wall')
167 add_cflag(conf
, '-Werror')
168 # for pre gcc-4.4, enable optimizations so use of uninitialized variables gets detected
170 is_gcc
= conf
.env
['CC_NAME'] == 'gcc'
173 for n
in conf
.env
['CC_VERSION']:
174 gcc_ver
.append(int(n
))
175 if gcc_ver
[0] < 4 or gcc_ver
[1] < 4:
176 #print "optimize force enable is required"
177 if not check_gcc_optimizations_enabled(conf
.env
['CCFLAGS']):
178 if Options
.options
.debug
:
179 print "C optimization must be forced in order to enable -Wuninitialized"
180 print "However this will not be made because debug compilation is enabled"
182 print "C optimization forced in order to enable -Wuninitialized"
183 conf
.env
.append_unique('CCFLAGS', "-O")
187 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
188 if conf
.env
['BUILD_DEBUG']:
189 add_cflag(conf
, '-g')
190 add_cflag(conf
, '-O0')
191 add_linkflag(conf
, '-g')
193 conf
.define('DATA_DIR', os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'share', APPNAME
)))
194 conf
.define('PACKAGE_VERSION', VERSION
)
195 conf
.define('DBUS_NAME_BASE', DBUS_NAME_BASE
)
196 conf
.define('DBUS_BASE_PATH', '/' + DBUS_NAME_BASE
.replace('.', '/'))
197 conf
.define('BASE_NAME', APPNAME
)
198 conf
.define('_GNU_SOURCE', 1)
199 conf
.write_config_header('config.h')
203 display_msg(conf
, "==================")
204 version_msg
= APPNAME
+ "-" + VERSION
206 if os
.access('version.h', os
.R_OK
):
207 data
= file('version.h').read()
208 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
210 version_msg
+= " exported from " + m
.group(1)
211 elif os
.access('.git', os
.R_OK
):
212 version_msg
+= " git revision will checked and eventually updated during build"
214 display_msg(conf
, version_msg
)
217 display_msg(conf
, "Install prefix", conf
.env
['PREFIX'], 'CYAN')
219 display_msg(conf
, 'Build gladish', yesno(conf
.env
['BUILD_GLADISH']))
220 display_msg(conf
, 'Build liblash', yesno(Options
.options
.enable_liblash
))
221 display_msg(conf
, 'Treat warnings as errors', yesno(conf
.env
['BUILD_WERROR']))
222 display_msg(conf
, 'Debuggable binaries', yesno(conf
.env
['BUILD_DEBUG']))
223 display_msg(conf
, 'Build doxygen documentation', yesno(conf
.env
['BUILD_DOXYGEN_DOCS']))
225 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
227 display_line(conf
, "WARNING: D-Bus session services directory as reported by pkg-config is", 'RED')
228 display_raw_text(conf
, "WARNING:", 'RED')
229 display_line(conf
, conf
.env
['DBUS_SERVICES_DIR_REAL'], 'CYAN')
230 display_line(conf
, 'WARNING: but service file will be installed in', 'RED')
231 display_raw_text(conf
, "WARNING:", 'RED')
232 display_line(conf
, conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
233 display_line(conf
, 'WARNING: You may need to adjust your D-Bus configuration after installing ladish', 'RED')
234 display_line(conf
, 'WARNING: You can override dbus service install directory', 'RED')
235 display_line(conf
, 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script', 'RED')
237 display_msg(conf
, 'C compiler flags', repr(conf
.env
['CCFLAGS']))
238 display_msg(conf
, 'C++ compiler flags', repr(conf
.env
['CXXFLAGS']))
240 if not conf
.env
['BUILD_GLADISH']:
242 display_line(conf
, "WARNING: The GUI frontend will not built", 'RED')
247 daemon
= bld
.new_task_gen('cc', 'program')
248 daemon
.target
= 'ladishd'
249 daemon
.includes
= "build/default" # XXX config.h version.h and other generated files
250 daemon
.uselib
= 'DBUS-1 UUID EXPAT'
251 daemon
.ver_header
= 'version.h'
252 daemon
.env
.append_value("LINKFLAGS", ["-lutil", "-ldl", "-Wl,-E"])
273 'studio_jack_conf.c',
278 'cmd_rename_studio.c',
280 'cmd_start_studio.c',
282 'cmd_unload_studio.c',
284 'cmd_change_app_state.c',
288 'cmd_save_project.c',
289 'cmd_unload_project.c',
290 'cmd_load_project.c',
298 daemon
.source
.append(os
.path
.join("daemon", source
))
308 daemon
.source
.append(os
.path
.join("proxies", source
))
318 daemon
.source
.append(os
.path
.join("dbus", source
))
325 daemon
.source
.append(os
.path
.join("common", source
))
327 # process dbus.service.in -> ladish.service
328 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.service', DBUS_NAME_BASE
, daemon
.target
)
330 #####################################################
332 jmcore
= bld
.new_task_gen('cc', 'program')
333 jmcore
.target
= 'jmcore'
334 jmcore
.includes
= "build/default" # XXX config.h version.h and other generated files
335 jmcore
.uselib
= 'DBUS-1 JACK'
336 jmcore
.defines
= ['LOG_OUTPUT_STDOUT']
337 jmcore
.source
= ['jmcore.c']
347 jmcore
.source
.append(os
.path
.join("dbus", source
))
349 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.jmcore.service', DBUS_NAME_BASE
+ ".jmcore", jmcore
.target
)
351 #####################################################
353 ladiconfd
= bld
.new_task_gen('cc', 'program')
354 ladiconfd
.target
= 'ladiconfd'
355 ladiconfd
.includes
= "build/default" # XXX config.h version.h and other generated files
356 ladiconfd
.uselib
= 'DBUS-1'
357 ladiconfd
.defines
= ['LOG_OUTPUT_STDOUT']
358 ladiconfd
.source
= ['conf.c']
364 ladiconfd
.source
.append(os
.path
.join("common", source
))
374 ladiconfd
.source
.append(os
.path
.join("dbus", source
))
376 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.conf.service', DBUS_NAME_BASE
+ ".conf", ladiconfd
.target
)
378 #####################################################
380 if bld
.env
['BUILD_LIBLASH']:
381 liblash
= bld
.new_task_gen('cc', 'shlib')
382 liblash
.includes
= "build/default" # XXX config.h version.h and other generated files
383 liblash
.uselib
= 'DBUS-1'
384 liblash
.target
= 'lash'
385 liblash
.vnum
= "1.1.1"
386 liblash
.defines
= ['LOG_OUTPUT_STDOUT']
387 liblash
.source
= [os
.path
.join("lash_compat", "liblash", 'lash.c')]
389 bld
.install_files('${PREFIX}/include/lash', 'lash_compat/liblash/lash/*.h')
391 # process lash-1.0.pc.in -> lash-1.0.pc
392 obj
= bld
.new_task_gen('subst')
393 obj
.source
= [os
.path
.join("lash_compat", 'lash-1.0.pc.in')]
394 obj
.target
= 'lash-1.0.pc'
395 obj
.dict = {'prefix': bld
.env
['PREFIX'],
396 'exec_prefix': bld
.env
['PREFIX'],
397 'libdir': bld
.env
['LIBDIR'],
398 'includedir': os
.path
.normpath(bld
.env
['PREFIX'] + '/include'),
400 obj
.install_path
= '${LIBDIR}/pkgconfig/'
401 obj
.fun
= misc
.subst_func
403 #####################################################
406 # pkgpyexec_LTLIBRARIES = _lash.la
407 # INCLUDES = $(PYTHON_INCLUDES)
408 # _lash_la_LDFLAGS = -module -avoid-version ../liblash/liblash.la
409 # _lash_la_SOURCES = lash.c lash.h lash_wrap.c
410 # pkgpyexec_SCRIPTS = lash.py
411 # CLEANFILES = lash_wrap.c lash.py lash.pyc zynjacku.defs
412 # EXTRA_DIST = test.py lash.i lash.py
413 # lash_wrap.c lash.py: lash.i lash.h
414 # swig -o lash_wrap.c -I$(top_srcdir) -python $(top_srcdir)/$(subdir)/lash.i
416 #####################################################
418 if bld
.env
['BUILD_GLADISH']:
419 gladish
= bld
.new_task_gen('cxx', 'program')
420 gladish
.features
.append('cc')
421 gladish
.target
= 'gladish'
422 gladish
.defines
= ['LOG_OUTPUT_STDOUT']
423 gladish
.includes
= "build/default" # XXX config.h version.h and other generated files
424 gladish
.uselib
= 'DBUS-1 DBUS-GLIB-1 FLOWCANVAS'
430 'load_project_dialog.c',
431 'save_project_dialog.c',
438 'create_room_dialog.c',
453 gladish
.source
.append(os
.path
.join("gui", source
))
460 'app_supervisor_proxy.c',
464 gladish
.source
.append(os
.path
.join("proxies", source
))
470 gladish
.source
.append(os
.path
.join("dbus", source
))
475 gladish
.source
.append(os
.path
.join("common", source
))
477 # GtkBuilder UI definitions (XML)
478 bld
.install_files(bld
.env
['DATA_DIR'], 'gui/gladish.ui')
480 bld
.install_files('${PREFIX}/bin', 'ladish_control', chmod
=0755)
482 # 'Desktop' file (menu entry, icon, etc)
483 bld
.install_files('${PREFIX}/share/applications/', 'gui/gladish.desktop', chmod
=0644)
486 icon_sizes
= ['16x16', '22x22', '24x24', '32x32', '48x48', '256x256']
487 for icon_size
in icon_sizes
:
488 bld
.path
.ant_glob('art/' + icon_size
+ '/apps/*.png')
489 bld
.install_files('${PREFIX}/share/icons/hicolor/' + icon_size
+ '/apps/', 'art/' + icon_size
+ '/apps/gladish.png')
492 for status
in ["down", "unloaded", "started", "stopped", "warning", "error"]:
493 status_images
.append("art/status_" + status
+ ".png")
495 bld
.install_files(bld
.env
['DATA_DIR'], status_images
)
496 bld
.install_files(bld
.env
['DATA_DIR'], "art/ladish-logo-128x128.png")
497 bld
.install_files(bld
.env
['DATA_DIR'], ["COPYING", "AUTHORS", "README", "NEWS"])
499 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
500 html_docs_source_dir
= "build/default/html"
501 if Options
.commands
['clean']:
502 if os
.access(html_docs_source_dir
, os
.R_OK
):
503 Utils
.pprint('CYAN', "Removing doxygen generated documentation...")
504 shutil
.rmtree(html_docs_source_dir
)
505 Utils
.pprint('CYAN', "Removing doxygen generated documentation done.")
506 elif Options
.commands
['build']:
507 if not os
.access(html_docs_source_dir
, os
.R_OK
):
508 os
.popen("doxygen").read()
510 Utils
.pprint('CYAN', "doxygen documentation already built.")
513 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
514 if 'relpath' in os
.path
.__all
__:
515 source_root
= os
.path
.relpath(source_root
)
517 paths
+= " " + os
.path
.join(source_root
, "common")
518 paths
+= " " + os
.path
.join(source_root
, "dbus")
519 paths
+= " " + os
.path
.join(source_root
, "proxies")
520 paths
+= " " + os
.path
.join(source_root
, "daemon")
521 paths
+= " " + os
.path
.join(source_root
, "gui")
522 paths
+= " " + os
.path
.join(source_root
, "example-apps")
523 paths
+= " " + os
.path
.join(source_root
, "lib")
524 paths
+= " " + os
.path
.join(source_root
, "lash_compat", "liblash")
525 paths
+= " " + os
.path
.join(source_root
, "lash_compat", "liblash", "lash")
529 '''build tag files for GNU global'''
530 cmd
= "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | gtags --statistics -f -" % get_tags_dirs()
531 #print("Running: %s" % cmd)
535 '''build TAGS file using etags'''
536 cmd
= "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | etags -" % get_tags_dirs()
537 #print("Running: %s" % cmd)
539 os
.system("stat -c '%y' TAGS")
542 #print repr(Options.options)
543 if Options
.options
.distnodeps
:
544 shutil
.rmtree('laditools')
545 shutil
.rmtree('flowcanvas')
546 shutil
.rmtree('jack2')
547 shutil
.rmtree('a2jmidid')
548 nodist_files
= ['.gitmodules', 'GTAGS', 'GRTAGS', 'GPATH', 'GSYMS'] # waf does not ignore these file
549 for nodist_file
in nodist_files
:
550 os
.remove(nodist_file
)
551 shutil
.copy('../build/default/version.h', "./")
554 from Constants
import RUN_ME
555 from TaskGen
import feature
, after
560 def process_git(self
):
561 if getattr(self
, 'ver_header', None):
562 tsk
= self
.create_task('git_ver')
563 tsk
.set_outputs(self
.path
.find_or_declare(self
.ver_header
))
565 # needs some help with implicit dependencies
566 # http://code.google.com/p/waf/issues/detail?id=732
567 tg
= self
.bld
.name_to_obj('ladishd', self
.env
)
568 if id(tg
) != id(self
):
571 if x
.inputs
and x
.inputs
[0].name
== 'main.c' and x
.inputs
[0].parent
.name
== 'daemon':
575 header
= self
.outputs
[0].abspath(self
.env
)
576 if os
.access('../version.h', os
.R_OK
):
577 shutil
.copy('../version.h', header
)
578 data
= file(header
).read()
579 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
581 self
.ver
= m
.group(1)
582 Utils
.pprint('BLUE', "tarball from git revision " + self
.ver
)
587 if os
.access('../.git', os
.R_OK
):
588 self
.ver
= commands
.getoutput("LANG= git rev-parse HEAD").splitlines()[0]
589 if commands
.getoutput("LANG= git diff-index --name-only HEAD").splitlines():
592 Utils
.pprint('BLUE', "git revision " + self
.ver
)
596 fi
= open(header
, 'w')
597 fi
.write('#define GIT_VERSION "%s"\n' % self
.ver
)
600 cls
= Task
.task_type_from_func('git_ver', vars=[], func
=git_ver
, color
='BLUE')
604 cls
.runnable_status
= always
607 sg
= Utils
.h_list(self
.ver
)
608 node
= self
.outputs
[0]
609 variant
= node
.variant(self
.env
)
610 self
.generator
.bld
.node_sigs
[variant
][node
.id] = sg
611 cls
.post_run
= post_run
615 old_refill
= Runner
.Parallel
.refill_task_list
616 def refill_task_list(self
):
618 self
.outstanding
.sort(cmp=lambda a
, b
: cmp(b
.__class
__.__name
__, a
.__class
__.__name
__))
619 Runner
.Parallel
.refill_task_list
= refill_task_list