# Patch to change the order of the checks for jack version. See
# http://subversion.ffado.org/ticket/381 for more information.
# Applied upstream.

Index: SConstruct
===================================================================
--- SConstruct	(revision 2574)
+++ SConstruct	(revision 2575)
@@ -250,21 +250,21 @@
     # 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.121.4'))
-        good_jack2 = (jackd_ver >= VersionInt('1.9.9'))
+    have_jack = conf.CheckPKG('jack')
+    if have_jack:
+        good_jack1 = conf.CheckPKG('jack < 1.9.0') and conf.CheckPKG('jack >= 0.121.4')
+        good_jack2 = conf.CheckPKG('jack >= 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')
+        jackd_ver = CheckJackdVer()
+        if (jackd_ver != -1):
+            # If jackd is unknown to pkg-config but is never-the-less
+            # runnable, 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.121.4'))
+            good_jack2 = (jackd_ver >= VersionInt('1.9.9'))
+
     if env['ENABLE_SETBUFFERSIZE_API_VER'] == 'auto':
         if not(have_jack):
             print """
