#!/usr/bin/env python
import autowaf
import os

# Version of this package (even if built as a child)
MAJOR = '0'
MINOR = '8'
MICRO = '3'
GTKMM2EXT_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)

# Library version (UNIX style major, minor, micro)
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
GTKMM2EXT_LIB_VERSION = '0.8.3'

# Variables for 'waf dist'
APPNAME = 'gtkmm2ext'
VERSION = GTKMM2EXT_VERSION

gtkmm2ext_sources = [
	'actions.cc',
	'auto_spin.cc',
	'barcontroller.cc',
	'binding_proxy.cc',
	'bindable_button.cc',
	'cell_renderer_pixbuf_multi.cc',
	'cell_renderer_pixbuf_toggle.cc',
	'choice.cc',
	'click_box.cc',
	'dndtreeview.cc',
	'fastmeter.cc',
	'focus_entry.cc',
	'grouped_buttons.cc',
	'gtk_ui.cc',
        'gtkapplication.c',
	'idle_adjustment.cc',
	'keyboard.cc',
        'motionfeedback.cc',
        'prolooks_helpers.c',
	'pixfader.cc',
	'pixscroller.cc',
	'popup.cc',
	'prompter.cc',
	'scroomer.cc',
	'selector.cc',
	'slider_controller.cc',
	'stateful_button.cc',
	'tearoff.cc',
	'textviewer.cc',
	'utils.cc',
	'version.cc',
	'window_title.cc'
]

# Mandatory variables
srcdir = '.'
blddir = 'build'

path_prefix = 'libs/gtkmm2ext/'

def set_options(opt):
	autowaf.set_options(opt)

def configure(conf):
	autowaf.build_version_files(path_prefix+'gtkmm2ext/version.h', path_prefix+'version.cc',
			'libgtkmm2ext', MAJOR, MINOR, MICRO)
	autowaf.configure(conf)
	conf.check_tool('compiler_cxx')
	autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM', atleast_version='2.8')
	autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK', atleast_version='2.12.1')


def build(bld):
	obj = bld.new_task_gen(features = 'cc cxx cshlib')
	obj.source = gtkmm2ext_sources
	obj.export_incdirs = ['.']
	obj.includes     = ['.']
	obj.name         = 'libgtkmm2ext'
	obj.target       = 'gtkmm2ext'
	obj.uselib       = 'GTKMM GTK GTKOSX OSX GDK'
	obj.uselib_local = 'libpbd'
	obj.vnum         = GTKMM2EXT_LIB_VERSION
	obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
	obj.cxxflags     = [
			'-DPACKAGE="libgtkmm2ext"',
			'-DLOCALEDIR="' + os.path.join(
				os.path.normpath(bld.env['DATADIRNAME']), 'locale') + '"']
	if bld.env['GTKOSX']:
		obj.source += ['gtkapplication_quartz.mm']
        else:
                obj.source += ['gtkapplication_x11.c']

def shutdown():
	autowaf.shutdown()

