#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import Params
import intltool

VERSION = '0.0.4'
APPNAME = 'breeze'

srcdir = '.'
blddir = '_build_'

def set_options(opt):
    opt.add_option('--enable-debug', action = 'store_true',
                   help = 'enable debugging stuff', dest = 'enable_debug')

def configure(conf):
    conf.check_tool('gcc intltool')

    if not conf.check_pkg('gtk+-2.0', destvar = 'GTK', vnum = '2.6.0'):
        Params.fatal('gtk+ >= 2.6.0 is required')
    if not conf.check_pkg('glib-2.0', destvar = 'GLIB', vnum = '2.6.0'):
        Params.fatal('glib >= 2.6.0 is required')
    if not conf.check_pkg('x11', destvar = 'X11', vnum = '1.0.0'):
        Params.fatal('X11 >= 1.0.0 is required')
    if not conf.check_pkg('xext', destvar = 'XEXT', vnum = '1.0.0'):
        Params.fatal('Xext >= 1.0.0 is required')

    conf.define('VERSION', VERSION)
    conf.define('PACKAGE_DATA_DIR',
                os.path.join(conf.env['PREFIX'], 'share', APPNAME))
    conf.define('PACKAGE_MAN1_DIR',
                os.path.join(conf.env['PREFIX'], 'share', 'man', 'man1'))

    conf.define('ENABLE_NLS', 1)
    conf.define('GETTEXT_PACKAGE', APPNAME)
    conf.define('PACKAGE_LOCALE_DIR',
                os.path.join(conf.env['PREFIX'], 'share', 'locale'))

    if Params.g_options.enable_debug:
        conf.define('DEBUG', 1)
        conf.env.append_value('CCFLAGS', '-O0 -ggdb -Wmissing-prototypes -Wstrict-prototypes')
    else:
        conf.env.append_value('CCFLAGS', '-O2')

    if os.sys.platform == 'win32':
        conf.define('PATHSEP', '\\')
    else:
        conf.define('PATHSEP', '/')

    conf.env.append_value('CCFLAGS', '-DHAVE_CONFIG_H')

    conf.write_config_header('config.h')

def build(bld):
    bld.add_subdirs('po src')

    install_files('PACKAGE_MAN1_DIR', '.', 'breeze.1')
