#! /usr/bin/env python
# encoding: utf-8
# anonymous coward, 2007

import sys, os

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

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

def set_options(opt):
	opt.tool_options('perl')
	opt.tool_options('compiler_cc')

def configure(conf):
	conf.check_tool('compiler_cc')
	conf.check_tool('perl')

	# check for perl
	if not conf.check_perl_version((5,6,0)):
		return False

	conf.check_perl_ext_devel()

	# check for some perl module...
	conf.check_perl_module("Cairo")
	# ...and a specific version
	conf.check_perl_module("Devel::PPPort 4.89")

	conf.env['INSTALLDIR_PERL_AUTO'] = os.path.join(conf.env['ARCHDIR_PERL'], "auto")
	conf.env['INSTALLDIR_PERL_LIB'] = conf.env['ARCHDIR_PERL']

def build(bld):
	# Build a perl extension module
	obj = bld.new_task_gen('cc', 'shlib', 'perlext')
	obj.source = 'Mytest.xs'
	obj.target = 'Mytest'
	obj.inst_var = 'INSTALLDIR_PERL_AUTO'

	bld.install_files('INSTALLDIR_PERL_LIB', '', 'Mytest.pm')

def shutdown():
	pass

