10 from waflib
.Scripting
import Dist
12 parallel_debug
= False
16 DBUS_NAME_BASE
= 'org.ladish'
19 # these variables are mandatory ('/' are converted automatically)
23 from Logs
import pprint
25 def display_msg(conf
, msg
="", status
= None, color
= None):
27 conf
.msg(msg
, status
, color
)
31 def display_raw_text(conf
, text
, color
= 'NORMAL'):
32 pprint(color
, text
, sep
= '')
34 def display_line(conf
, text
, color
= 'NORMAL'):
35 pprint(color
, text
, sep
= os
.linesep
)
44 opt
.load('compiler_c')
45 opt
.load('compiler_cxx')
48 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')
49 opt
.add_option('--enable-liblash', action
='store_true', default
=False, help='Build LASH compatibility library')
50 opt
.add_option('--enable-pylash', action
='store_true', default
=False, help='Build python bindings for LASH compatibility library')
51 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help="Build debuggable binaries")
52 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
53 opt
.add_option('--distnodeps', action
='store_true', default
=False, help="When creating distribution tarball, don't package git submodules")
54 opt
.add_option('--distname', type='string', default
=None, help="Name for the distribution tarball")
55 opt
.add_option('--distsuffix', type='string', default
="", help="String to append to the distribution tarball name")
56 opt
.add_option('--tagdist', action
='store_true', default
=False, help='Create of git tag for distname')
57 opt
.add_option('--libdir', type='string', default
=None, help='Define lib dir')
59 opt
.load('parallel_debug')
61 def add_cflag(conf
, flag
):
62 conf
.env
.append_unique('CXXFLAGS', flag
)
63 conf
.env
.append_unique('CFLAGS', flag
)
65 def add_linkflag(conf
, flag
):
66 conf
.env
.append_unique('LINKFLAGS', flag
)
68 def check_gcc_optimizations_enabled(flags
):
69 gcc_optimizations_enabled
= False
71 if len(flag
) < 2 or flag
[0] != '-' or flag
[1] != 'O':
74 gcc_optimizations_enabled
= True;
76 gcc_optimizations_enabled
= flag
[2] != '0';
77 return gcc_optimizations_enabled
79 def create_service_taskgen(bld
, target
, opath
, binary
):
81 features
= 'subst', # the feature 'subst' overrides the source/target processing
82 source
= os
.path
.join('daemon', 'dbus.service.in'), # list of string or nodes
83 target
= target
, # list of strings or nodes
84 install_path
= bld
.env
['DBUS_SERVICES_DIR'] + os
.path
.sep
,
85 # variables to use in the substitution
86 dbus_object_path
= opath
,
87 daemon_bin_path
= os
.path
.join(bld
.env
['PREFIX'], 'bin', binary
))
90 conf
.load('compiler_c')
91 conf
.load('compiler_cxx')
96 conf
.load('parallel_debug')
98 # dladdr() is used by daemon/siginfo.c
99 # dlvsym() is used by the alsapid library
100 conf
.check_cc(msg
="Checking for libdl", lib
=['dl'], uselib_store
='DL')
102 # forkpty() is used by ladishd
103 conf
.check_cc(msg
="Checking for libutil", lib
=['util'], uselib_store
='UTIL')
108 errmsg
= "not installed, see http://jackaudio.org/",
109 args
= '--cflags --libs')
114 errmsg
= "not installed, see http://www.alsa-project.org/",
119 atleast_version
= '1.0.0',
121 errmsg
= "not installed, see http://dbus.freedesktop.org/",
122 args
= '--cflags --libs')
124 dbus_dir
= conf
.check_cfg(package
='dbus-1', args
='--variable=session_bus_services_dir', msg
="Retrieving D-Bus services dir")
128 dbus_dir
= dbus_dir
.strip()
129 conf
.env
['DBUS_SERVICES_DIR_REAL'] = dbus_dir
131 if Options
.options
.enable_pkg_config_dbus_service_dir
:
132 conf
.env
['DBUS_SERVICES_DIR'] = dbus_dir
134 conf
.env
['DBUS_SERVICES_DIR'] = os
.path
.join(os
.path
.normpath(conf
.env
['PREFIX']), 'share', 'dbus-1', 'services')
136 if Options
.options
.libdir
:
137 conf
.env
['LIBDIR'] = Options
.options
.libdir
139 conf
.env
['LIBDIR'] = os
.path
.join(os
.path
.normpath(conf
.env
['PREFIX']), 'lib')
141 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
146 errmsg
= "not installed, see http://e2fsprogs.sourceforge.net/",
147 args
= '--cflags --libs')
150 header_name
='expat.h',
152 errmsg
= "not installed, see http://expat.sourceforge.net/")
154 conf
.env
['LIB_EXPAT'] = ['expat']
158 if build_gui
and not conf
.check_cfg(
159 package
= 'glib-2.0',
161 errmsg
= "not installed, see http://www.gtk.org/",
162 args
= '--cflags --libs'):
165 if build_gui
and not conf
.check_cfg(
166 package
= 'dbus-glib-1',
168 errmsg
= "not installed, see http://dbus.freedesktop.org/",
169 args
= '--cflags --libs'):
172 if build_gui
and not conf
.check_cfg(
173 package
= 'gtk+-2.0',
175 atleast_version
= '2.20.0',
176 errmsg
= "not installed, see http://www.gtk.org/",
177 args
= '--cflags --libs'):
180 if build_gui
and not conf
.check_cfg(
181 package
= 'gtkmm-2.4',
183 atleast_version
= '2.10.0',
184 errmsg
= "not installed, see http://www.gtkmm.org",
185 args
= '--cflags --libs'):
188 if build_gui
and not conf
.check_cfg(
189 package
= 'libgnomecanvasmm-2.6',
191 atleast_version
= '2.6.0',
192 errmsg
= "not installed, see http://www.gtkmm.org",
193 args
= '--cflags --libs'):
196 #autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GLIBMM', atleast_version='2.10.0', mandatory=True)
197 #autowaf.check_pkg(conf, 'libgnomecanvasmm-2.6', uselib_store='GNOMECANVASMM', atleast_version='2.6.0', mandatory=True)
199 #autowaf.check_pkg(conf, 'libgvc', uselib_store='AGRAPH', atleast_version='2.8', mandatory=False)
202 # We need the boost headers package (e.g. libboost-dev)
203 # shared_ptr.hpp and weak_ptr.hpp
204 build_gui
= conf
.check_boost(
206 errmsg
="not found, see http://boost.org/")
208 conf
.env
['BUILD_GLADISH'] = build_gui
210 conf
.env
['BUILD_LIBLASH'] = Options
.options
.enable_liblash
211 conf
.env
['BUILD_PYLASH'] = Options
.options
.enable_pylash
212 if conf
.env
['BUILD_PYLASH'] and not conf
.env
['BUILD_LIBLASH']:
213 conf
.fatal("pylash build was requested but liblash was not")
214 conf
.env
['BUILD_PYLASH'] = False
215 if conf
.env
['BUILD_PYLASH']:
216 conf
.check_python_version()
217 conf
.check_python_headers()
219 add_cflag(conf
, '-fvisibility=hidden')
221 conf
.env
['BUILD_WERROR'] = not RELEASE
222 add_cflag(conf
, '-Wall')
223 # lash_wrap code is generated by swig and causes warnings
224 if not conf
.env
['BUILD_PYLASH']:
225 add_cflag(conf
, '-Wextra')
226 conf
.env
.append_unique('CXXFLAGS', '-Wno-unused-parameter') # the UNUSED() macro doesnt work for C++
227 if conf
.env
['BUILD_WERROR']:
228 add_cflag(conf
, '-Werror')
229 # for pre gcc-4.4, enable optimizations so use of uninitialized variables gets detected
231 is_gcc
= conf
.env
['CC_NAME'] == 'gcc'
234 for n
in conf
.env
['CC_VERSION']:
235 gcc_ver
.append(int(n
))
236 if gcc_ver
[0] < 4 or gcc_ver
[1] < 4:
237 #print "optimize force enable is required"
238 if not check_gcc_optimizations_enabled(conf
.env
['CFLAGS']):
239 if Options
.options
.debug
:
240 print "C optimization must be forced in order to enable -Wuninitialized"
241 print "However this will not be made because debug compilation is enabled"
243 print "C optimization forced in order to enable -Wuninitialized"
244 conf
.env
.append_unique('CFLAGS', "-O")
248 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
249 if conf
.env
['BUILD_DEBUG']:
250 add_cflag(conf
, '-g')
251 add_cflag(conf
, '-O0')
252 add_linkflag(conf
, '-g')
254 conf
.env
['DATA_DIR'] = os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'share', APPNAME
))
255 conf
.env
['LOCALE_DIR'] = os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'share', 'locale'))
257 # write some parts of the configure environment to the config.h file
258 conf
.define('DATA_DIR', conf
.env
['DATA_DIR'])
259 conf
.define('LOCALE_DIR', conf
.env
['LOCALE_DIR'])
260 conf
.define('PACKAGE_VERSION', VERSION
)
261 conf
.define('DBUS_NAME_BASE', DBUS_NAME_BASE
)
262 conf
.define('DBUS_BASE_PATH', '/' + DBUS_NAME_BASE
.replace('.', '/'))
263 conf
.define('BASE_NAME', APPNAME
)
264 conf
.define('_GNU_SOURCE', 1)
265 conf
.write_config_header('config.h')
269 display_msg(conf
, "==================")
270 version_msg
= APPNAME
+ "-" + VERSION
272 if os
.access('version.h', os
.R_OK
):
273 data
= file('version.h').read()
274 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
276 version_msg
+= " exported from " + m
.group(1)
277 elif os
.access('.git', os
.R_OK
):
278 version_msg
+= " git revision will checked and eventually updated during build"
280 display_msg(conf
, version_msg
)
283 display_msg(conf
, "Install prefix", conf
.env
['PREFIX'], 'CYAN')
285 display_msg(conf
, 'Build gladish', yesno(conf
.env
['BUILD_GLADISH']))
286 display_msg(conf
, 'Build liblash', yesno(Options
.options
.enable_liblash
))
287 display_msg(conf
, 'Build pylash', yesno(conf
.env
['BUILD_PYLASH']))
288 display_msg(conf
, 'Treat warnings as errors', yesno(conf
.env
['BUILD_WERROR']))
289 display_msg(conf
, 'Debuggable binaries', yesno(conf
.env
['BUILD_DEBUG']))
290 display_msg(conf
, 'Build doxygen documentation', yesno(conf
.env
['BUILD_DOXYGEN_DOCS']))
292 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
294 display_line(conf
, "WARNING: D-Bus session services directory as reported by pkg-config is", 'RED')
295 display_raw_text(conf
, "WARNING:", 'RED')
296 display_line(conf
, conf
.env
['DBUS_SERVICES_DIR_REAL'], 'CYAN')
297 display_line(conf
, 'WARNING: but service file will be installed in', 'RED')
298 display_raw_text(conf
, "WARNING:", 'RED')
299 display_line(conf
, conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
300 display_line(conf
, 'WARNING: You may need to adjust your D-Bus configuration after installing ladish', 'RED')
301 display_line(conf
, 'WARNING: You can override dbus service install directory', 'RED')
302 display_line(conf
, 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script', 'RED')
304 display_msg(conf
, 'C compiler flags', repr(conf
.env
['CFLAGS']))
305 display_msg(conf
, 'C++ compiler flags', repr(conf
.env
['CXXFLAGS']))
307 if not conf
.env
['BUILD_GLADISH']:
309 display_line(conf
, "WARNING: The GUI frontend will not built", 'RED')
314 bld
= self
.generator
.bld
315 header
= self
.outputs
[0].abspath()
316 if os
.access('./version.h', os
.R_OK
):
317 header
= os
.path
.join(os
.getcwd(), out
, "version.h")
318 shutil
.copy('./version.h', header
)
319 data
= file(header
).read()
320 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
322 self
.ver
= m
.group(1)
323 pprint('BLUE', "tarball from git revision " + self
.ver
)
328 if bld
.srcnode
.find_node('.git'):
329 self
.ver
= bld
.cmd_and_log("LANG= git rev-parse HEAD", quiet
=waflib
.Context
.BOTH
).splitlines()[0]
330 if bld
.cmd_and_log("LANG= git diff-index --name-only HEAD", quiet
=waflib
.Context
.BOTH
).splitlines():
333 pprint('BLUE', "git revision " + self
.ver
)
337 fi
= open(header
, 'w')
338 fi
.write('#define GIT_VERSION "%s"\n' % self
.ver
)
342 if not bld
.env
['DATA_DIR']:
343 raise "DATA_DIR is emtpy"
345 bld(rule
=git_ver
, target
='version.h', update_outputs
=True, always
=True, ext_out
=['.h'])
347 daemon
= bld
.program(source
= [], features
= 'c cprogram', includes
= [bld
.path
.get_bld()])
348 daemon
.target
= 'ladishd'
349 daemon
.uselib
= 'DBUS-1 UUID EXPAT DL UTIL'
350 daemon
.ver_header
= 'version.h'
351 # Make backtrace function lookup to work for functions in the executable itself
352 daemon
.env
.append_value("LINKFLAGS", ["-Wl,-E"])
353 daemon
.defines
= ["HAVE_CONFIG_H"]
355 daemon
.source
= ["string_constants.c"]
374 'studio_jack_conf.c',
380 'cmd_rename_studio.c',
382 'cmd_start_studio.c',
384 'cmd_unload_studio.c',
386 'cmd_change_app_state.c',
390 'cmd_save_project.c',
391 'cmd_unload_project.c',
392 'cmd_load_project.c',
405 daemon
.source
.append(os
.path
.join("daemon", source
))
414 "lash_client_proxy.c",
416 daemon
.source
.append(os
.path
.join("proxies", source
))
425 daemon
.source
.append(os
.path
.join("cdbus", source
))
433 daemon
.source
.append(os
.path
.join("common", source
))
435 daemon
.source
.append(os
.path
.join("alsapid", "helper.c"))
437 # process dbus.service.in -> ladish.service
438 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.service', DBUS_NAME_BASE
, daemon
.target
)
440 #####################################################
442 jmcore
= bld
.program(source
= [], features
= 'c cprogram', includes
= [bld
.path
.get_bld()])
443 jmcore
.target
= 'jmcore'
444 jmcore
.uselib
= 'DBUS-1 JACK'
445 jmcore
.defines
= ['LOG_OUTPUT_STDOUT']
446 jmcore
.source
= ['jmcore.c']
451 jmcore
.source
.append(os
.path
.join("common", source
))
460 jmcore
.source
.append(os
.path
.join("cdbus", source
))
462 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.jmcore.service', DBUS_NAME_BASE
+ ".jmcore", jmcore
.target
)
464 #####################################################
466 ladiconfd
= bld
.program(source
= [], features
= 'c cprogram', includes
= [bld
.path
.get_bld()])
467 ladiconfd
.target
= 'ladiconfd'
468 ladiconfd
.uselib
= 'DBUS-1'
469 ladiconfd
.defines
= ['LOG_OUTPUT_STDOUT']
470 ladiconfd
.source
= ['conf.c']
477 ladiconfd
.source
.append(os
.path
.join("common", source
))
486 ladiconfd
.source
.append(os
.path
.join("cdbus", source
))
488 create_service_taskgen(bld
, DBUS_NAME_BASE
+ '.conf.service', DBUS_NAME_BASE
+ ".conf", ladiconfd
.target
)
490 #####################################################
492 alsapid
= bld
.shlib(source
= [], features
= 'c cshlib', includes
= [bld
.path
.get_bld()])
493 alsapid
.uselib
= 'DL'
494 alsapid
.target
= 'alsapid'
499 alsapid
.source
.append(os
.path
.join("alsapid", source
))
501 #####################################################
503 if bld
.env
['BUILD_LIBLASH']:
504 liblash
= bld
.shlib(source
= [], features
= 'c cshlib', includes
= [bld
.path
.get_bld()])
505 liblash
.uselib
= 'DBUS-1'
506 liblash
.target
= 'lash'
507 liblash
.vnum
= "1.1.1"
508 liblash
.defines
= ['LOG_OUTPUT_STDOUT']
509 liblash
.source
= [os
.path
.join("lash_compat", "liblash", 'lash.c')]
517 liblash
.source
.append(os
.path
.join("common", source
))
525 liblash
.source
.append(os
.path
.join("cdbus", source
))
527 bld
.install_files('${PREFIX}/include/lash-1.0/lash', bld
.path
.ant_glob('lash_compat/liblash/lash/*.h'))
529 # process lash-1.0.pc.in -> lash-1.0.pc
531 features
= 'subst', # the feature 'subst' overrides the source/target processing
532 source
= os
.path
.join("lash_compat", 'lash-1.0.pc.in'), # list of string or nodes
533 target
= 'lash-1.0.pc', # list of strings or nodes
534 install_path
= '${LIBDIR}/pkgconfig/',
535 # variables to use in the substitution
536 prefix
= bld
.env
['PREFIX'],
537 exec_prefix
= bld
.env
['PREFIX'],
538 libdir
= bld
.env
['LIBDIR'],
539 includedir
= os
.path
.normpath(bld
.env
['PREFIX'] + '/include'))
541 #####################################################
543 if bld
.env
['BUILD_PYLASH']:
544 pylash
= bld
.shlib(source
= [], features
= 'c cshlib pyext', includes
= ["lash_compat/liblash"])
545 pylash
.target
= '_lash'
547 pylash
.install_path
= '${PYTHONDIR}'
553 pylash
.source
.append(os
.path
.join("lash_compat", "pylash", source
))
555 bld
.install_files('${PYTHONDIR}', os
.path
.join("lash_compat", "pylash", "lash.py"))
557 #####################################################
559 if bld
.env
['BUILD_GLADISH']:
560 gladish
= bld
.program(source
= [], features
= 'c cxx cxxprogram', includes
= [bld
.path
.get_bld()])
561 gladish
.target
= 'gladish'
562 gladish
.defines
= ['LOG_OUTPUT_STDOUT']
563 gladish
.uselib
= 'DBUS-1 DBUS-GLIB-1 GTKMM-2.4 LIBGNOMECANVASMM-2.6 GTK+-2.0'
565 gladish
.source
= ["string_constants.c"]
569 'load_project_dialog.c',
570 'save_project_dialog.c',
571 'project_properties.c',
578 'create_room_dialog.c',
596 gladish
.source
.append(os
.path
.join("gui", source
))
607 gladish
.source
.append(os
.path
.join("gui", "flowcanvas", source
))
615 'app_supervisor_proxy.c',
619 gladish
.source
.append(os
.path
.join("proxies", source
))
625 gladish
.source
.append(os
.path
.join("cdbus", source
))
632 gladish
.source
.append(os
.path
.join("common", source
))
634 # GtkBuilder UI definitions (XML)
635 bld
.install_files('${DATA_DIR}', 'gui/gladish.ui')
637 bld
.install_files('${PREFIX}/bin', 'ladish_control', chmod
=0755)
639 # 'Desktop' file (menu entry, icon, etc)
640 bld
.install_files('${PREFIX}/share/applications/', 'gui/gladish.desktop', chmod
=0644)
643 icon_sizes
= ['16x16', '22x22', '24x24', '32x32', '48x48', '256x256']
644 for icon_size
in icon_sizes
:
645 bld
.path
.ant_glob('art/' + icon_size
+ '/apps/*.png')
646 bld
.install_files('${PREFIX}/share/icons/hicolor/' + icon_size
+ '/apps/', 'art/' + icon_size
+ '/apps/gladish.png')
649 for status
in ["down", "unloaded", "started", "stopped", "warning", "error"]:
650 status_images
.append("art/status_" + status
+ ".png")
652 bld
.install_files('${DATA_DIR}', status_images
)
653 bld
.install_files('${DATA_DIR}', "art/ladish-logo-128x128.png")
654 bld
.install_files('${DATA_DIR}', ["AUTHORS", "README", "NEWS"])
655 bld
.install_as('${DATA_DIR}/COPYING', "gpl2.txt")
657 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
658 html_docs_source_dir
= "build/default/html"
659 if bld
.cmd
== 'clean':
660 if os
.access(html_docs_source_dir
, os
.R_OK
):
661 pprint('CYAN', "Removing doxygen generated documentation...")
662 shutil
.rmtree(html_docs_source_dir
)
663 pprint('CYAN', "Removing doxygen generated documentation done.")
664 elif bld
.cmd
== 'build':
665 if not os
.access(html_docs_source_dir
, os
.R_OK
):
666 os
.popen("doxygen").read()
668 pprint('CYAN', "doxygen documentation already built.")
670 bld(features
='intltool_po', appname
=APPNAME
, podir
='po', install_path
="${LOCALE_DIR}")
673 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
674 if 'relpath' in os
.path
.__all
__:
675 source_root
= os
.path
.relpath(source_root
)
677 paths
+= " " + os
.path
.join(source_root
, "common")
678 paths
+= " " + os
.path
.join(source_root
, "cdbus")
679 paths
+= " " + os
.path
.join(source_root
, "proxies")
680 paths
+= " " + os
.path
.join(source_root
, "daemon")
681 paths
+= " " + os
.path
.join(source_root
, "gui")
682 paths
+= " " + os
.path
.join(source_root
, "example-apps")
683 paths
+= " " + os
.path
.join(source_root
, "lib")
684 paths
+= " " + os
.path
.join(source_root
, "lash_compat", "liblash")
685 paths
+= " " + os
.path
.join(source_root
, "lash_compat", "liblash", "lash")
689 '''build tag files for GNU global'''
690 cmd
= "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | gtags --statistics -f -" % get_tags_dirs()
691 #print("Running: %s" % cmd)
695 '''build TAGS file using etags'''
696 cmd
= "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | etags -" % get_tags_dirs()
697 #print("Running: %s" % cmd)
699 os
.system("stat -c '%y' TAGS")
701 class ladish_dist(waflib
.Scripting
.Dist
):
707 if Options
.options
.distname
:
708 self
.base_name
= Options
.options
.distname
711 self
.base_name
= self
.cmd_and_log("LANG= git describe --tags", quiet
=waflib
.Context
.BOTH
).splitlines()[0]
713 self
.base_name
= APPNAME
+ '-' + VERSION
714 self
.base_name
+= Options
.options
.distsuffix
716 #print self.base_name
718 if Options
.options
.distname
and Options
.options
.tagdist
:
719 ret
= self
.exec_command("LANG= git tag " + self
.base_name
)
721 raise waflib
.Errors
.WafError('git tag creation failed')
723 def get_base_name(self
):
724 return self
.base_name
727 excl
= Dist
.get_excl(self
)
729 excl
+= ' .gitmodules'
735 if Options
.options
.distnodeps
:
744 shutil
.copy('./build/version.h', "./")
746 super(ladish_dist
, self
).execute()
748 os
.remove("version.h")