2018-01-31 12:48:43 +03:00
from waflib import Utils
from waflib . Configure import conf
2019-02-06 18:27:41 +03:00
from samba_utils import get_string
2014-08-26 03:29:57 +04:00
done = { }
@conf
def SAMBA_CHECK_PERL ( conf , mandatory = True , version = ( 5 , 0 , 0 ) ) :
if " done " in done :
return
done [ " done " ] = True
conf . find_program ( ' perl ' , var = ' PERL ' , mandatory = mandatory )
2018-01-31 12:48:43 +03:00
conf . load ( ' perl ' )
2014-08-26 03:29:57 +04:00
path_perl = conf . find_program ( ' perl ' )
conf . env . PERL_SPECIFIED = ( conf . env . PERL != path_perl )
conf . check_perl_version ( version )
def read_perl_config_var ( cmd ) :
2018-07-27 18:54:16 +03:00
output = Utils . cmd_output ( [ conf . env . get_flat ( ' PERL ' ) , ' -MConfig ' , ' -e ' , cmd ] )
if not isinstance ( output , str ) :
2019-02-06 18:27:41 +03:00
output = get_string ( output )
2018-07-27 18:54:16 +03:00
return Utils . to_list ( output )
2014-08-26 03:29:57 +04:00
def check_perl_config_var ( var ) :
conf . start_msg ( " Checking for perl $Config { %s }: " % var )
try :
v = read_perl_config_var ( ' print $Config { %s } ' % var ) [ 0 ]
conf . end_msg ( " ' %s ' " % ( v ) , ' GREEN ' )
return v
except IndexError :
conf . end_msg ( False , ' YELLOW ' )
return None
vendor_prefix = check_perl_config_var ( ' vendorprefix ' )
perl_arch_install_dir = None
if vendor_prefix == conf . env . PREFIX :
2023-08-29 11:47:58 +03:00
perl_arch_install_dir = check_perl_config_var ( ' vendorarch ' )
2014-08-26 03:29:57 +04:00
if perl_arch_install_dir is None :
2023-08-29 11:47:58 +03:00
perl_arch_install_dir = " $ {LIBDIR} /perl5 "
2014-08-26 03:29:57 +04:00
conf . start_msg ( " PERL_ARCH_INSTALL_DIR: " )
conf . end_msg ( " ' %s ' " % ( perl_arch_install_dir ) , ' GREEN ' )
conf . env . PERL_ARCH_INSTALL_DIR = perl_arch_install_dir
perl_lib_install_dir = None
if vendor_prefix == conf . env . PREFIX :
2023-08-29 11:47:58 +03:00
perl_lib_install_dir = check_perl_config_var ( ' vendorlib ' )
2014-08-26 03:29:57 +04:00
if perl_lib_install_dir is None :
2023-08-29 11:47:58 +03:00
perl_lib_install_dir = " $ {DATADIR} /perl5 "
2014-08-26 03:29:57 +04:00
conf . start_msg ( " PERL_LIB_INSTALL_DIR: " )
conf . end_msg ( " ' %s ' " % ( perl_lib_install_dir ) , ' GREEN ' )
conf . env . PERL_LIB_INSTALL_DIR = perl_lib_install_dir
perl_inc = read_perl_config_var ( ' print " @INC " ' )
2016-10-25 14:06:12 +03:00
if ' . ' in perl_inc :
perl_inc . remove ( ' . ' )
2014-08-26 03:29:57 +04:00
conf . start_msg ( " PERL_INC: " )
conf . end_msg ( " %s " % ( perl_inc ) , ' GREEN ' )
conf . env . PERL_INC = perl_inc