# AUTHOR: lilrc <lilrc@users-sourceforge.net>
# A patch to avoid calling jackd --version from within the build system
# which generates a sandbox violation. Instead use pkgconfig as jack
# will install the necessary pkgconfig files.

diff -ur libffado-2.1.0.a/SConstruct libffado-2.1.0.b/SConstruct
--- libffado-2.1.0.a/SConstruct	2013-04-01 12:55:08.239992516 +0200
+++ libffado-2.1.0.b/SConstruct	2013-04-01 13:54:42.019972442 +0200
@@ -194,16 +194,6 @@
     # restricted to 0-255.
     return (int(maj) << 24) | (int(min) << 8) | int(patch)
 
-def CheckJackdVer():
-    print 'Checking jackd version...',
-    ret = Popen("which jackd >/dev/null 2>&1 && jackd --version | cut -d ' ' -f 3", shell=True, stdout=PIPE).stdout.read()[:-1]
-    if (ret == ""):
-        print "not installed"
-        return -1
-    else:
-        print ret
-    return VersionInt(ret)
-
 if env['SERIALIZE_USE_EXPAT']:
     env['SERIALIZE_USE_EXPAT']=1
 else:
@@ -248,24 +238,9 @@
     if not env['SERIALIZE_USE_EXPAT']:
         pkgs['libxml++-2.6'] = '2.13.0'
 
-    # Provide a way for users to compile newer libffado which will work 
-    # against older jack installations which will not accept the new API
-    # version reported at runtime.
-    jackd_ver = CheckJackdVer()
-    if (jackd_ver != -1):
-        # If jackd is available, use the version number reported by it.  This
-        # means users don't have to have jack development files present on
-        # their system for this to work.
-        have_jack = (jackd_ver >= VersionInt('0.0.0'))
-        good_jack1 = (jackd_ver < VersionInt('1.9.0')) and (jackd_ver >= VersionInt('0.122.0'))
-        good_jack2 = (jackd_ver >= VersionInt('1.9.9'))
-    else:
-        # Jackd is not runnable.  Attempt to identify a version from
-        # pkgconfig on the off-chance jack details are available from there.
-        print "Will retry jack detection using pkg-config"
-        have_jack = conf.CheckPKG('jack >= 0.0.0')
-        good_jack1 = conf.CheckPKG('jack < 1.9.0') and conf.CheckPKG('jack >= 0.122.0')
-        good_jack2 = conf.CheckPKG('jack >= 1.9.9')
+    have_jack = conf.CheckPKG('jack >= 0.0.0')
+    good_jack1 = conf.CheckPKG('jack < 1.9.0') and conf.CheckPKG('jack >= 0.122.0')
+    good_jack2 = conf.CheckPKG('jack >= 1.9.9')
     if env['ENABLE_SETBUFFERSIZE_API_VER'] == 'auto':
         if not(have_jack):
             print """
diff -ur libffado-2.1.0.a/support/tools/ffado-diag-static libffado-2.1.0.b/support/tools/ffado-diag-static
--- libffado-2.1.0.a/support/tools/ffado-diag-static	2010-05-03 21:37:15.000000000 +0200
+++ libffado-2.1.0.b/support/tools/ffado-diag-static	2013-04-02 17:45:15.924979761 +0200
@@ -75,7 +75,7 @@
     print "   gcc ............... %s" % get_version_first_line('gcc --version')
     print "   g++ ............... %s" % get_version_first_line('g++ --version')
     print "   PyQt4 (by pyuic4) . %s" % get_version_first_line('pyuic4 --version')
-    print "   jackd ............. %s" % get_version_first_line('jackd --version')
+    print "   jackd ............. %s" % get_version_first_line('pkg-config --modversion jack')
     print "     path ............ %s" % get_command_path('jackd')
     print "     flags ........... %s" % get_package_flags("jack")
     print "   libraw1394 ........ %s" % get_package_version("libraw1394")
