11 parallel_debug
= False
15 DBUS_NAME_BASE
= 'org.ladish'
18 # these variables are mandatory ('/' are converted automatically)
22 from Logs
import pprint
24 def display_msg(conf
, msg
="", status
= None, color
= None):
26 conf
.msg(msg
, status
, color
)
30 def display_raw_text(conf
, text
, color
= 'NORMAL'):
31 pprint(color
, text
, sep
= '')
33 def display_line(conf
, text
, color
= 'NORMAL'):
34 pprint(color
, text
, sep
= os
.linesep
)
43 opt
.tool_options('compiler_cc')
44 opt
.tool_options('compiler_cxx')
45 opt
.tool_options('boost')
46 opt
.tool_options('python')
47 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')
48 opt
.add_option('--enable-liblash', action
='store_true', default
=False, help='Build LASH compatibility library')
49 opt
.add_option('--enable-pylash', action
='store_true', default
=False, help='Build python bindings for LASH compatibility library')
50 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help="Build debuggable binaries")
51 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
52 opt
.add_option('--distnodeps', action
='store_true', default
=False, help="When creating distribution tarball, don't package git submodules")
54 opt
.load('parallel_debug')
56 def add_cflag(conf
, flag
):
57 conf
.env
.append_unique('CXXFLAGS', flag
)
58 conf
.env
.append_unique('CCFLAGS', flag
)
60 def add_linkflag(conf
, flag
):
61 conf
.env
.append_unique('LINKFLAGS', flag
)
63 def check_gcc_optimizations_enabled(flags
):
64 gcc_optimizations_enabled
= False
66 if len(flag
) < 2 or flag
[0] != '-' or flag
[1] != 'O':
69 gcc_optimizations_enabled
= True;
71 gcc_optimizations_enabled
= flag
[2] != '0';
72 return gcc_optimizations_enabled
74 def create_service_taskgen(bld
, target
, opath
, binary
):
76 features
= 'subst', # the feature 'subst' overrides the source/target processing
77 source
= os
.path
.join('daemon', 'dbus.service.in'), # list of string or nodes
78 target
= target
, # list of strings or nodes
79 install_path
= bld
.env
['DBUS_SERVICES_DIR'] + os
.path
.sep
,
80 # variables to use in the substitution
81 dbus_object_path
= opath
,
82 daemon_bin_path
= os
.path
.join(bld
.env
['PREFIX'], 'bin', binary
))
85 conf
.check_tool('compiler_cc')
86 conf
.check_tool('compiler_cxx')
87 conf
.check_tool('boost')
88 conf
.check_tool('python')
90 conf
.load('parallel_debug')
92 conf
.env
['LIB_DL'] = ['dl']
97 errmsg
= "not installed, see http://jackaudio.org/",
98 args
= '--cflags --libs')
102 atleast_version
= '1.0.0',
104 errmsg
= "not installed, see http://dbus.freedesktop.org/",
105 args
= '--cflags --libs')
107 dbus_dir
= conf
.check_cfg(package
='dbus-1', args
='--variable=session_bus_services_dir', msg
="Retrieving D-Bus services dir")
111 dbus_dir
= dbus_dir
.strip()
112 conf
.env
['DBUS_SERVICES_DIR_REAL'] = dbus_dir
114 if Options
.options
.enable_pkg_config_dbus_service_dir
:
115 conf
.env
['DBUS_SERVICES_DIR'] = dbus_dir
117 conf
.env
['DBUS_SERVICES_DIR'] = os
.path
.join(os
.path
.normpath(conf
.env
['PREFIX']), 'share', 'dbus-1', 'services')
119 conf
.env
['LIBDIR'] = os
.path
.join(os
.path
.normpath(conf
.env
['PREFIX']), 'lib')
121 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
126 errmsg
= "not installed, see http://e2fsprogs.sourceforge.net/",
127 args
= '--cflags --libs')
130 header_name
='expat.h',
132 errmsg
= "not installed, see http://expat.sourceforge.net/")
134 conf
.env
['LIB_EXPAT'] = ['expat']
138 if build_gui
and not conf
.check_cfg(
139 package
= 'glib-2.0',
141 errmsg
= "not installed, see http://www.gtk.org/",
142 args
= '--cflags --libs'):
145 if build_gui
and not conf
.check_cfg(
146 package
= 'dbus-glib-1',
148 errmsg
= "not installed, see http://dbus.freedesktop.org/",
149 args
= '--cflags --libs'):
152 if build_gui
and not conf
.check_cfg(
153 package
= 'gtk+-2.0',
155 atleast_version
= '2.20.0',
156 errmsg
= "not installed, see http://www.gtk.org/",
157 args
= '--cflags --libs'):
160 if build_gui
and not conf
.check_cfg(
161 package
= 'flowcanvas',
163 atleast_version
= '0.6.4',
164 errmsg
= "not installed, see http://drobilla.net/software/flowcanvas/",
165 args
= '--cflags --libs'):
169 # We need the boost headers package (e.g. libboost-dev)
170 # shared_ptr.hpp and weak_ptr.hpp
171 build_gui
= conf
.check_boost(errmsg
="not found, see http://boost.org/")
173 conf
.env
['BUILD_GLADISH'] = build_gui
175 conf
.env
['BUILD_LIBLASH'] = Options
.options
.enable_liblash
176 conf
.env
['BUILD_PYLASH'] = Options
.options
.enable_pylash
177 if conf
.env
['BUILD_PYLASH'] and not conf
.env
['BUILD_LIBLASH']:
178 conf
.fatal("pylash build was requested but liblash was not")
179 conf
.env
['BUILD_PYLASH'] = False
180 if conf
.env
['BUILD_PYLASH']:
181 conf
.check_python_version()
182 conf
.check_python_headers()
184 conf
.env
['BUILD_WERROR'] = not RELEASE
185 if conf
.env
['BUILD_WERROR']:
186 add_cflag(conf
, '-Wall')
187 add_cflag(conf
, '-Werror')
188 # for pre gcc-4.4, enable optimizations so use of uninitialized variables gets detected
190 is_gcc
= conf
.env
['CC_NAME'] == 'gcc'
193 for n
in conf
.env
['CC_VERSION']:
194 gcc_ver
.append(int(n
))
195 if gcc_ver
[0] < 4 or gcc_ver
[1] < 4:
196 #print "optimize force enable is required"
197 if not check_gcc_optimizations_enabled(conf
.env
['CCFLAGS']):
198 if Options
.options
.debug
:
199 print "C optimization must be forced in order to enable -Wuninitialized"
200 print "However this will not be made because debug compilation is enabled"
202 print "C optimization forced in order to enable -Wuninitialized"
203 conf
.env
.append_unique('CCFLAGS', "-O")
207 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
208 if conf
.env
['BUILD_DEBUG']:
209 add_cflag(conf
, '-g')
210 add_cflag(conf
, '-O0')
211 add_linkflag(conf
, '-g')
213 conf
.env
['DATA_DIR'] = os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'share', APPNAME
))
215 # write some parts of the configure environment to the config.h file
216 conf
.define('DATA_DIR', conf
.env
['DATA_DIR'])
217 conf
.define('PACKAGE_VERSION', VERSION
)
218 conf
.define('DBUS_NAME_BASE', DBUS_NAME_BASE
)
219 conf
.define('DBUS_BASE_PATH', '/' + DBUS_NAME_BASE
.replace('.', '/'))
220 conf
.define('BASE_NAME', APPNAME
)
221 conf
.define('_GNU_SOURCE', 1)
222 conf
.write_config_header('config.h')
226 display_msg(conf
, "==================")
227 version_msg
= APPNAME
+ "-" + VERSION
229 if os
.access('version.h', os
.R_OK
):
230 data
= file('version.h').read()
231 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
233 version_msg
+= " exported from " + m
.group(1)
234 elif os
.access('.git', os
.R_OK
):
235 version_msg
+= " git revision will checked and eventually updated during build"
237 display_msg(conf
, version_msg
)
240 display_msg(conf
, "Install prefix", conf
.env
['PREFIX'], 'CYAN')
242 display_msg(conf
, 'Build gladish', yesno(conf
.env
['BUILD_GLADISH']))
243 display_msg(conf
, 'Build liblash', yesno(Options
.options
.enable_liblash
))
244 display_msg(conf
, 'Build pylash', yesno(conf
.env
['BUILD_PYLASH']))
245 display_msg(conf
, 'Treat warnings as errors', yesno(conf
.env
['BUILD_WERROR']))
246 display_msg(conf
, 'Debuggable binaries', yesno(conf
.env
['BUILD_DEBUG']))
247 display_msg(conf
, 'Build doxygen documentation', yesno(conf
.env
['BUILD_DOXYGEN_DOCS']))
249 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
251 display_line(conf
, "WARNING: D-Bus session services directory as reported by pkg-config is", 'RED')
252 display_raw_text(conf
, "WARNING:", 'RED')
253 display_line(conf
, conf
.env
['DBUS_SERVICES_DIR_REAL'], 'CYAN')
254 display_line(conf
, 'WARNING: but service file will be installed in', 'RED')
255 display_raw_text(conf
, "WARNING:", 'RED')
256 display_line(conf
, conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
257 display_line(conf
, 'WARNING: You may need to adjust your D-Bus configuration after installing ladish', 'RED')
258 display_line(conf
, 'WARNING: You can override dbus service install directory', 'RED')
259 display_line(conf
, 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script', 'RED')
261 display_msg(conf
, 'C compiler flags', repr(conf
.env
['CCFLAGS']))
262 display_msg(conf
, 'C++ compiler flags', repr(conf
.env
['CXXFLAGS']))
264 if not conf
.env
['BUILD_GLADISH']:
266 display_line(conf
, "WARNING: The GUI frontend will not built", 'RED')
271 bld
= self
.generator
.bld
272 header
= self
.outputs
[0].abspath()
273 if os
.access('../version.h', os
.R_OK
):
274 shutil
.copy('../version.h', header
)
275 data
= file(header
).read()
276 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
278 self
.ver
= m
.group(1)
279 pprint('BLUE', "tarball from git revision " + self
.ver
)
284 if bld
.srcnode
.find_node('.git'):
285 self
.ver
= bld
.cmd_and_log("LANG= git rev-parse HEAD", quiet
=waflib
.Context
.BOTH
).splitlines()[0]
286 if bld
.cmd_and_log("LANG= git diff-index --name-only HEAD", quiet
=waflib
.Context
.BOTH
).splitlines():
289 pprint('BLUE', "git revision " + self
.ver
)
293 fi
= open(header
, 'w')
294 fi
.write('#define GIT_VERSION "%s"\n' % self
.ver
)
298 if not bld
.env
['DATA_DIR']:
299 raise "DATA_DIR is emtpy"
301 bld(rule
=git_ver
, target
='version.h', update_outputs
=True, always
=True, ext_out
=['.h'])
303 daemon
= bld
.program(source
= [], features
= 'c cprogram', includes
= [bld
.path
.get_bld()])
304 daemon
.target
= 'ladishd'
305 daemon
.uselib
= 'DBUS-1 UUID EXPAT'
306 daemon
.ver_header
= 'version.h'
307 daemon
.env
.append_value("LINKFLAGS", ["-lutil", "-ldl", "-Wl,-E"])
326 'studio_jack_conf.c',
331 'cmd_rename_studio.c',
333 'cmd_start_studio.c',
335 'cmd_unload_studio.c',
337 'cmd_change_app_state.c',
341 'cmd_save_project.c',
342 'cmd_unload_project.c',
343 'cmd_load_project.c',
353 daemon
.source
.append(os
.path
.join("daemon", source
))
363 daemon
.source
.append(os
.path
.join("proxies", source
))
373 daemon
.source
.append(os
.path
.join("dbus", source
))
380 daemon
.source
.append(os
.path
.join("common", source
))
382 daemon
.source
.append(os
.path
.join("alsapid", "helper.c"))
384 # process dbus.service.in -> ladish.service
385 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.service', DBUS_NAME_BASE
, daemon
.target
)
387 #####################################################
389 jmcore
= bld
.program(source
= [], features
= 'c cprogram', includes
= [bld
.path
.get_bld()])
390 jmcore
.target
= 'jmcore'
391 jmcore
.uselib
= 'DBUS-1 JACK'
392 jmcore
.defines
= ['LOG_OUTPUT_STDOUT']
393 jmcore
.source
= ['jmcore.c']
403 jmcore
.source
.append(os
.path
.join("dbus", source
))
405 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.jmcore.service', DBUS_NAME_BASE
+ ".jmcore", jmcore
.target
)
407 #####################################################
409 ladiconfd
= bld
.program(source
= [], features
= 'c cprogram', includes
= [bld
.path
.get_bld()])
410 ladiconfd
.target
= 'ladiconfd'
411 ladiconfd
.uselib
= 'DBUS-1'
412 ladiconfd
.defines
= ['LOG_OUTPUT_STDOUT']
413 ladiconfd
.source
= ['conf.c']
419 ladiconfd
.source
.append(os
.path
.join("common", source
))
429 ladiconfd
.source
.append(os
.path
.join("dbus", source
))
431 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.conf.service', DBUS_NAME_BASE
+ ".conf", ladiconfd
.target
)
433 #####################################################
435 bld
.shlib(source
= [os
.path
.join("alsapid", 'lib.c'), os
.path
.join("alsapid", "helper.c")], target
= 'alsapid', uselib
= 'DL')
437 #####################################################
439 if bld
.env
['BUILD_LIBLASH']:
440 liblash
= bld
.shlib(source
= [], features
= 'c cshlib', includes
= [bld
.path
.get_bld()])
441 liblash
.uselib
= 'DBUS-1'
442 liblash
.target
= 'lash'
443 liblash
.vnum
= "1.1.1"
444 liblash
.defines
= ['LOG_OUTPUT_STDOUT']
445 liblash
.source
= [os
.path
.join("lash_compat", "liblash", 'lash.c'), os
.path
.join("common", "catdup.c")]
447 bld
.install_files('${PREFIX}/include/lash', bld
.path
.ant_glob('lash_compat/liblash/lash/*.h'))
449 # process lash-1.0.pc.in -> lash-1.0.pc
451 features
= 'subst', # the feature 'subst' overrides the source/target processing
452 source
= os
.path
.join("lash_compat", 'lash-1.0.pc.in'), # list of string or nodes
453 target
= 'lash-1.0.pc', # list of strings or nodes
454 install_path
= '${LIBDIR}/pkgconfig/',
455 # variables to use in the substitution
456 prefix
= bld
.env
['PREFIX'],
457 exec_prefix
= bld
.env
['PREFIX'],
458 libdir
= bld
.env
['LIBDIR'],
459 includedir
= os
.path
.normpath(bld
.env
['PREFIX'] + '/include'))
461 #####################################################
463 if bld
.env
['BUILD_PYLASH']:
464 pylash
= bld
.shlib(features
= 'c cshlib pyext', source
= [])
465 pylash
.target
= '_lash'
467 pylash
.install_path
= '${PYTHONDIR}'
473 pylash
.source
.append(os
.path
.join("lash_compat", "pylash", source
))
475 bld
.install_files('${PYTHONDIR}', os
.path
.join("lash_compat", "pylash", "lash.py"))
477 #####################################################
479 if bld
.env
['BUILD_GLADISH']:
480 gladish
= bld
.program(source
= [], features
= 'c cxx cxxprogram', includes
= [bld
.path
.get_bld()])
481 gladish
.target
= 'gladish'
482 gladish
.defines
= ['LOG_OUTPUT_STDOUT']
483 gladish
.uselib
= 'DBUS-1 DBUS-GLIB-1 FLOWCANVAS'
489 'load_project_dialog.c',
490 'save_project_dialog.c',
497 'create_room_dialog.c',
515 gladish
.source
.append(os
.path
.join("gui", source
))
522 'app_supervisor_proxy.c',
526 gladish
.source
.append(os
.path
.join("proxies", source
))
532 gladish
.source
.append(os
.path
.join("dbus", source
))
537 gladish
.source
.append(os
.path
.join("common", source
))
539 # GtkBuilder UI definitions (XML)
540 bld
.install_files('${DATA_DIR}', 'gui/gladish.ui')
542 bld
.install_files('${PREFIX}/bin', 'ladish_control', chmod
=0755)
544 # 'Desktop' file (menu entry, icon, etc)
545 bld
.install_files('${PREFIX}/share/applications/', 'gui/gladish.desktop', chmod
=0644)
548 icon_sizes
= ['16x16', '22x22', '24x24', '32x32', '48x48', '256x256']
549 for icon_size
in icon_sizes
:
550 bld
.path
.ant_glob('art/' + icon_size
+ '/apps/*.png')
551 bld
.install_files('${PREFIX}/share/icons/hicolor/' + icon_size
+ '/apps/', 'art/' + icon_size
+ '/apps/gladish.png')
554 for status
in ["down", "unloaded", "started", "stopped", "warning", "error"]:
555 status_images
.append("art/status_" + status
+ ".png")
557 bld
.install_files('${DATA_DIR}', status_images
)
558 bld
.install_files('${DATA_DIR}', "art/ladish-logo-128x128.png")
559 bld
.install_files('${DATA_DIR}', ["COPYING", "AUTHORS", "README", "NEWS"])
561 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
562 html_docs_source_dir
= "build/default/html"
563 if bld
.cmd
== 'clean':
564 if os
.access(html_docs_source_dir
, os
.R_OK
):
565 pprint('CYAN', "Removing doxygen generated documentation...")
566 shutil
.rmtree(html_docs_source_dir
)
567 pprint('CYAN', "Removing doxygen generated documentation done.")
568 elif bld
.cmd
== 'build':
569 if not os
.access(html_docs_source_dir
, os
.R_OK
):
570 os
.popen("doxygen").read()
572 pprint('CYAN', "doxygen documentation already built.")
575 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
576 if 'relpath' in os
.path
.__all
__:
577 source_root
= os
.path
.relpath(source_root
)
579 paths
+= " " + os
.path
.join(source_root
, "common")
580 paths
+= " " + os
.path
.join(source_root
, "dbus")
581 paths
+= " " + os
.path
.join(source_root
, "proxies")
582 paths
+= " " + os
.path
.join(source_root
, "daemon")
583 paths
+= " " + os
.path
.join(source_root
, "gui")
584 paths
+= " " + os
.path
.join(source_root
, "example-apps")
585 paths
+= " " + os
.path
.join(source_root
, "lib")
586 paths
+= " " + os
.path
.join(source_root
, "lash_compat", "liblash")
587 paths
+= " " + os
.path
.join(source_root
, "lash_compat", "liblash", "lash")
591 '''build tag files for GNU global'''
592 cmd
= "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | gtags --statistics -f -" % get_tags_dirs()
593 #print("Running: %s" % cmd)
597 '''build TAGS file using etags'''
598 cmd
= "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | etags -" % get_tags_dirs()
599 #print("Running: %s" % cmd)
601 os
.system("stat -c '%y' TAGS")
604 #print repr(Options.options)
605 if Options
.options
.distnodeps
:
606 shutil
.rmtree('laditools')
607 shutil
.rmtree('flowcanvas')
608 shutil
.rmtree('jack2')
609 shutil
.rmtree('a2jmidid')
610 nodist_files
= ['.gitmodules', 'GTAGS', 'GRTAGS', 'GPATH', 'GSYMS'] # waf does not ignore these file
611 for nodist_file
in nodist_files
:
612 if os
.access(nodist_file
, os
.F_OK
):
613 os
.remove(nodist_file
)
614 shutil
.copy('../build/default/version.h', "./")