#!/usr/bin/python
#
# Copyright (C) 2007-2008 Arnold Krille
# Copyright (C) 2007-2008 Pieter Palmers
#
# This file is part of FFADO
# FFADO = Free Firewire (pro-)audio drivers for linux
#
# FFADO is based upon FreeBoB.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
import os
from string import Template

Import( 'env' )

if env.has_key('PYUIC'):
    e = env.Clone()

    e['MIXERGUIS'] = [ 'phase24', 'phase88',
                       'saffire_mono', 'saffire_stereo',
                       'saffireprolarge', 'saffireprosmall',
                       'saffirelelarge', 'saffirelesmall',
                       'audiofire_strip', 'audiofire_settings',
                       'bcoaudio5', 'edirolfa66', 'edirolfa101',
                       'mackie_generic', 'quatafire', 'motu',
                       'global', 'dummy'
                     ]
    e['MIXERAPPS'] = [ 'phase24', 'phase88',
                       'saffire',
                       'saffirepro',
                       'saffirele',
                       'audiofire',
                       'bcoaudio5', 'edirolfa66', 'edirolfa101',
                       'mackie_generic', 'quatafire', 'motu',
                       'global', 'dummy'
                     ]
    e['OTHERGUIS'] = ['ffado_regdialog']
    e['OTHERAPPS'] = ['ffado_regdialog', 'mixer_saffire_base']

    #
    # For the ffadomixer.in
    e['PYTHONDIR'] = Template( os.path.join( e['SHAREDIR'], 'python-qt3' ) ).safe_substitute( e )
    # For the installation of the stuff
    e['pythondir'] = Template( os.path.join( e['sharedir'], 'python-qt3' ) ).safe_substitute( e )

    for m in e['MIXERGUIS']:
        app = "mixer_" + m
        if os.path.exists( app+".ui" ):
            e.PyUIC( source=app+".ui", target=app+"ui.py" )
            e.Install( "$pythondir", app+"ui.py" )
    for m in e['MIXERAPPS']:
        app = "mixer_" + m
        e.Install( "$pythondir", app+".py" )

    for app in e['OTHERGUIS']:
        if os.path.exists( app+".ui" ):
            e.PyUIC( source=app+".ui", target=app+"ui.py" )
            e.Install( "$pythondir", app+"ui.py" )
    for app in e['OTHERAPPS']:
        e.Install( "$pythondir", app+".py" )

    e.Install( "$pythondir", "ffado_registration.py" )

    e.ScanReplace( "ffadomixer_config.py.in" )
    e.Depends( "ffadomixer_config.py", "#/config.h" )
    e.Install( "$pythondir", "ffadomixer_config.py" )

    e.ScanReplace( "ffado-mixer-qt3.in" )
    e.Depends( "ffado-mixer-qt3", "#/config.h" )
    e.Depends( "ffado-mixer-qt3", "SConscript" )
    e.Install( "$bindir", "ffado-mixer-qt3" )

