#! /usr/bin/env python3
# encoding: utf-8

import os
from waflib import Logs as logs
from waflib import Utils as utils

def options(opt):
	pass

def configure(conf):
	pass

def build(bld):
	if bld.cmd == 'install' or bld.cmd == 'uninstall':
		if not os.geteuid()==0:
			logs.warn ('You most likely need root privileges to install or uninstall properly.')


	nodes =  bld.path.ant_glob(\
	    ['*.c',
	     'tools/*.c',
	     'gplot/*.c',
	     'engines/*.c',
	     'sheet/*.c',
	     'model/*.c'],
	     excl='main.c')

	bld.objects (
		['c','glib2'],
		source = nodes,
		includes = ['.', 'tools/', 'engines/', 'gplot/', 'model/', 'sheet/'],
		uselib = 'M XML GOBJECT GLIB GTK3 XML GOOCANVAS GTKSOURCEVIEW3',
		target = 'shared_objects'
	)

	exe = bld.program(
		features = ['c', 'glib2'],
		target = bld.env.appname,
		source = ['main.c'],
		includes = ['.', 'tools/', 'engines/', 'gplot/', 'model/', 'sheet/'],
		use = 'shared_objects',
		uselib = 'M XML GOBJECT GLIB GTK3 XML GOOCANVAS GTKSOURCEVIEW3',
		settings_schema_files = ['../data/settings/'+bld.env.gschema_name ] if not bld.options.no_install_gschema else [],
		install_path = "${BINDIR}"
	)

	for item in exe.includes:
		logs.debug(item)
