# AUTHOR:      Karl Linden (lilrc)
# DESCRIPTION: Patch to remove the automagic dependency on PyQt and friends.
# STATUS:      Sent upstream as of 26 March 2015.
# SEE:         http://subversion.ffado.org/ticket/391

Index: SConstruct
===================================================================
--- SConstruct	(revision 2587)
+++ SConstruct	(working copy)
@@ -68,6 +68,7 @@
   this code.""", False ),
     BoolVariable( "ENABLE_ALL", "Enable/Disable support for all devices.", False ),
     BoolVariable( "SERIALIZE_USE_EXPAT", "Use libexpat for XML serialization.", False ),
+    EnumVariable( "BUILD_MIXER", "Build the ffado-mixer", 'auto', allowed_values=('auto', 'true', 'false'), ignorecase=2),
     BoolVariable( "BUILD_TESTS", """\
 Build the tests in their directory. As some contain quite some functionality,
   this is on by default.
@@ -379,28 +380,33 @@
 #
 
 # PyQT checks
-build_mixer = False
-if conf.CheckForApp( 'which pyuic4' ) and conf.CheckForPyModule( 'dbus' ) and conf.CheckForPyModule( 'PyQt4' ) and conf.CheckForPyModule( 'dbus.mainloop.qt' ):
-    env['PYUIC4'] = True
-    build_mixer = True
+if env['BUILD_MIXER'] != 'false':
+    if conf.CheckForApp( 'which pyuic4' ) and conf.CheckForPyModule( 'dbus' ) and conf.CheckForPyModule( 'PyQt4' ) and conf.CheckForPyModule( 'dbus.mainloop.qt' ):
+        env['BUILD_MIXER'] = 'true'
+    elif not env.GetOption('clean'):
+        if env['BUILD_MIXER'] == 'auto':
+            env['BUILD_MIXER'] = 'false'
+            print """
+The prerequisites ('pyuic4' and the python-modules 'dbus' and 'PyQt4', the
+packages could be named like dbus-python and PyQt) to build the mixer were not
+found. Therefore the qt4 mixer will not be installed."""
+        else: # env['BUILD_MIXER'] == 'true'
+            print """
+The prerequisites ('pyuic4' and the python-modules 'dbus' and 'PyQt4', the
+packages could be named like dbus-python and PyQt) to build the mixer were not
+found, but BUILD_MIXER was requested."""
+            Exit( 1 )
 
-if conf.CheckForApp( 'xdg-desktop-menu --help' ):
-    env['XDG_TOOLS'] = True
-else:
-    print """
-I couldn't find the program 'xdg-desktop-menu'. Together with xdg-icon-resource
-this is needed to add the fancy entry to your menu. But if the mixer will be
-installed, you can start it by executing "ffado-mixer".
-"""
+env['XDG_TOOLS'] = False
+if env['BUILD_MIXER'] == 'true':
+    if conf.CheckForApp( 'xdg-desktop-menu --help' ) and conf.CheckForApp( 'xdg-icon-resource --help' ):
+        env['XDG_TOOLS'] = True
+    else:
+        print """
+I couldn't find the 'xdg-desktop-menu' and 'xdg-icon-resource' programs. These
+are needed to add the fancy entry for the mixer to your menu, but you can still
+start it by executing "ffado-mixer"."""
 
-if not build_mixer and not env.GetOption('clean'):
-    print """
-I couldn't find all the prerequisites ('pyuic4' and the python-modules 'dbus'
-and 'PyQt4', the packages could be named like dbus-python and PyQt) to build the
-mixer.
-Therefor the qt4 mixer will not get installed.
-"""
-
 #
 # Optional pkg-config
 #
@@ -510,7 +516,7 @@
 env.Alias( "install", env['sharedir'] )
 env.Alias( "install", env['bindir'] )
 env.Alias( "install", env['mandir'] )
-if build_mixer:
+if env['BUILD_MIXER'] == 'true':
     env.Alias( "install", env['pypkgdir'] )
 
 #
@@ -909,7 +915,7 @@
         if env.GetOption( "clean" ):
             env.Execute( action )
 
-    if env.has_key( 'XDG_TOOLS' ) and env.has_key( 'PYUIC4' ):
+    if env['BUILD_MIXER'] == 'true' and env['XDG_TOOLS']:
         if not env.GetOption("clean"):
             action = "install"
         else:
Index: support/mixer-qt4/SConscript
===================================================================
--- support/mixer-qt4/SConscript	(revision 2587)
+++ support/mixer-qt4/SConscript	(working copy)
@@ -26,7 +26,7 @@
 
 Import( 'env' )
 
-if env.has_key('PYUIC4'):
+if env['BUILD_MIXER'] == 'true':
     e = env.Clone()
 
     def findfiles( arg, dirname, names ):
