#! /usr/bin/env python
# encoding: utf-8
# Richard Quirk, 2008

import UnitTest, Utils

srcdir = '.'
blddir = 'build'

def set_options(opt):
	opt.tool_options('compiler_cxx')
	opt.tool_options('UnitTest')

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

	# this one requires cppunit
	conf.check_cfg(package='cppunit', args='--cflags --libs')
	if 'LIB_CPPUNIT' in conf.env:
		if 'dl' not in conf.env.LIB_CPPUNIT:
			l = conf.check(lib='dl', uselib_store='CPPUNIT')
	else:
		conf.fatal('Install cppunit')

def build(bld):
	# process subfolders from here
	subdirs = 'src'
	# if cppunit was found in the config step, build unit tests too
	if bld.env.LIB_CPPUNIT:
		subdirs += ' tests'
	bld.add_subdirs(subdirs)

	bld.add_post_fun(UnitTest.summary)
