#!/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('PYUIC4'):
    e = env.Clone()
    e['MIXERGUIS'] = [
                        'phase24', 
                        'phase88',
                        'saffire_mono', 'saffire_stereo',
                        'saffirepro_large', 'saffirepro_small',
                        'saffirele_large', 'saffirele_small',
                        'audiofire_strip', 'audiofire_settings',
                        'bcoaudio5',
                        'edirolfa101', 'edirolfa66',
                        'quatafire',
                        'mackie_onyxmixer',
                        'motu',
                        'global', 'dummy'
                     ]
    e['MIXERAPPS'] = [
                        'phase24',
                        'phase88',
                        'saffire',
                        'saffirepro',
                        'audiofire',
                        'bcoaudio5',
                        'edirolfa101', 'edirolfa66',
                        'quatafire',
                        'mackie_onyxmixer',
                        'motu',
                        'global', 'dummy'
                     ]

    e['OTHERGUIS'] = ['ffado_regdialog', 'ffado_panelmanagerstatus']
    e['OTHERAPPS'] = ['ffado_dbus_util',
                      'ffado_regdialog',
                      'ffado_panelmanager',
                      'ffado_configuration',
                      'mixer_saffire_base'
                     ]

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

    for m in e['MIXERGUIS']:
        app = "mixer_" + m
        if os.path.exists( app+".ui" ):
            e.PyUIC4( 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.PyUIC4( 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.in" )
    e.Depends( "ffado-mixer", "#/config.h" )
    e.Depends( "ffado-mixer", "SConscript" )
    e.Install( "$bindir", "ffado-mixer" )

    e.Install( "$sharedir/icons", "../xdg/hi64-apps-ffado.png" )
