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 *
@feature ( ' install_bin ' )
@after ( ' apply_core ' )
2010-05-03 18:37:33 +04:00
@before ( ' apply_link ' , ' apply_obj_vars ' )
2010-04-01 15:19:32 +04:00
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
2010-11-30 03:10:31 +03:00
install_ldflags = install_rpath ( self )
2010-04-01 15:19:32 +04:00
build_ldflags = build_rpath ( bld )
2010-11-08 03:01:13 +03:00
if not Options . is_install :
2010-04-01 15:19:32 +04:00
# just need to set rpath if we are not installing
2010-05-03 18:37:33 +04:00
self . env . RPATH = build_ldflags
2010-04-01 15:19:32 +04:00
return
# work out the install path, expanding variables
2010-10-05 10:17:31 +04:00
install_path = getattr ( self , ' samba_inst_path ' , None ) or ' $ {BINDIR} '
2010-04-01 15:19:32 +04:00
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
2010-05-03 18:37:33 +04:00
self . env . RPATH = install_ldflags
2010-04-01 15:19:32 +04:00
2010-11-08 03:01:13 +03:00
if not self . samba_install :
# this binary is marked not to be installed
return
2010-04-01 15:19:32 +04:00
# 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-10-06 13:11:01 +04:00
chmod = MODE_755 )
2010-04-01 15:19:32 +04:00
@feature ( ' install_lib ' )
@after ( ' apply_core ' )
2010-05-03 18:37:33 +04:00
@before ( ' apply_link ' , ' apply_obj_vars ' )
2010-04-01 15:19:32 +04:00
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
2010-11-30 03:10:31 +03:00
install_ldflags = install_rpath ( self )
2010-04-01 15:19:32 +04:00
build_ldflags = build_rpath ( bld )
2010-10-05 10:17:31 +04:00
if not Options . is_install or not getattr ( self , ' samba_install ' , True ) :
2010-04-01 15:19:32 +04:00
# just need to set the build rpath if we are not installing
2010-05-03 18:37:33 +04:00
self . env . RPATH = build_ldflags
2010-04-01 15:19:32 +04:00
return
# setup the install path, expanding variables
2010-11-05 01:23:39 +03:00
install_path = getattr ( self , ' samba_inst_path ' , None )
if install_path is None :
if getattr ( self , ' private_library ' , False ) :
install_path = ' $ {PRIVATELIBDIR} '
else :
install_path = ' $ {LIBDIR} '
2010-04-01 15:19:32 +04:00
install_path = bld . EXPAND_VARIABLES ( install_path )
2010-11-08 04:47:09 +03:00
target_name = 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 . done_install_library = True
2010-11-08 07:45:18 +03:00
t = self . clone ( ' default ' )
2010-05-05 16:09:26 +04:00
t . posted = False
2010-04-01 15:19:32 +04:00
t . target + = ' .inst '
2010-05-03 18:37:33 +04:00
self . env . RPATH = build_ldflags
2010-04-01 15:19:32 +04:00
else :
t = self
2010-05-03 18:37:33 +04:00
t . env . RPATH = install_ldflags
2010-04-01 15:19:32 +04:00
2010-04-13 13:45:38 +04:00
dev_link = None
2010-11-08 04:47:09 +03:00
# in the following the names are:
# - inst_name is the name with .inst. in it, in the build
# directory
# - install_name is the name in the install directory
# - install_link is a symlink in the install directory, to install_name
2010-10-05 10:17:31 +04:00
if getattr ( self , ' samba_realname ' , None ) :
2010-04-01 15:19:32 +04:00
install_name = self . samba_realname
install_link = None
2010-04-26 13:04:33 +04:00
if getattr ( self , ' samba_type ' , None ) == ' PYTHON ' :
2010-10-17 14:58:22 +04:00
inst_name = bld . make_libname ( t . target , nolibprefix = True , python = True )
2010-04-26 13:04:33 +04:00
else :
2010-10-17 14:58:22 +04:00
inst_name = bld . make_libname ( t . target )
2010-04-01 15:19:32 +04:00
elif self . vnum :
vnum_base = self . vnum . split ( ' . ' ) [ 0 ]
2010-11-08 04:47:09 +03:00
install_name = bld . make_libname ( target_name , version = self . vnum )
install_link = bld . make_libname ( target_name , version = vnum_base )
2010-10-17 14:58:22 +04:00
inst_name = bld . make_libname ( t . target )
2010-10-21 04:22:36 +04:00
if not self . private_library :
2010-04-13 13:45:38 +04:00
# only generate the dev link for non-bundled libs
2010-11-08 04:47:09 +03:00
dev_link = bld . make_libname ( target_name )
2010-10-27 04:54:56 +04:00
elif getattr ( self , ' soname ' , ' ' ) :
2010-11-08 04:47:09 +03:00
install_name = bld . make_libname ( target_name )
2010-10-27 04:54:56 +04:00
install_link = self . soname
inst_name = bld . make_libname ( t . target )
2010-04-01 15:19:32 +04:00
else :
2010-11-08 04:47:09 +03:00
install_name = bld . make_libname ( target_name )
2010-04-01 15:19:32 +04:00
install_link = None
2010-10-17 14:58:22 +04:00
inst_name = bld . make_libname ( t . target )
2010-04-01 15:19:32 +04:00
2011-03-02 03:40:33 +03:00
if t . env . SONAME_ST :
# ensure we get the right names in the library
if install_link :
t . env . append_value ( ' LINKFLAGS ' , t . env . SONAME_ST % install_link )
else :
t . env . append_value ( ' LINKFLAGS ' , t . env . SONAME_ST % install_name )
2010-05-23 19:55:48 +04:00
t . env . SONAME_ST = ' '
2010-04-01 15:19:32 +04:00
# 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 ) )
2010-12-17 20:47:05 +03:00
if install_link and install_link != install_name :
2010-04-01 15:19:32 +04:00
# and the symlink if needed
2010-12-17 20:47:05 +03:00
bld . symlink_as ( os . path . join ( install_path , install_link ) , install_name )
2010-04-13 13:45:38 +04:00
if dev_link :
2010-12-17 20:47:05 +03:00
bld . symlink_as ( os . path . join ( install_path , dev_link ) , install_name )
2010-04-01 15:19:32 +04:00
2010-10-27 04:54:56 +04:00
@feature ( ' cshlib ' )
@after ( ' apply_implib ' )
@before ( ' apply_vnum ' )
def apply_soname ( self ) :
''' install a library, taking account of the different rpath varients '''
if self . env . SONAME_ST and getattr ( self , ' soname ' , ' ' ) :
self . env . append_value ( ' LINKFLAGS ' , self . env . SONAME_ST % self . soname )
self . env . SONAME_ST = ' '
2010-04-01 15:19:32 +04:00
2010-12-17 21:16:33 +03:00
@feature ( ' cshlib ' )
@after ( ' apply_implib ' )
@before ( ' apply_vnum ' )
def apply_vscript ( self ) :
''' add version-script arguments to library build '''
if self . env . HAVE_LD_VERSION_SCRIPT and getattr ( self , ' version_script ' , ' ' ) :
self . env . append_value ( ' LINKFLAGS ' , " -Wl,--version-script= %s " %
2010-12-17 21:38:12 +03:00
self . version_script )
2010-12-17 21:16:33 +03:00
self . version_script = None
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 == ' ' :
2011-02-18 02:52:48 +03:00
basename = os . path . basename ( self . bld . make_libname ( self . target , version = soext ) )
2010-11-05 04:30:01 +03:00
if getattr ( self , " private_library " , False ) :
link_target = ' %s /private/ %s ' % ( LIB_PATH , basename )
else :
link_target = ' %s / %s ' % ( LIB_PATH , basename )
2010-04-01 15:19:32 +04:00
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 )
2010-09-04 04:18:31 +04:00
link_container = os . path . dirname ( link_target )
if not os . path . isdir ( link_container ) :
2010-09-05 20:00:44 +04:00
os . makedirs ( link_container )
2010-09-04 04:18:31 +04:00
2010-04-05 05:23:28 +04:00
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 ) )
2011-02-17 06:03:13 +03:00
if not self . link_task . outputs or not self . link_task . outputs [ 0 ] :
raise Utils . WafError ( ' no outputs found for %s in symlink_bin ' % self . name )
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 )