use weak-jack's jack_port_rename wrapper
[ardour.git] / libs / backends / jack / wscript
index 73b2005f84f78d84df1eea698b68ff4f689d587d..09a7c227f728b9177aeb1badad97032e8f03f346 100644 (file)
@@ -1,14 +1,10 @@
 #!/usr/bin/env python
 from waflib.extras import autowaf as autowaf
+from waflib import Options
 import os
 import sys
 import re
 
-# Library version (UNIX style major, minor, micro)
-# major increment <=> incompatible changes
-# minor increment <=> compatible changes (additions)
-# micro increment <=> no interface changes
-JACKBACKEND_VERSION = '1.0.0'
 I18N_PACKAGE = 'jack-backend'
 
 # Mandatory variables
@@ -19,10 +15,53 @@ def options(opt):
     autowaf.set_options(opt)
 
 def configure(conf):
+    autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.121.0')
+
+    #
+    # PortAudio is currently used to get a list of audio device names.
+    # We should find a better way to do this that doesn't involve this
+    # kind of dependency.
+    #
+    if Options.options.dist_target == 'mingw':
+        autowaf.check_pkg(conf, 'portaudio-2.0', uselib_store='PORTAUDIO',
+                          atleast_version='19')
     autowaf.configure(conf)
 
+    if Options.options.libjack_link == 'auto':
+        if Options.options.dist_target == 'mingw' or sys.platform == 'darwin':
+            conf.env['libjack_link'] = "weak"
+        else:
+            conf.env['libjack_link'] = "link"
+    elif Options.options.libjack_link == 'weak':
+        conf.env['libjack_link'] = "weak"
+    else:
+        conf.env['libjack_link'] = "link"
+
+    # Check that metadata API is available and working
+    conf.check_cxx(fragment = "#include <jack/jack.h>\n#include <jack/metadata.h>\nint main(void) { jack_port_uuid(NULL); return 0; }\n",
+                   mandatory = False,
+                   msg = 'Checking for JACK metadata API',
+                   execute = False,
+                   features = ['cxx'],
+                   okmsg = 'ok',
+                   errmsg = 'not found (or broken). JACK metadata API will not be used',
+                   define_name = 'HAVE_JACK_METADATA',
+                   uselib = 'JACK')
+
+    # Check to see if jack_port_rename() is available and working
+    if Options.options.libjack_link == 'link':
+            conf.check_cxx(fragment = "#include <jack/jack.h>\nint main(void) { jack_client_t* c; jack_port_t* p; jack_port_rename (c, p, \"foo\"); return 0; }\n",
+                   mandatory = False,
+                   execute = False,
+                   features = ['cxx'],
+                   msg = 'Checking for jack_port_rename()',
+                   okmsg = 'ok',
+                   errmsg = 'not found (or broken). jack_port_rename() will not be used, and jack_port_set_name() will be used instead',
+                   define_name = 'HAVE_JACK_PORT_RENAME',
+                   uselib = 'JACK')
+
 def build(bld):
-    obj = bld(features = 'cxx cxxshlib')
+    obj = bld(features = 'c cxx cxxshlib')
     obj.source = [ 
             'jack_api.cc',
             'jack_connection.cc',
@@ -30,18 +69,41 @@ def build(bld):
             'jack_portengine.cc',
             'jack_utils.cc',
             'jack_session.cc',
+            'weak_libjack.c',
             ]
     obj.includes = ['.']
-    obj.cxxflags = [ '-fPIC' ]
     obj.name     = 'jack_audiobackend'
     obj.target   = 'jack_audiobackend'
-    obj.uselib   = [ 'JACK' ]
-    obj.use      = 'ardour libpbd'
-    obj.vnum     = JACKBACKEND_VERSION
-    obj.install_path  = os.path.join(bld.env['LIBDIR'], 'ardour3', 'backends')
     obj.defines = ['PACKAGE="' + I18N_PACKAGE + '"', 
                    'ARDOURBACKEND_DLL_EXPORTS'
                    ]
+    obj.use      = 'libardour libpbd ardouralsautil'
+    obj.install_path  = os.path.join(bld.env['LIBDIR'], 'backends')
+    if bld.env['build_target'] != 'mingw':
+        obj.cxxflags = [ '-fPIC' ]
+        obj.cflags   = [ '-fPIC' ]
+    else:
+        obj.cxxflags = [ ]
+        obj.cflags   = [ ]
+
+    if bld.is_defined ('HAVE_JACK_METADATA'):
+        obj.cxxflags += [ '-DHAVE_JACK_METADATA' ]
+        obj.cflags += [ '-DHAVE_JACK_METADATA' ]
+
+    if bld.is_defined ('HAVE_JACK_PORT_RENAME'):
+        obj.cxxflags += [ '-DHAVE_JACK_PORT_RENAME' ]
+        obj.cflags += [ '-DHAVE_JACK_PORT_RENAME' ]
+
+    if (bld.env['build_target'] == 'mingw'):
+        obj.uselib   = [ 'PORTAUDIO' ]
+    else:
+        obj.uselib   = [ ]
+
+    if bld.env['libjack_link'] == 'link':
+        obj.uselib   += [ 'JACK' ]
+    else:
+        obj.defines += [ 'USE_WEAK_JACK', 'HAVE_JACK_PORT_RENAME' ]
+        obj.deps = [ 'weak_libjack.def' ]
 
     #
     # device discovery code in the jack backend needs ALSA