#!/usr/bin/env python

import intltool, platform, os
import Environment, Scripting, Runner, Options

APPNAME = 'NicoEdit'
VERSION = '2.0'
COPYRIGHT = "Copyright \xc2\xa9 2009 Nicolas Alcouffe"

VERSION_MAJOR_MINOR = '.'.join (VERSION.split ('.')[0:2])
VERSION_MAJOR = '.'.join (VERSION.split ('.')[0:1])
srcdir = '.'
blddir = '_build_'


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

  min_vala_version = (0, 7, 4)
  if conf.env['VALAC_VERSION'] < min_vala_version:
      conf.fatal('Your vala compiler version is too old, NicoEdit requires at least version %d.%d.%d' % min_vala_version );

  conf.check_cfg (package='glib-2.0',          uselib_store='GLIB',          atleast_version='2.16.0', args='--cflags --libs', mandatory=True)
  conf.check_cfg (package='gio-2.0',           uselib_store='GIO',           atleast_version='2.16.0', args='--cflags --libs', mandatory=True)
  conf.check_cfg (package='gtk+-2.0',          uselib_store='GTK+',          atleast_version='2.14.0', args='--cflags --libs', mandatory=True)
  conf.check_cfg (package='gtksourceview-2.0', uselib_store='GTKSOURCEVIEW', atleast_version='2.0.0',  args='--cflags --libs', mandatory=True)


  conf.define ('PACKAGE_NAME', APPNAME)
  conf.define ('GETTEXT_PACKAGE', APPNAME)
  conf.define ('VERSION', VERSION)
  conf.define ('COPYRIGHT', COPYRIGHT)

  prefix = conf.env['PREFIX']

  conf.define ('PIXMAPS_DIR', prefix + '/share/pixmaps/' + APPNAME)

  if prefix != '/usr' and prefix != '/usr/local' and prefix != '/usr/' and prefix != '/usr/local/':
    prefix = os.getenv ('HOME') + '/.local'

  conf.define ('DESKTOP_DIR', prefix + '/share/applications/')
  conf.write_config_header ('config.h')

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

def shutdown ():
  pass

