#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2006 (ita)

import os
import Params

# the following two variables are used by the target "waf dist"
VERSION='0.0.2'
APPNAME='gnome_test'

# these variables are mandatory ('/' are converted automatically)
srcdir = '.'
blddir = '_build_'

def build(bld):
	# process subfolders from here
	bld.add_subdirs('src pixmaps po help man data')
	if bld.env_of_name('default')['MCS']:
		bld.add_subdirs('shrap')

def configure(conf):
	conf.check_tool('gcc gnome cs')

	conf.check_pkg('libgnome-2.0',        destvar='GNOME',    vnum='2.10.0')
	conf.check_pkg('libgnomeui-2.0',      destvar='GNOMEUI',  vnum='2.10.0')
	conf.check_pkg('gtk+-2.0',            destvar='GTK',      vnum='2.6.0')
	conf.check_pkg('dbus-glib-1',         destvar='DBUSGLIB', vnum='0.60')

	# here is how to add more libraries (look in src/wscript_build too)
	#conf.check_pkg('glib-2.0',            destvar='GLIB',     vnum='2.6.0')
	#conf.check_pkg('libbonobo-2.0',       destvar='BONOBO',   vnum='2.0.0')
	#conf.check_pkg('libbonoboui-2.0',     destvar='BONOBOUI', vnum='2.0.0')
	#conf.check_pkg('libglade-2.0',        destvar='GLADE',    vnum='2.0.1')
	#conf.check_pkg('libgnomecanvas-2.0',  destvar='CANVAS',   vnum='2.0.1')
	#conf.check_pkg('libgnomeprintui-2.2', destvar='PRINTUI',  vnum='2.2.0')
	#conf.check_pkg('libgnomeprint-2.2',   destvar='PRINT',    vnum='2.2.0')
	#conf.check_pkg('libxml-2.0',          destvar='XML',      vnum='2.4.23')
	#conf.check_pkg('gdk-x11-2.0',         destvar='GDK',      vnum='1.0.0')

	conf.add_define('VERSION', VERSION)
	conf.add_define('GETTEXT_PACKAGE', 'gnome-hello-2.0')
	conf.add_define('PACKAGE', 'gnome-hello')

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

	conf.env['ASSEMBLIES_GLIB'] = '/usr/lib/mono/gtk-sharp/glib-sharp.dll'

	conf.write_config_header('config.h')

def set_options(opt):
	# add your custom options here, for example:
	#opt.add_option('--bunny', type='string', help='how many bunnies we have', dest='bunny')
	pass

def shutdown():
	# this piece of code may be move right after the pixmap or documentation installation
	if Params.g_commands['install']:
		import Runner, Common

		# add the gconf schema
		dir = Common.path_install('PREFIX', 'etc/gconf/schemas/gnome_test.schemas')
		command = 'gconftool-2 --install-schema-file=%s 1> /dev/null' % dir
		ret = Runner.exec_command(command)

		# update the pixmap cache directory
		dir = Common.path_install('DATADIR', 'icons/hicolor')
		command = 'gtk-update-icon-cache -q -f -t %s' % dir
		ret = Runner.exec_command(command)

		# now the scrollkeeper update if we can write to the log file
		if os.path.iswriteable('/var/log/scrollkeeper.log'):
			dir1 = Common.path_install('PREFIX', 'var/scrollkeeper')
			dir2 = Common.path_install('DATADIR', 'omf/gnome-hello')
			command = 'scrollkeeper-update -q -p %s -o %s' % (dir1, dir2)
			ret = Runner.exec_command(command)

