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

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

import Params

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

def set_options(opt):
	opt.tool_options('compiler_d')

def configure(conf):
	conf.check_tool('compiler_d')

	if not conf.env['D_COMPILER']:
		Params.fatal("either dmd or gdc is required (d compilers)")

	conf.env['LIB_PTHREAD'] = ['pthread']

def build(bld):
	bld.add_subdirs('src2')

	obj = bld.create_obj('d', 'staticlib')
	obj.source = '''
	testlib/code.d
	'''
	obj.importpaths = '.'
	obj.name = 'testlib'
	obj.target = 'testlib'

	"""
	compiling with d, linking with gcc:
	* in the configuration, add conf.check_tool('gcc')
	* in the object creation, add 3 lines

	obj = bld.create_obj('d')
	obj.source = '''
	testlib/code.d
	'''
	obj.features.append('cc')
	obj.features.append('cshlib')
	obj.name = 'testlib'
	obj.target = 'testlib'
	obj.m_type = 'shlib'
	"""

	obj = bld.create_obj('d', 'program')
	obj.source = '''
	example.d
	'''
	obj.target = 'd_test'
	obj.uselib_local = 'testlib'
	obj.uselib = 'PTHREAD'
