From 6a90ffca22786165c87a283071d398721218e5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 10:13:44 +0200 Subject: [PATCH 01/24] implement build system auto options --- wscript | 310 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 310 insertions(+) diff --git a/wscript b/wscript index 5d6de660..6fba9c37 100644 --- a/wscript +++ b/wscript @@ -27,6 +27,8 @@ out = 'build' # lib32 variant name used when building in mixed mode lib32 = 'lib32' +auto_options = [] + def display_msg(msg, status = None, color = None): sr = msg global g_maxlen @@ -43,6 +45,13 @@ def display_feature(msg, build): else: display_msg(msg, "no", 'YELLOW') +def print_error(msg): + """ + This function prints an error without stopping waf. The reason waf should + not be stopped is to be able to list all missing dependencies in one chunk. + """ + print(Logs.colors.RED + msg + Logs.colors.NORMAL) + def create_svnversion_task(bld, header='svnversion.h', define=None): cmd = '../svnversion_regenerate.sh ${TGT}' if define: @@ -63,6 +72,298 @@ def create_svnversion_task(bld, header='svnversion.h', define=None): target = [bld.path.find_or_declare(header)] ) +class AutoOption: + """ + This class is the foundation for the auto options. It adds an option + --foo=no|yes to the list of options and deals with all logic and checks for + these options. + + Each option can have different dependencies that will be checked. If all + dependencies are available and the user has not done any request the option + will be enabled. If the user has requested to enable the option the class + ensures that all dependencies are available and prints an error message + otherwise. If the user disables the option, i.e. --foo=no, no checks are + made. + + For each option it is possible to add packages that are required for the + option using the add_package function. For dependency programs add_program + should be used. For libraries (without pkg-config support) the add_library + function should be used. For headers the add_header function exists. If + there is another type of requirement or dependency the check hook (an + external function called when configuring) can be used. + + When all checks have been made and the class has made a decision the result + is saved in conf.env['NAME'] where 'NAME' by default is the uppercase of the + name argument to __init__, but it can be changed with the conf_dest argument + to __init__. + + The class will define a preprocessor symbol with the result. The default + name is HAVE_NAME, but it can be changed using the define argument to + __init__. + """ + + # check hook to call upon configuration + check_hook = None + check_hook_error = None + check_hook_found = True + + # required libraries + libs = [] # elements on the form [lib,uselib_store] + libs_not_found = [] # elements on the form lib + + # required headers + headers = [] + headers_not_found = [] + + # required packages (checked with pkg-config) + packages = [] # elements on the form [package,uselib_store,atleast_version] + packages_not_found = [] # elements on the form [package,atleast_version] + + # required programs + programs = [] # elements on the form [program,var] + programs_not_found = [] # elements on the form program + + # the result of the configuration (should the option be enabled or not?) + result = False + + def __init__(self, opt, name, help, conf_dest=None, define=None): + self.help = help + self.option = '--' + name + self.dest = 'auto_option_' + name + if conf_dest: + self.conf_dest = conf_dest + else: + self.conf_dest = name.upper() + if not define: + self.define = 'HAVE_' + name.upper() + else: + self.define = define + opt.add_option(self.option, type='string', default='auto', dest=self.dest, help=self.help+' (enabled by default if possible)', metavar='no|yes') + + def add_library(self, library, uselib_store=None): + """ + Add a required library that should be checked during configuration. The + library will be checked using the conf.check_cc function. If the + uselib_store arugment is not given it defaults to LIBRARY (the uppercase + of the library argument). The uselib_store argument will be passed to + check_cc which means LIB_LIBRARY, CFLAGS_LIBRARY and DEFINES_LIBRARY, + etc. will be defined if the option is enabled. + """ + if not uselib_store: + uselib_store = library.upper().replace('-', '_') + self.libs.append([library, uselib_store]) + + def add_header(self, header): + """ + Add a required header that should be checked during configuration. The + header will be checked using the conf.check_cc function which means + HAVE_HEADER_H will be defined if found. + """ + self.headers.append(header) + + def add_package(self, package, uselib_store=None, atleast_version=None): + """ + Add a required package that should be checked using pkg-config during + configuration. The package will be checked using the conf.check_cfg + function and the uselib_store and atleast_version will be passed to + check_cfg. If uselib_store is None it defaults to PACKAGE (uppercase of + the package argument) with hyphens and dots replaced with underscores. + If atleast_version is None it defaults to '0'. + """ + if not uselib_store: + uselib_store = package.upper().replace('-', '_').replace('.', '_') + if not atleast_version: + atleast_version = '0' + self.packages.append([package, uselib_store, atleast_version]) + + def add_program(self, program, var=None): + """ + Add a required program that should be checked during configuration. If + var is not given it defaults to PROGRAM (the uppercase of the program + argument). If the option is enabled the program is saved in + conf.env.PROGRAM. + """ + if not var: + var = program.upper().replace('-', '_') + self.programs.append([program, var]) + + def check_hook(self, check_hook, check_hook_error): + """ + Add a check hook and a corresponding error printing function to the + configure step. The check_hook argument is a function that should return + True if the extra prerequisites were found and False if not. The + check_hook_error argument is an error printing function that should + print an error message telling the user that --foo was explicitly + requested but cannot be built since the extra prerequisites were not + found. Both function should take a single argument that is the waf + configuration context. + """ + self.check_hook = check_hook + self.check_hook_error = check_hook_error + + def _check(self, conf): + """ + This is an internal function that runs all necessary configure checks. + It checks all dependencies (even if some dependency was not found) so + that the user can install all missing dependencies in one go, instead + of playing the infamous hit-configure-hit-configure game. + + This function returns True if all dependencies were found and False if + not. + """ + all_found = True + + # check for libraries + for lib,uselib_store in self.libs: + try: + conf.check_cc(lib=lib, uselib_store=uselib_store) + except conf.errors.ConfigurationError: + all_found = False + self.libs_not_found.append(lib) + + # check for headers + for header in self.headers: + try: + conf.check_cc(header_name=header) + except conf.errors.ConfigurationError: + all_found = False + self.headers_not_found.append(header) + + # check for packages + for package,uselib_store,atleast_version in self.packages: + try: + conf.check_cfg(package=package, uselib_store=uselib_store, atleast_version=atleast_version, args='--cflags --libs') + except conf.errors.ConfigurationError: + all_found = False + self.packages_not_found.append([package,atleast_version]) + + # check for programs + for program,var in self.programs: + try: + conf.find_program(program, var=var) + except conf.errors.ConfigurationError: + all_found = False + self.programs_not_found.append(program) + + # call hook (if specified) + if self.check_hook: + self.check_hook_found = self.check_hook(conf) + if not self.check_hook_found: + all_found = False + + return all_found + + def _configure_error(self, conf): + """ + This is an internal function that prints errors for each missing + dependency. The error messages tell the user that this option required + some dependency, but it cannot be found. + """ + + for lib in self.libs_not_found: + print_error('%s requires the %s library, but it cannot be found.' % (self.option, lib)) + + for header in self.headers_not_found: + print_error('%s requires the %s header, but it cannot be found.' % (self.option, header)) + + for package,atleast_version in self.packages_not_found: + string = package + if atleast_version: + string += ' >= ' + atleast_version + print_error('%s requires the package %s, but it cannot be found.' % (self.option, string)) + + for program in self.programs_not_found: + print_error('%s requires the %s program, but it cannot be found.', (self.option, program)) + + if not self.check_hook_found: + self.check_hook_error(conf) + + def configure(self, conf): + """ + This function configures the option examining the argument given too + --foo (where foo is this option). This function sets self.result to the + result of the configuration; True if the option should be enabled or + False if not. If not all dependencies were found self.result will shall + be False. conf.env['NAME'] will be set to the same value aswell as a + preprocessor symbol will be defined according to the result. + + If --foo[=yes] was given, but some dependency was not found an error + message is printed (foreach missing dependency). + + This function returns True on success and False on error. + """ + argument = getattr(Options.options, self.dest) + if argument == 'no': + self.result = False + retvalue = True + elif argument == 'yes': + if self._check(conf): + self.result = True + retvalue = True + else: + self.result = False + retvalue = False + self._configure_error(conf) + elif argument == 'auto': + self.result = self._check(conf) + retvalue = True + else: + print_error('Invalid argument "' + argument + '" to ' + self.option) + self.result = False + retvalue = False + + conf.env[self.conf_dest] = self.result + if self.result: + conf.define(self.define, 1) + else: + conf.define(self.define, 0) + return retvalue + + def display_message(self): + """ + This function displays a result message with the help text and the + result of the configuration. + """ + display_feature(self.help, self.result) + +def add_auto_option(opt, name, help, conf_dest=None, define=None): + """ + Adds an option to the list of auto options and returns the newly created + option. + """ + option = AutoOption(opt, name, help, conf_dest=conf_dest, define=define) + auto_options.append(option) + return option + +def auto_options_argv_hack(): + """ + This function applies a hack that for each auto option --foo=no|yes replaces + any occurence --foo in argv with --foo=yes, in effect interpreting --foo as + --foo=yes. The function has to be called before waf issues the option + parser, i.e. before the configure phase. + """ + for option in auto_options: + for x in range(1, len(sys.argv)): + if sys.argv[x] == option.option: + sys.argv[x] += '=yes' + +def configure_auto_options(conf): + """ + This function configures all auto options. It stops waf and prints an error + message if there were unsatisfied requirements. + """ + ok = True + for option in auto_options: + if not option.configure(conf): + ok = False + if not ok: + conf.fatal('There were unsatisfied requirements.') + +def display_auto_options_messages(): + """This function displays all options and the configuration result.""" + for option in auto_options: + option.display_message() + def options(opt): # options provided by the modules opt.tool_options('compiler_cxx') @@ -98,6 +399,9 @@ def options(opt): # dbus options opt.sub_options('dbus') + # this must be called before the configure phase + auto_options_argv_hack() + def configure(conf): conf.load('compiler_cxx') conf.load('compiler_cc') @@ -150,6 +454,9 @@ def configure(conf): conf.env.append_unique('CXXFLAGS', '-Wall') conf.env.append_unique('CFLAGS', '-Wall') + # configure all auto options + configure_auto_options(conf) + conf.sub_config('common') if conf.env['IS_LINUX']: conf.sub_config('linux') @@ -359,6 +666,9 @@ def configure(conf): print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL) print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL) + # display configuration result messages for auto options + display_auto_options_messages() + if conf.env['IS_LINUX']: display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True) display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True) From f98fdba3d94e0598577e20a9477590904a1def30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 10:27:02 +0200 Subject: [PATCH 02/24] rename the check_hook function to set_check_hook in the AutoOption class to prevent name clash --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index 6fba9c37..9856db5a 100644 --- a/wscript +++ b/wscript @@ -187,7 +187,7 @@ class AutoOption: var = program.upper().replace('-', '_') self.programs.append([program, var]) - def check_hook(self, check_hook, check_hook_error): + def set_check_hook(self, check_hook, check_hook_error): """ Add a check hook and a corresponding error printing function to the configure step. The check_hook argument is a function that should return From e4006fba40f2179ebe09d92595872b4083e43991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 10:28:07 +0200 Subject: [PATCH 03/24] in the AutoOption class, make the set_check_hook documentation string more precise --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index 9856db5a..ebde3578 100644 --- a/wscript +++ b/wscript @@ -189,7 +189,7 @@ class AutoOption: def set_check_hook(self, check_hook, check_hook_error): """ - Add a check hook and a corresponding error printing function to the + Set the check hook and the corresponding error printing function to the configure step. The check_hook argument is a function that should return True if the extra prerequisites were found and False if not. The check_hook_error argument is an error printing function that should From a31f352e612fd0525efeba8b816004b1e89b17b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 10:36:49 +0200 Subject: [PATCH 04/24] make the --doxygen option an auto option --- wscript | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wscript b/wscript index ebde3578..582bc74d 100644 --- a/wscript +++ b/wscript @@ -388,7 +388,8 @@ def options(opt): opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application') # options with third party dependencies - opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation') + doxygen = add_auto_option(opt, 'doxygen', help='Build doxygen documentation', conf_dest='BUILD_DOXYGEN_DOCS') + doxygen.add_program('doxygen') opt.add_option('--alsa', action='store_true', default=False, help='Enable ALSA driver') opt.add_option('--firewire', action='store_true', default=False, help='Enable FireWire driver (FFADO)') opt.add_option('--freebob', action='store_true', default=False, help='Enable FreeBob driver') @@ -537,7 +538,6 @@ def configure(conf): conf.env['JACK_API_VERSION'] = JACK_API_VERSION conf.env['JACK_VERSION'] = VERSION - conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen conf.env['BUILD_WITH_PROFILE'] = Options.options.profile conf.env['BUILD_WITH_32_64'] = Options.options.mixed conf.env['BUILD_CLASSIC'] = Options.options.classic @@ -653,7 +653,6 @@ def configure(conf): display_msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS'])) display_msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS'])) display_msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS'])) - display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS']) display_feature('Build Opus netjack2', conf.env['WITH_OPUS']) display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE']) display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64']) From bcc742b6b12c09b0d910672ce40899fa21eb4217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 10:47:00 +0200 Subject: [PATCH 05/24] respect the DOXYGEN environment variable when building docs --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index 582bc74d..ca63efb8 100644 --- a/wscript +++ b/wscript @@ -774,7 +774,7 @@ def build(bld): Logs.pprint('CYAN', "Removing doxygen generated documentation done.") elif bld.cmd =='build': if not os.access(html_docs_source_dir, os.R_OK): - os.popen("doxygen").read() + os.popen(bld.env.DOXYGEN).read() else: Logs.pprint('CYAN', "doxygen documentation already built.") From b8b68cadad936816bc7e3f3ddcb54ea719109f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 11:14:23 +0200 Subject: [PATCH 06/24] do not share the private AutoOption lists and results between different instances of the class --- wscript | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/wscript b/wscript index ca63efb8..83d1e68d 100644 --- a/wscript +++ b/wscript @@ -102,31 +102,31 @@ class AutoOption: __init__. """ - # check hook to call upon configuration - check_hook = None - check_hook_error = None - check_hook_found = True + def __init__(self, opt, name, help, conf_dest=None, define=None): + # check hook to call upon configuration + self.check_hook = None + self.check_hook_error = None + self.check_hook_found = True - # required libraries - libs = [] # elements on the form [lib,uselib_store] - libs_not_found = [] # elements on the form lib + # required libraries + self.libs = [] # elements on the form [lib,uselib_store] + self.libs_not_found = [] # elements on the form lib - # required headers - headers = [] - headers_not_found = [] + # required headers + self.headers = [] + self.headers_not_found = [] - # required packages (checked with pkg-config) - packages = [] # elements on the form [package,uselib_store,atleast_version] - packages_not_found = [] # elements on the form [package,atleast_version] + # required packages (checked with pkg-config) + self.packages = [] # elements on the form [package,uselib_store,atleast_version] + self.packages_not_found = [] # elements on the form [package,atleast_version] - # required programs - programs = [] # elements on the form [program,var] - programs_not_found = [] # elements on the form program + # required programs + self.programs = [] # elements on the form [program,var] + self.programs_not_found = [] # elements on the form program - # the result of the configuration (should the option be enabled or not?) - result = False + # the result of the configuration (should the option be enabled or not?) + self.result = False - def __init__(self, opt, name, help, conf_dest=None, define=None): self.help = help self.option = '--' + name self.dest = 'auto_option_' + name From 61421de45630ce5c410346060b6e8a84ef346a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 11:16:22 +0200 Subject: [PATCH 07/24] fix a typo in _configure_error in the AutoOption class --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index 83d1e68d..6111a616 100644 --- a/wscript +++ b/wscript @@ -273,7 +273,7 @@ class AutoOption: print_error('%s requires the package %s, but it cannot be found.' % (self.option, string)) for program in self.programs_not_found: - print_error('%s requires the %s program, but it cannot be found.', (self.option, program)) + print_error('%s requires the %s program, but it cannot be found.' % (self.option, program)) if not self.check_hook_found: self.check_hook_error(conf) From 97499df9c04f97766ea30b1976e0b2c2769808ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 11:24:15 +0200 Subject: [PATCH 08/24] make build option --alsa an auto option --- linux/wscript | 3 --- wscript | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/linux/wscript b/linux/wscript index df2debec..f7f0752d 100644 --- a/linux/wscript +++ b/linux/wscript @@ -4,9 +4,6 @@ from waflib import Context def configure(conf): - conf.check_cfg(package='alsa', atleast_version='1.0.18', args='--cflags --libs', mandatory=False) - conf.env['BUILD_DRIVER_ALSA'] = conf.is_defined('HAVE_ALSA') - conf. check_cfg(package='libfreebob', atleast_version='1.0.0', args='--cflags --libs', mandatory=False) conf.env['BUILD_DRIVER_FREEBOB'] = conf.is_defined('HAVE_LIBFREEBOB') diff --git a/wscript b/wscript index 6111a616..3d4f4850 100644 --- a/wscript +++ b/wscript @@ -390,7 +390,8 @@ def options(opt): # options with third party dependencies doxygen = add_auto_option(opt, 'doxygen', help='Build doxygen documentation', conf_dest='BUILD_DOXYGEN_DOCS') doxygen.add_program('doxygen') - opt.add_option('--alsa', action='store_true', default=False, help='Enable ALSA driver') + alsa = add_auto_option(opt, 'alsa', help='Enable ALSA driver', conf_dest='BUILD_DRIVER_ALSA') + alsa.add_package('alsa', atleast_version='1.0.18') opt.add_option('--firewire', action='store_true', default=False, help='Enable FireWire driver (FFADO)') opt.add_option('--freebob', action='store_true', default=False, help='Enable FreeBob driver') opt.add_option('--iio', action='store_true', default=False, help='Enable IIO driver') @@ -461,15 +462,12 @@ def configure(conf): conf.sub_config('common') if conf.env['IS_LINUX']: conf.sub_config('linux') - if Options.options.alsa and not conf.env['BUILD_DRIVER_ALSA']: - conf.fatal('ALSA driver was explicitly requested but cannot be built') if Options.options.freebob and not conf.env['BUILD_DRIVER_FREEBOB']: conf.fatal('FreeBob driver was explicitly requested but cannot be built') if Options.options.firewire and not conf.env['BUILD_DRIVER_FFADO']: conf.fatal('FFADO driver was explicitly requested but cannot be built') if Options.options.iio and not conf.env['BUILD_DRIVER_IIO']: conf.fatal('IIO driver was explicitly requested but cannot be built') - conf.env['BUILD_DRIVER_ALSA'] = Options.options.alsa conf.env['BUILD_DRIVER_FFADO'] = Options.options.firewire conf.env['BUILD_DRIVER_FREEBOB'] = Options.options.freebob conf.env['BUILD_DRIVER_IIO'] = Options.options.iio @@ -669,7 +667,6 @@ def configure(conf): display_auto_options_messages() if conf.env['IS_LINUX']: - display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True) display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True) display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True) display_feature('Build with IIO support', conf.env['BUILD_DRIVER_IIO'] == True) From 1b27e13418ab0acb6f7956f5b8f0111908d5dc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 11:51:10 +0200 Subject: [PATCH 09/24] make build option --firewire an auto option --- linux/wscript | 3 --- wscript | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/linux/wscript b/linux/wscript index f7f0752d..1aee0aae 100644 --- a/linux/wscript +++ b/linux/wscript @@ -7,9 +7,6 @@ def configure(conf): conf. check_cfg(package='libfreebob', atleast_version='1.0.0', args='--cflags --libs', mandatory=False) conf.env['BUILD_DRIVER_FREEBOB'] = conf.is_defined('HAVE_LIBFREEBOB') - conf. check_cfg(package='libffado', atleast_version='1.999.17', args='--cflags --libs', mandatory=False) - conf.env['BUILD_DRIVER_FFADO'] = conf.is_defined('HAVE_LIBFFADO') - conf.define('HAVE_PPOLL', 1 ) conf.check_cfg(package='gtkIOStream', atleast_version='1.4.0', args='--cflags --libs', mandatory=False) diff --git a/wscript b/wscript index 3d4f4850..3fa93715 100644 --- a/wscript +++ b/wscript @@ -392,7 +392,8 @@ def options(opt): doxygen.add_program('doxygen') alsa = add_auto_option(opt, 'alsa', help='Enable ALSA driver', conf_dest='BUILD_DRIVER_ALSA') alsa.add_package('alsa', atleast_version='1.0.18') - opt.add_option('--firewire', action='store_true', default=False, help='Enable FireWire driver (FFADO)') + firewire = add_auto_option(opt, 'firewire', help='Enable FireWire driver (FFADO)', conf_dest='BUILD_DRIVER_FFADO') + firewire.add_package('libffado', atleast_version='1.999.17') opt.add_option('--freebob', action='store_true', default=False, help='Enable FreeBob driver') opt.add_option('--iio', action='store_true', default=False, help='Enable IIO driver') opt.add_option('--portaudio', action='store_true', default=False, help='Enable Portaudio driver') @@ -464,11 +465,8 @@ def configure(conf): conf.sub_config('linux') if Options.options.freebob and not conf.env['BUILD_DRIVER_FREEBOB']: conf.fatal('FreeBob driver was explicitly requested but cannot be built') - if Options.options.firewire and not conf.env['BUILD_DRIVER_FFADO']: - conf.fatal('FFADO driver was explicitly requested but cannot be built') if Options.options.iio and not conf.env['BUILD_DRIVER_IIO']: conf.fatal('IIO driver was explicitly requested but cannot be built') - conf.env['BUILD_DRIVER_FFADO'] = Options.options.firewire conf.env['BUILD_DRIVER_FREEBOB'] = Options.options.freebob conf.env['BUILD_DRIVER_IIO'] = Options.options.iio if conf.env['IS_WINDOWS']: @@ -668,7 +666,6 @@ def configure(conf): if conf.env['IS_LINUX']: display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True) - display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True) display_feature('Build with IIO support', conf.env['BUILD_DRIVER_IIO'] == True) if conf.env['IS_WINDOWS']: From 5586a5b88db76d03e25dca7eab38f6cee03cc9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 12:05:16 +0200 Subject: [PATCH 10/24] make build option --freebob an auto option --- linux/wscript | 3 --- wscript | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/linux/wscript b/linux/wscript index 1aee0aae..4e2e8962 100644 --- a/linux/wscript +++ b/linux/wscript @@ -4,9 +4,6 @@ from waflib import Context def configure(conf): - conf. check_cfg(package='libfreebob', atleast_version='1.0.0', args='--cflags --libs', mandatory=False) - conf.env['BUILD_DRIVER_FREEBOB'] = conf.is_defined('HAVE_LIBFREEBOB') - conf.define('HAVE_PPOLL', 1 ) conf.check_cfg(package='gtkIOStream', atleast_version='1.4.0', args='--cflags --libs', mandatory=False) diff --git a/wscript b/wscript index 3fa93715..1f72729a 100644 --- a/wscript +++ b/wscript @@ -394,7 +394,8 @@ def options(opt): alsa.add_package('alsa', atleast_version='1.0.18') firewire = add_auto_option(opt, 'firewire', help='Enable FireWire driver (FFADO)', conf_dest='BUILD_DRIVER_FFADO') firewire.add_package('libffado', atleast_version='1.999.17') - opt.add_option('--freebob', action='store_true', default=False, help='Enable FreeBob driver') + freebob = add_auto_option(opt, 'freebob', help='Enable FreeBob driver') + freebob.add_package('libfreebob', atleast_version='1.0.0') opt.add_option('--iio', action='store_true', default=False, help='Enable IIO driver') opt.add_option('--portaudio', action='store_true', default=False, help='Enable Portaudio driver') opt.add_option('--winmme', action='store_true', default=False, help='Enable WinMME driver') @@ -463,11 +464,8 @@ def configure(conf): conf.sub_config('common') if conf.env['IS_LINUX']: conf.sub_config('linux') - if Options.options.freebob and not conf.env['BUILD_DRIVER_FREEBOB']: - conf.fatal('FreeBob driver was explicitly requested but cannot be built') if Options.options.iio and not conf.env['BUILD_DRIVER_IIO']: conf.fatal('IIO driver was explicitly requested but cannot be built') - conf.env['BUILD_DRIVER_FREEBOB'] = Options.options.freebob conf.env['BUILD_DRIVER_IIO'] = Options.options.iio if conf.env['IS_WINDOWS']: conf.sub_config('windows') @@ -665,7 +663,6 @@ def configure(conf): display_auto_options_messages() if conf.env['IS_LINUX']: - display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True) display_feature('Build with IIO support', conf.env['BUILD_DRIVER_IIO'] == True) if conf.env['IS_WINDOWS']: From b77fa414f5aad2c9a0ec1f763b3765b899a7f1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 12:20:39 +0200 Subject: [PATCH 11/24] make build option --iio an auto option --- linux/wscript | 5 ----- wscript | 10 +++------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/linux/wscript b/linux/wscript index 4e2e8962..cb4b9d3f 100644 --- a/linux/wscript +++ b/linux/wscript @@ -6,11 +6,6 @@ from waflib import Context def configure(conf): conf.define('HAVE_PPOLL', 1 ) - conf.check_cfg(package='gtkIOStream', atleast_version='1.4.0', args='--cflags --libs', mandatory=False) - conf.env['BUILD_DRIVER_IIO'] = conf.is_defined('HAVE_GTKIOSTREAM') - conf.check_cfg(package='eigen3', atleast_version='3.1.2', args='--cflags --libs', mandatory=False) - conf.env['BUILD_DRIVER_IIO'] += conf.is_defined('HAVE_EIGEN3') - def create_jack_driver_obj(bld, target, sources, uselib = None): driver = bld(features = ['c', 'cxx', 'cxxshlib', 'cshlib']) driver.env['cxxshlib_PATTERN'] = 'jack_%s.so' diff --git a/wscript b/wscript index 1f72729a..0fe010b2 100644 --- a/wscript +++ b/wscript @@ -396,7 +396,9 @@ def options(opt): firewire.add_package('libffado', atleast_version='1.999.17') freebob = add_auto_option(opt, 'freebob', help='Enable FreeBob driver') freebob.add_package('libfreebob', atleast_version='1.0.0') - opt.add_option('--iio', action='store_true', default=False, help='Enable IIO driver') + iio = add_auto_option(opt, 'iio', help='Enable IIO driver', conf_dest='BUILD_DRIVER_IIO') + iio.add_package('gtkIOStream', atleast_version='1.4.0') + iio.add_package('eigen3', atleast_version='3.1.2') opt.add_option('--portaudio', action='store_true', default=False, help='Enable Portaudio driver') opt.add_option('--winmme', action='store_true', default=False, help='Enable WinMME driver') @@ -464,9 +466,6 @@ def configure(conf): conf.sub_config('common') if conf.env['IS_LINUX']: conf.sub_config('linux') - if Options.options.iio and not conf.env['BUILD_DRIVER_IIO']: - conf.fatal('IIO driver was explicitly requested but cannot be built') - conf.env['BUILD_DRIVER_IIO'] = Options.options.iio if conf.env['IS_WINDOWS']: conf.sub_config('windows') if Options.options.portaudio and not conf.env['BUILD_DRIVER_PORTAUDIO']: @@ -662,9 +661,6 @@ def configure(conf): # display configuration result messages for auto options display_auto_options_messages() - if conf.env['IS_LINUX']: - display_feature('Build with IIO support', conf.env['BUILD_DRIVER_IIO'] == True) - if conf.env['IS_WINDOWS']: display_feature('Build with WinMME support', conf.env['BUILD_DRIVER_WINMME'] == True) display_feature('Build with Portaudio support', conf.env['BUILD_DRIVER_PORTAUDIO'] == True) From fcec68f9032e7b53fe6eb8e205aac9aafe95ad01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 12:35:01 +0200 Subject: [PATCH 12/24] make build option --portaudio an auto option --- windows/wscript | 4 ---- wscript | 10 ++++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/windows/wscript b/windows/wscript index ea4dd3d9..ec17887f 100644 --- a/windows/wscript +++ b/windows/wscript @@ -1,10 +1,6 @@ #! /usr/bin/env python # encoding: utf-8 -def configure(conf): - conf.check_cfg(package='portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19', args='--cflags --libs') - conf.env['BUILD_DRIVER_PORTAUDIO'] = conf.is_defined('HAVE_PORTAUDIO') - def create_jack_driver_obj(bld, target, sources, uselib = None): driver = bld(features = ['c', 'cxx', 'cxxshlib', 'cshlib']) driver.env['cxxshlib_PATTERN'] = 'jack_%s.dll' diff --git a/wscript b/wscript index 0fe010b2..9e7af263 100644 --- a/wscript +++ b/wscript @@ -399,7 +399,9 @@ def options(opt): iio = add_auto_option(opt, 'iio', help='Enable IIO driver', conf_dest='BUILD_DRIVER_IIO') iio.add_package('gtkIOStream', atleast_version='1.4.0') iio.add_package('eigen3', atleast_version='3.1.2') - opt.add_option('--portaudio', action='store_true', default=False, help='Enable Portaudio driver') + portaudio = add_auto_option(opt, 'portaudio', help='Enable Portaudio driver', conf_dest='BUILD_DRIVER_PORTAUDIO') + portaudio.add_header('windows.h') # only build portaudio on windows + portaudio.add_package('portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19') opt.add_option('--winmme', action='store_true', default=False, help='Enable WinMME driver') # dbus options @@ -467,10 +469,7 @@ def configure(conf): if conf.env['IS_LINUX']: conf.sub_config('linux') if conf.env['IS_WINDOWS']: - conf.sub_config('windows') - if Options.options.portaudio and not conf.env['BUILD_DRIVER_PORTAUDIO']: - conf.fatal('Portaudio driver was explicitly requested but cannot be built') - conf.env['BUILD_DRIVER_WINMME'] = Options.options.winmme + conf.env['BUILD_DRIVER_WINMME'] = Options.options.winmme if Options.options.dbus: conf.sub_config('dbus') if conf.env['BUILD_JACKDBUS'] != True: @@ -663,7 +662,6 @@ def configure(conf): if conf.env['IS_WINDOWS']: display_feature('Build with WinMME support', conf.env['BUILD_DRIVER_WINMME'] == True) - display_feature('Build with Portaudio support', conf.env['BUILD_DRIVER_PORTAUDIO'] == True) if conf.env['BUILD_JACKDBUS'] == True: display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN') From b0c4633a7552fd57701492b15aaafe6198559ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 12:40:38 +0200 Subject: [PATCH 13/24] make build option --winmme an auto option and use mmsystem.h and windows.h to check if winmme can be built --- wscript | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/wscript b/wscript index 9e7af263..ce13277e 100644 --- a/wscript +++ b/wscript @@ -402,7 +402,9 @@ def options(opt): portaudio = add_auto_option(opt, 'portaudio', help='Enable Portaudio driver', conf_dest='BUILD_DRIVER_PORTAUDIO') portaudio.add_header('windows.h') # only build portaudio on windows portaudio.add_package('portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19') - opt.add_option('--winmme', action='store_true', default=False, help='Enable WinMME driver') + winmme = add_auto_option(opt, 'winmme', help='Enable WinMME driver', conf_dest='BUILD_DRIVER_WINMME') + winmme.add_header('mmsystem.h') + winmme.add_header('windows.h') # dbus options opt.sub_options('dbus') @@ -468,8 +470,6 @@ def configure(conf): conf.sub_config('common') if conf.env['IS_LINUX']: conf.sub_config('linux') - if conf.env['IS_WINDOWS']: - conf.env['BUILD_DRIVER_WINMME'] = Options.options.winmme if Options.options.dbus: conf.sub_config('dbus') if conf.env['BUILD_JACKDBUS'] != True: @@ -660,9 +660,6 @@ def configure(conf): # display configuration result messages for auto options display_auto_options_messages() - if conf.env['IS_WINDOWS']: - display_feature('Build with WinMME support', conf.env['BUILD_DRIVER_WINMME'] == True) - if conf.env['BUILD_JACKDBUS'] == True: display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN') #display_msg('Settings persistence', xxx) From 170c0d5f399e3c655fc4bfd0e0f6141aaf4130fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 15:54:00 +0200 Subject: [PATCH 14/24] add the --celt auto option and rewrite the celt check using a smaller loop (drop conf.define('HAVE_CELT', ...) since the AutoOption class handles this) --- wscript | 52 +++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/wscript b/wscript index ce13277e..a112a909 100644 --- a/wscript +++ b/wscript @@ -364,6 +364,24 @@ def display_auto_options_messages(): for option in auto_options: option.display_message() +def check_for_celt(conf): + found = False + for version in ['11', '8', '7', '5']: + define = 'HAVE_CELT_API_0_' + version + if not found: + try: + conf.check_cfg(package='celt', atleast_version='0.' + version + '.0', args='--cflags --libs') + found = True + conf.define(define, 1) + continue + except conf.errors.ConfigurationError: + pass + conf.define(define, 0) + return found + +def check_for_celt_error(conf): + print_error('--celt requires the package celt, but it could not be found.') + def options(opt): # options provided by the modules opt.tool_options('compiler_cxx') @@ -406,6 +424,9 @@ def options(opt): winmme.add_header('mmsystem.h') winmme.add_header('windows.h') + celt = add_auto_option(opt, 'celt', help='Build with CELT') + celt.set_check_hook(check_for_celt, check_for_celt_error) + # dbus options opt.sub_options('dbus') @@ -482,37 +503,6 @@ def configure(conf): conf.sub_config('example-clients') - if conf.check_cfg(package='celt', atleast_version='0.11.0', args='--cflags --libs', mandatory=False): - conf.define('HAVE_CELT', 1) - conf.define('HAVE_CELT_API_0_11', 1) - conf.define('HAVE_CELT_API_0_8', 0) - conf.define('HAVE_CELT_API_0_7', 0) - conf.define('HAVE_CELT_API_0_5', 0) - elif conf.check_cfg(package='celt', atleast_version='0.8.0', args='--cflags --libs', mandatory=False): - conf.define('HAVE_CELT', 1) - conf.define('HAVE_CELT_API_0_11', 0) - conf.define('HAVE_CELT_API_0_8', 1) - conf.define('HAVE_CELT_API_0_7', 0) - conf.define('HAVE_CELT_API_0_5', 0) - elif conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs', mandatory=False): - conf.define('HAVE_CELT', 1) - conf.define('HAVE_CELT_API_0_11', 0) - conf.define('HAVE_CELT_API_0_8', 0) - conf.define('HAVE_CELT_API_0_7', 1) - conf.define('HAVE_CELT_API_0_5', 0) - elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', mandatory=False): - conf.define('HAVE_CELT', 1) - conf.define('HAVE_CELT_API_0_11', 0) - conf.define('HAVE_CELT_API_0_8', 0) - conf.define('HAVE_CELT_API_0_7', 0) - conf.define('HAVE_CELT_API_0_5', 1) - else: - conf.define('HAVE_CELT', 0) - conf.define('HAVE_CELT_API_0_11', 0) - conf.define('HAVE_CELT_API_0_8', 0) - conf.define('HAVE_CELT_API_0_7', 0) - conf.define('HAVE_CELT_API_0_5', 0) - conf.env['WITH_OPUS'] = False if conf.check_cfg(package='opus', atleast_version='0.9.0' , args='--cflags --libs', mandatory=False): if conf.check_cc(header_name='opus/opus_custom.h', mandatory=False): From 66cdd35753697359a467ae8788315fbd159fd73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 15:57:02 +0200 Subject: [PATCH 15/24] remove extra and unnecessary celt check in example-clients --- example-clients/wscript | 2 -- 1 file changed, 2 deletions(-) diff --git a/example-clients/wscript b/example-clients/wscript index ae706e43..4338bdcd 100644 --- a/example-clients/wscript +++ b/example-clients/wscript @@ -41,8 +41,6 @@ def configure(conf): if conf.is_defined('HAVE_SNDFILE'): conf.env['LIB_SNDFILE'] = ['sndfile'] - conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', mandatory=False) - e = conf.check_cc(lib='readline', define_name="HAVE_READLINE", mandatory=False) # define_name="HAVE_READLINE" has no effect, LIB_READLINE is defined if readline is available From 7f2bc7f037b796b446de942da8b77de154f8a04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 16:16:49 +0200 Subject: [PATCH 16/24] add the --opus auto option --- wscript | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/wscript b/wscript index a112a909..d4171731 100644 --- a/wscript +++ b/wscript @@ -426,6 +426,9 @@ def options(opt): celt = add_auto_option(opt, 'celt', help='Build with CELT') celt.set_check_hook(check_for_celt, check_for_celt_error) + opus = add_auto_option(opt, 'opus', help='Build Opus netjack2') + opus.add_header('opus/opus_custom.h') + opus.add_package('opus', atleast_version='0.9.0') # dbus options opt.sub_options('dbus') @@ -503,15 +506,6 @@ def configure(conf): conf.sub_config('example-clients') - conf.env['WITH_OPUS'] = False - if conf.check_cfg(package='opus', atleast_version='0.9.0' , args='--cflags --libs', mandatory=False): - if conf.check_cc(header_name='opus/opus_custom.h', mandatory=False): - conf.define('HAVE_OPUS', 1) - conf.env['WITH_OPUS'] = True - else: - conf.define('HAVE_OPUS', 0) - - conf.env['LIB_PTHREAD'] = ['pthread'] conf.env['LIB_DL'] = ['dl'] conf.env['LIB_RT'] = ['rt'] @@ -635,7 +629,6 @@ def configure(conf): display_msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS'])) display_msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS'])) display_msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS'])) - display_feature('Build Opus netjack2', conf.env['WITH_OPUS']) display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE']) display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64']) From ad24b255beccbd5031f86184c729948c9d42834e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 16:21:55 +0200 Subject: [PATCH 17/24] move check for samplerate.h to before conf.sub_config('common') and remove the duplicate check in common --- common/wscript | 5 ----- wscript | 10 +++++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/common/wscript b/common/wscript index 4302b1e2..bca070a5 100644 --- a/common/wscript +++ b/common/wscript @@ -6,11 +6,6 @@ import re import os def configure(conf): - conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE") - - if conf.is_defined('HAVE_SAMPLERATE'): - conf.env['LIB_SAMPLERATE'] = ['samplerate'] - conf.env['BUILD_NETLIB'] = conf.is_defined('HAVE_SAMPLERATE') conf.env['BUILD_ADAPTER'] = conf.is_defined('HAVE_SAMPLERATE') diff --git a/wscript b/wscript index d4171731..05e081c0 100644 --- a/wscript +++ b/wscript @@ -491,6 +491,11 @@ def configure(conf): # configure all auto options configure_auto_options(conf) + conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE") + + if conf.is_defined('HAVE_SAMPLERATE'): + conf.env['LIB_SAMPLERATE'] = ['samplerate'] + conf.sub_config('common') if conf.env['IS_LINUX']: conf.sub_config('linux') @@ -499,11 +504,6 @@ def configure(conf): if conf.env['BUILD_JACKDBUS'] != True: conf.fatal('jackdbus was explicitly requested but cannot be built') - conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE") - - if conf.is_defined('HAVE_SAMPLERATE'): - conf.env['LIB_SAMPLERATE'] = ['samplerate'] - conf.sub_config('example-clients') conf.env['LIB_PTHREAD'] = ['pthread'] From 94efc64f206e0e2de2b531cf17a2a04c904f7678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 16:28:05 +0200 Subject: [PATCH 18/24] use conf.env['SAMPLERATE'] to determine wether samplerate is available instead of conf.is_defined('HAVE_SAMPLERATE') --- common/wscript | 4 ++-- example-clients/wscript | 2 +- wscript | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/wscript b/common/wscript index bca070a5..10ed9c25 100644 --- a/common/wscript +++ b/common/wscript @@ -6,8 +6,8 @@ import re import os def configure(conf): - conf.env['BUILD_NETLIB'] = conf.is_defined('HAVE_SAMPLERATE') - conf.env['BUILD_ADAPTER'] = conf.is_defined('HAVE_SAMPLERATE') + conf.env['BUILD_NETLIB'] = conf.env['SAMPLERATE'] + conf.env['BUILD_ADAPTER'] = conf.env['SAMPLERATE'] if conf.env['IS_WINDOWS']: try: diff --git a/example-clients/wscript b/example-clients/wscript index 4338bdcd..02c60bfd 100644 --- a/example-clients/wscript +++ b/example-clients/wscript @@ -51,7 +51,7 @@ def configure(conf): conf.env['BUILD_EXAMPLE_CLIENT_REC'] = conf.is_defined('HAVE_SNDFILE') - conf.env['BUILD_EXAMPLE_ALSA_IO'] = conf.is_defined('HAVE_SAMPLERATE') and conf.env['BUILD_DRIVER_ALSA'] + conf.env['BUILD_EXAMPLE_ALSA_IO'] = conf.env['SAMPLERATE'] and conf.env['BUILD_DRIVER_ALSA'] def build(bld): if bld.env['IS_LINUX']: diff --git a/wscript b/wscript index 05e081c0..d2f39ddc 100644 --- a/wscript +++ b/wscript @@ -495,6 +495,9 @@ def configure(conf): if conf.is_defined('HAVE_SAMPLERATE'): conf.env['LIB_SAMPLERATE'] = ['samplerate'] + conf.env['SAMPLERATE'] = True + else: + conf.env['SAMPLERATE'] = False conf.sub_config('common') if conf.env['IS_LINUX']: From 7a5793d9e4c79abe4dd676a5d713c744bb49e84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 16:39:39 +0200 Subject: [PATCH 19/24] add the --samplerate auto option and use pkg-config to find samplerate (the AutoOption class takes care of defining env['SAMPLERATE'] and HAVE_SAMPLERATE) --- wscript | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/wscript b/wscript index d2f39ddc..7e6ccaa2 100644 --- a/wscript +++ b/wscript @@ -429,6 +429,8 @@ def options(opt): opus = add_auto_option(opt, 'opus', help='Build Opus netjack2') opus.add_header('opus/opus_custom.h') opus.add_package('opus', atleast_version='0.9.0') + samplerate = add_auto_option(opt, 'samplerate', help='Build with libsamplerate') + samplerate.add_package('samplerate') # dbus options opt.sub_options('dbus') @@ -491,14 +493,6 @@ def configure(conf): # configure all auto options configure_auto_options(conf) - conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE") - - if conf.is_defined('HAVE_SAMPLERATE'): - conf.env['LIB_SAMPLERATE'] = ['samplerate'] - conf.env['SAMPLERATE'] = True - else: - conf.env['SAMPLERATE'] = False - conf.sub_config('common') if conf.env['IS_LINUX']: conf.sub_config('linux') From aef035ad1f1940d6d6af02efd7269ca30c106451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 16:50:48 +0200 Subject: [PATCH 20/24] make sndfile dependency optional --- example-clients/wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example-clients/wscript b/example-clients/wscript index 02c60bfd..232b4891 100644 --- a/example-clients/wscript +++ b/example-clients/wscript @@ -36,7 +36,7 @@ example_libs = { } def configure(conf): - e = conf.check_cc(header_name='sndfile.h', define_name="HAVE_SNDFILE") + e = conf.check_cc(header_name='sndfile.h', define_name="HAVE_SNDFILE", mandatory=False) if conf.is_defined('HAVE_SNDFILE'): conf.env['LIB_SNDFILE'] = ['sndfile'] From ea43b15ea9d753720a00931242a882925ee48e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 16:54:20 +0200 Subject: [PATCH 21/24] use pkg-config to find sndfile (drop explicit LIB_SNDFILE and HAVE_SNDFILE since check_cfg deals with it) --- example-clients/wscript | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/example-clients/wscript b/example-clients/wscript index 232b4891..f834e8a2 100644 --- a/example-clients/wscript +++ b/example-clients/wscript @@ -36,11 +36,8 @@ example_libs = { } def configure(conf): - e = conf.check_cc(header_name='sndfile.h', define_name="HAVE_SNDFILE", mandatory=False) + conf.check_cfg(package='sndfile', args='--cflags --libs', mandatory=False) - if conf.is_defined('HAVE_SNDFILE'): - conf.env['LIB_SNDFILE'] = ['sndfile'] - e = conf.check_cc(lib='readline', define_name="HAVE_READLINE", mandatory=False) # define_name="HAVE_READLINE" has no effect, LIB_READLINE is defined if readline is available From bac7cc775de4461b5833f27cb13153839bb7cba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 17:02:30 +0200 Subject: [PATCH 22/24] add the --sndfile auto option and check sndfile availability with env['SNDFILE'] instead of is_defined('HAVE_SNDFILE') --- example-clients/wscript | 4 +--- wscript | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example-clients/wscript b/example-clients/wscript index f834e8a2..0c8f32da 100644 --- a/example-clients/wscript +++ b/example-clients/wscript @@ -36,8 +36,6 @@ example_libs = { } def configure(conf): - conf.check_cfg(package='sndfile', args='--cflags --libs', mandatory=False) - e = conf.check_cc(lib='readline', define_name="HAVE_READLINE", mandatory=False) # define_name="HAVE_READLINE" has no effect, LIB_READLINE is defined if readline is available @@ -46,7 +44,7 @@ def configure(conf): conf.env['BUILD_EXAMPLE_CLIENT_TRANSPORT'] = bool(conf.env['LIB_READLINE']) - conf.env['BUILD_EXAMPLE_CLIENT_REC'] = conf.is_defined('HAVE_SNDFILE') + conf.env['BUILD_EXAMPLE_CLIENT_REC'] = conf.env['SNDFILE'] conf.env['BUILD_EXAMPLE_ALSA_IO'] = conf.env['SAMPLERATE'] and conf.env['BUILD_DRIVER_ALSA'] diff --git a/wscript b/wscript index 7e6ccaa2..5d03cd18 100644 --- a/wscript +++ b/wscript @@ -431,6 +431,8 @@ def options(opt): opus.add_package('opus', atleast_version='0.9.0') samplerate = add_auto_option(opt, 'samplerate', help='Build with libsamplerate') samplerate.add_package('samplerate') + sndfile = add_auto_option(opt, 'sndfile', help='Build with libsndfile') + sndfile.add_package('sndfile') # dbus options opt.sub_options('dbus') From 5a59aef94c68053e9d298124d9c7e125976871dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 17:11:34 +0200 Subject: [PATCH 23/24] add the --readline auto option --- example-clients/wscript | 8 +------- wscript | 2 ++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/example-clients/wscript b/example-clients/wscript index 0c8f32da..cee04cc2 100644 --- a/example-clients/wscript +++ b/example-clients/wscript @@ -36,13 +36,7 @@ example_libs = { } def configure(conf): - e = conf.check_cc(lib='readline', define_name="HAVE_READLINE", mandatory=False) - - # define_name="HAVE_READLINE" has no effect, LIB_READLINE is defined if readline is available - #if conf.is_defined('HAVE_READLINE'): - # conf.env['LIB_READLINE'] = ['readline'] - - conf.env['BUILD_EXAMPLE_CLIENT_TRANSPORT'] = bool(conf.env['LIB_READLINE']) + conf.env['BUILD_EXAMPLE_CLIENT_TRANSPORT'] = conf.env['READLINE'] conf.env['BUILD_EXAMPLE_CLIENT_REC'] = conf.env['SNDFILE'] diff --git a/wscript b/wscript index 5d03cd18..05d79ddc 100644 --- a/wscript +++ b/wscript @@ -433,6 +433,8 @@ def options(opt): samplerate.add_package('samplerate') sndfile = add_auto_option(opt, 'sndfile', help='Build with libsndfile') sndfile.add_package('sndfile') + readline = add_auto_option(opt, 'readline', help='Build with readline') + readline.add_library('readline') # dbus options opt.sub_options('dbus') From 9b2ad3b05d138123ba0a4eb8497d41578491775e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Lind=C3=A9n?= Date: Fri, 10 Apr 2015 17:26:26 +0200 Subject: [PATCH 24/24] add a custom check for readline/readline.h that works around the header's stdio.h dependeny --- wscript | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wscript b/wscript index 05d79ddc..ac98fe9b 100644 --- a/wscript +++ b/wscript @@ -382,6 +382,24 @@ def check_for_celt(conf): def check_for_celt_error(conf): print_error('--celt requires the package celt, but it could not be found.') +# The readline/readline.h header does not work if stdio.h is not included +# before. Thus a fragment with both stdio.h and readline/readline.h need to be +# test-compiled to find out whether readline is available. +def check_for_readline(conf): + try: + conf.check_cc(fragment=''' + #include + #include + int main(void) { return 0; }''', + execute=False, + msg='Checking for header readline/readline.h') + return True + except conf.errors.ConfigurationError: + return False + +def check_for_readline_error(conf): + print_error('--readline requires the readline/readline.h header, but it cannot be found.') + def options(opt): # options provided by the modules opt.tool_options('compiler_cxx') @@ -435,6 +453,7 @@ def options(opt): sndfile.add_package('sndfile') readline = add_auto_option(opt, 'readline', help='Build with readline') readline.add_library('readline') + readline.set_check_hook(check_for_readline, check_for_readline_error) # dbus options opt.sub_options('dbus')