2010-04-01 15:19:32 +04:00
###########################
# this handles the magic we need to do for installing
# with all the configure options that affect rpath and shared
# library use
import Options
from TaskGen import feature , before , after
from samba_utils import *
2010-04-08 01:45:46 +04:00
O755 = 493
2010-04-01 15:19:32 +04:00
@feature ( ' install_bin ' )
@after ( ' apply_core ' )
@before ( ' apply_link ' )
def install_binary ( self ) :
''' install a binary, taking account of the different rpath varients '''
bld = self . bld
# get the ldflags we will use for install and build
install_ldflags = install_rpath ( bld )
build_ldflags = build_rpath ( bld )
if not Options . is_install or not self . samba_install :
# just need to set rpath if we are not installing
self . env . append_value ( ' LINKFLAGS ' , build_ldflags )
return
# work out the install path, expanding variables
install_path = self . samba_inst_path or ' $ {BINDIR} '
install_path = bld . EXPAND_VARIABLES ( install_path )
2010-04-18 15:08:11 +04:00
orig_target = os . path . basename ( self . target )
2010-04-01 15:19:32 +04:00
if install_ldflags != build_ldflags :
# we will be creating a new target name, and using that for the
# install link. That stops us from overwriting the existing build
# target, which has different ldflags
self . target + = ' .inst '
# setup the right rpath link flags for the install
self . env . append_value ( ' LINKFLAGS ' , install_ldflags )
# tell waf to install the right binary
bld . install_as ( os . path . join ( install_path , orig_target ) ,
os . path . join ( self . path . abspath ( bld . env ) , self . target ) ,
2010-04-08 01:45:46 +04:00
chmod = O755 )
2010-04-01 15:19:32 +04:00
@feature ( ' install_lib ' )
@after ( ' apply_core ' )
@before ( ' apply_link ' )
def install_library ( self ) :
''' install a library, taking account of the different rpath varients '''
if getattr ( self , ' done_install_library ' , False ) :
return
bld = self . bld
install_ldflags = install_rpath ( bld )
build_ldflags = build_rpath ( bld )
if not Options . is_install or not self . samba_install :
# just need to set the build rpath if we are not installing
self . env . append_value ( ' LINKFLAGS ' , build_ldflags )
return
# setup the install path, expanding variables
install_path = self . samba_inst_path or ' $ {LIBDIR} '
install_path = bld . EXPAND_VARIABLES ( install_path )
if install_ldflags != build_ldflags :
# we will be creating a new target name, and using that for the
# install link. That stops us from overwriting the existing build
# target, which has different ldflags
self . done_install_library = True
t = self . clone ( ' default ' )
t . target + = ' .inst '
self . env . append_value ( ' LINKFLAGS ' , build_ldflags )
else :
t = self
t . env . append_value ( ' LINKFLAGS ' , install_ldflags )
2010-04-13 13:45:38 +04:00
dev_link = None
2010-04-01 15:19:32 +04:00
if self . samba_realname :
install_name = self . samba_realname
install_link = None
inst_name = t . target + ' .so '
elif self . vnum :
vnum_base = self . vnum . split ( ' . ' ) [ 0 ]
install_name = ' lib %s .so. %s ' % ( self . target , self . vnum )
install_link = ' lib %s .so. %s ' % ( self . target , vnum_base )
inst_name = ' lib %s .so ' % t . target
2010-04-13 13:45:38 +04:00
if self . target == self . name :
# only generate the dev link for non-bundled libs
dev_link = ' lib %s .so ' % self . target
2010-04-01 15:19:32 +04:00
else :
install_name = ' lib %s .so ' % self . target
install_link = None
inst_name = ' lib %s .so ' % t . target
# tell waf to install the library
bld . install_as ( os . path . join ( install_path , install_name ) ,
os . path . join ( self . path . abspath ( bld . env ) , inst_name ) )
if install_link :
# and the symlink if needed
bld . symlink_as ( os . path . join ( install_path , install_link ) ,
install_name )
2010-04-13 13:45:38 +04:00
if dev_link :
bld . symlink_as ( os . path . join ( install_path , dev_link ) ,
install_name )
2010-04-01 15:19:32 +04:00
##############################
# handle the creation of links for libraries and binaries in the build tree
@feature ( ' symlink_lib ' )
@after ( ' apply_link ' )
def symlink_lib ( self ) :
''' symlink a shared lib '''
2010-04-05 05:23:28 +04:00
if self . target . endswith ( ' .inst ' ) :
2010-04-01 15:19:32 +04:00
return
2010-04-08 15:46:20 +04:00
blddir = os . path . dirname ( self . bld . srcnode . abspath ( self . bld . env ) )
2010-04-05 05:23:28 +04:00
libpath = self . link_task . outputs [ 0 ] . abspath ( self . env )
2010-04-01 15:19:32 +04:00
# calculat the link target and put it in the environment
soext = " "
vnum = getattr ( self , ' vnum ' , None )
if vnum is not None :
soext = ' . ' + vnum . split ( ' . ' ) [ 0 ]
link_target = getattr ( self , ' link_name ' , ' ' )
if link_target == ' ' :
link_target = ' %s /lib %s .so %s ' % ( LIB_PATH , self . target , soext )
2010-04-05 05:23:28 +04:00
link_target = os . path . join ( blddir , link_target )
2010-04-01 15:19:32 +04:00
2010-04-05 05:23:28 +04:00
if os . path . lexists ( link_target ) :
2010-04-13 03:33:18 +04:00
if os . path . islink ( link_target ) and os . readlink ( link_target ) == libpath :
2010-04-09 14:30:44 +04:00
return
2010-04-05 05:23:28 +04:00
os . unlink ( link_target )
os . symlink ( libpath , link_target )
2010-04-01 15:19:32 +04:00
@feature ( ' symlink_bin ' )
@after ( ' apply_link ' )
def symlink_bin ( self ) :
2010-04-05 05:23:28 +04:00
''' symlink a binary into the build directory '''
if self . target . endswith ( ' .inst ' ) :
2010-04-01 15:19:32 +04:00
return
2010-04-08 15:46:20 +04:00
blddir = os . path . dirname ( self . bld . srcnode . abspath ( self . bld . env ) )
2010-04-05 05:23:28 +04:00
binpath = self . link_task . outputs [ 0 ] . abspath ( self . env )
2010-04-11 23:59:43 +04:00
bldpath = os . path . join ( self . bld . env . BUILD_DIRECTORY , self . link_task . outputs [ 0 ] . name )
2010-04-01 15:19:32 +04:00
2010-04-05 05:23:28 +04:00
if os . path . lexists ( bldpath ) :
2010-04-13 03:33:18 +04:00
if os . path . islink ( bldpath ) and os . readlink ( bldpath ) == binpath :
2010-04-09 14:30:44 +04:00
return
2010-04-05 05:23:28 +04:00
os . unlink ( bldpath )
os . symlink ( binpath , bldpath )