3
# WARNING! All changes made to this file will be lost!
6
from waflib import Task,Options,Utils
7
from waflib.Configure import conf
8
from waflib.TaskGen import extension,feature,before
9
def init_perlext(self):
10
self.uselib=self.to_list(getattr(self,'uselib',[]))
11
if not'PERLEXT'in self.uselib:self.uselib.append('PERLEXT')
12
self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['perlext_PATTERN']
13
def xsubpp_file(self,node):
14
outnode=node.change_ext('.c')
15
self.create_task('xsubpp',node,outnode)
16
self.source.append(outnode)
17
class xsubpp(Task.Task):
18
run_str='${PERL} ${XSUBPP} -noprototypes -typemap ${EXTUTILS_TYPEMAP} ${SRC} > ${TGT}'
21
def check_perl_version(self,minver=None):
23
if not getattr(Options.options,'perlbinary',None):
24
perl=self.find_program('perl',var='PERL')
28
self.env['PERL']=perl=Options.options.perlbinary
29
version=self.cmd_and_log([perl,"-e",'printf \"%vd\", $^V'])
33
elif not minver is None:
34
ver=tuple(map(int,version.split(".")))
40
cver=".".join(map(str,minver))
41
self.msg('Checking for perl version',cver)
43
def check_perl_module(self,module):
44
cmd=[self.env['PERL'],'-e','use %s'%module]
45
self.start_msg('perl module %s'%module)
47
r=self.cmd_and_log(cmd)
51
self.end_msg(r or True)
53
def check_perl_ext_devel(self):
57
self.fatal('find perl first')
59
return Utils.to_list(self.cmd_and_log(perl+cmd))
60
env['LINKFLAGS_PERLEXT']=read_out(" -MConfig -e'print $Config{lddlflags}'")
61
env['INCLUDES_PERLEXT']=read_out(" -MConfig -e'print \"$Config{archlib}/CORE\"'")
62
env['CFLAGS_PERLEXT']=read_out(" -MConfig -e'print \"$Config{ccflags} $Config{cccdlflags}\"'")
63
env['XSUBPP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}\"'")
64
env['EXTUTILS_TYPEMAP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/typemap\"'")
65
if not getattr(Options.options,'perlarchdir',None):
66
env['ARCHDIR_PERL']=self.cmd_and_log(perl+" -MConfig -e'print $Config{sitearch}'")
68
env['ARCHDIR_PERL']=getattr(Options.options,'perlarchdir')
69
env['perlext_PATTERN']='%s.'+self.cmd_and_log(perl+" -MConfig -e'print $Config{dlext}'")
71
opt.add_option('--with-perl-binary',type='string',dest='perlbinary',help='Specify alternate perl binary',default=None)
72
opt.add_option('--with-perl-archdir',type='string',dest='perlarchdir',help='Specify directory where to install arch specific files',default=None)
74
before('apply_incpaths','apply_link','propagate_uselib_vars')(init_perlext)
75
feature('perlext')(init_perlext)
76
extension('.xs')(xsubpp_file)
77
conf(check_perl_version)
78
conf(check_perl_module)
79
conf(check_perl_ext_devel)
b'\\ No newline at end of file'