1 ###########################
2 # this handles the magic we need to do for installing
3 # with all the configure options that affect rpath and shared
7 from TaskGen import feature, before, after
8 from samba_utils import *
12 @feature('install_bin')
15 def install_binary(self):
16 '''install a binary, taking account of the different rpath varients'''
19 # get the ldflags we will use for install and build
20 install_ldflags = install_rpath(bld)
21 build_ldflags = build_rpath(bld)
23 if not Options.is_install or not self.samba_install:
24 # just need to set rpath if we are not installing
25 self.env.append_value('LINKFLAGS', build_ldflags)
28 # work out the install path, expanding variables
29 install_path = self.samba_inst_path or '${BINDIR}'
30 install_path = bld.EXPAND_VARIABLES(install_path)
32 orig_target = self.target
34 if install_ldflags != build_ldflags:
35 # we will be creating a new target name, and using that for the
36 # install link. That stops us from overwriting the existing build
37 # target, which has different ldflags
38 self.target += '.inst'
40 # setup the right rpath link flags for the install
41 self.env.append_value('LINKFLAGS', install_ldflags)
43 # tell waf to install the right binary
44 bld.install_as(os.path.join(install_path, orig_target),
45 os.path.join(self.path.abspath(bld.env), self.target),
50 @feature('install_lib')
53 def install_library(self):
54 '''install a library, taking account of the different rpath varients'''
55 if getattr(self, 'done_install_library', False):
60 install_ldflags = install_rpath(bld)
61 build_ldflags = build_rpath(bld)
63 if not Options.is_install or not self.samba_install:
64 # just need to set the build rpath if we are not installing
65 self.env.append_value('LINKFLAGS', build_ldflags)
68 # setup the install path, expanding variables
69 install_path = self.samba_inst_path or '${LIBDIR}'
70 install_path = bld.EXPAND_VARIABLES(install_path)
72 if install_ldflags != build_ldflags:
73 # we will be creating a new target name, and using that for the
74 # install link. That stops us from overwriting the existing build
75 # target, which has different ldflags
76 self.done_install_library = True
77 t = self.clone('default')
79 self.env.append_value('LINKFLAGS', build_ldflags)
83 t.env.append_value('LINKFLAGS', install_ldflags)
85 if self.samba_realname:
86 install_name = self.samba_realname
88 inst_name = t.target + '.so'
90 vnum_base = self.vnum.split('.')[0]
91 install_name = 'lib%s.so.%s' % (self.target, self.vnum)
92 install_link = 'lib%s.so.%s' % (self.target, vnum_base)
93 inst_name = 'lib%s.so' % t.target
95 install_name = 'lib%s.so' % self.target
97 inst_name = 'lib%s.so' % t.target
99 # tell waf to install the library
100 bld.install_as(os.path.join(install_path, install_name),
101 os.path.join(self.path.abspath(bld.env), inst_name))
103 # and the symlink if needed
104 bld.symlink_as(os.path.join(install_path, install_link),
109 ##############################
110 # handle the creation of links for libraries and binaries in the build tree
112 @feature('symlink_lib')
114 def symlink_lib(self):
115 '''symlink a shared lib'''
117 if self.target.endswith('.inst'):
120 blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
121 libpath = self.link_task.outputs[0].abspath(self.env)
123 # calculat the link target and put it in the environment
125 vnum = getattr(self, 'vnum', None)
127 soext = '.' + vnum.split('.')[0]
129 link_target = getattr(self, 'link_name', '')
130 if link_target == '':
131 link_target = '%s/lib%s.so%s' % (LIB_PATH, self.target, soext)
133 link_target = os.path.join(blddir, link_target)
135 if os.path.lexists(link_target):
136 os.unlink(link_target)
137 os.symlink(libpath, link_target)
140 @feature('symlink_bin')
142 def symlink_bin(self):
143 '''symlink a binary into the build directory'''
145 if self.target.endswith('.inst'):
148 blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
149 binpath = self.link_task.outputs[0].abspath(self.env)
150 bldpath = os.path.join(self.bld.env.BUILD_DIRECTORY, self.target)
152 if os.path.lexists(bldpath):
154 os.symlink(binpath, bldpath)