s3/vfs_tsmsm: remove unneeded cast to off_t
[Samba.git] / buildtools / wafsamba / samba_install.py
blob488729bc513dfacfaa975342c7ec17388e7bcd40
1 ###########################
2 # this handles the magic we need to do for installing
3 # with all the configure options that affect rpath and shared
4 # library use
6 import Options
7 from TaskGen import feature, before, after
8 from samba_utils import *
10 @feature('install_bin')
11 @after('apply_core')
12 @before('apply_link', 'apply_obj_vars')
13 def install_binary(self):
14 '''install a binary, taking account of the different rpath varients'''
15 bld = self.bld
17 # get the ldflags we will use for install and build
18 install_ldflags = install_rpath(bld)
19 build_ldflags = build_rpath(bld)
21 if not Options.is_install or not self.samba_install:
22 # just need to set rpath if we are not installing
23 self.env.RPATH = build_ldflags
24 return
26 # work out the install path, expanding variables
27 install_path = self.samba_inst_path or '${BINDIR}'
28 install_path = bld.EXPAND_VARIABLES(install_path)
30 orig_target = os.path.basename(self.target)
32 if install_ldflags != build_ldflags:
33 # we will be creating a new target name, and using that for the
34 # install link. That stops us from overwriting the existing build
35 # target, which has different ldflags
36 self.target += '.inst'
38 # setup the right rpath link flags for the install
39 self.env.RPATH = install_ldflags
41 # tell waf to install the right binary
42 bld.install_as(os.path.join(install_path, orig_target),
43 os.path.join(self.path.abspath(bld.env), self.target),
44 chmod=0755)
48 @feature('install_lib')
49 @after('apply_core')
50 @before('apply_link', 'apply_obj_vars')
51 def install_library(self):
52 '''install a library, taking account of the different rpath varients'''
53 if getattr(self, 'done_install_library', False):
54 return
56 bld = self.bld
58 install_ldflags = install_rpath(bld)
59 build_ldflags = build_rpath(bld)
61 if not Options.is_install or not self.samba_install:
62 # just need to set the build rpath if we are not installing
63 self.env.RPATH = build_ldflags
64 return
66 # setup the install path, expanding variables
67 install_path = self.samba_inst_path or '${LIBDIR}'
68 install_path = bld.EXPAND_VARIABLES(install_path)
70 if install_ldflags != build_ldflags:
71 # we will be creating a new target name, and using that for the
72 # install link. That stops us from overwriting the existing build
73 # target, which has different ldflags
74 self.done_install_library = True
75 t = self.clone('default')
76 t.posted = False
77 t.target += '.inst'
78 self.env.RPATH = build_ldflags
79 else:
80 t = self
82 t.env.RPATH = install_ldflags
84 dev_link = None
86 if self.samba_realname:
87 install_name = self.samba_realname
88 install_link = None
89 if getattr(self, 'samba_type', None) == 'PYTHON':
90 inst_name = '%s.so' % t.target
91 else:
92 inst_name = 'lib%s.so' % t.target
93 elif self.vnum:
94 vnum_base = self.vnum.split('.')[0]
95 install_name = 'lib%s.so.%s' % (self.target, self.vnum)
96 install_link = 'lib%s.so.%s' % (self.target, vnum_base)
97 inst_name = 'lib%s.so' % t.target
98 if not self.is_bundled:
99 # only generate the dev link for non-bundled libs
100 dev_link = 'lib%s.so' % self.target
101 else:
102 install_name = 'lib%s.so' % self.target
103 install_link = None
104 inst_name = 'lib%s.so' % t.target
106 if t.env.SONAME_ST and install_link:
107 t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_link)
108 t.env.SONAME_ST = ''
110 # tell waf to install the library
111 bld.install_as(os.path.join(install_path, install_name),
112 os.path.join(self.path.abspath(bld.env), inst_name))
113 if install_link:
114 # and the symlink if needed
115 bld.symlink_as(os.path.join(install_path, install_link),
116 install_name)
117 if dev_link:
118 bld.symlink_as(os.path.join(install_path, dev_link),
119 install_name)
123 ##############################
124 # handle the creation of links for libraries and binaries in the build tree
126 @feature('symlink_lib')
127 @after('apply_link')
128 def symlink_lib(self):
129 '''symlink a shared lib'''
131 if self.target.endswith('.inst'):
132 return
134 blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
135 libpath = self.link_task.outputs[0].abspath(self.env)
137 # calculat the link target and put it in the environment
138 soext=""
139 vnum = getattr(self, 'vnum', None)
140 if vnum is not None:
141 soext = '.' + vnum.split('.')[0]
143 link_target = getattr(self, 'link_name', '')
144 if link_target == '':
145 link_target = '%s/lib%s.so%s' % (LIB_PATH, self.target, soext)
147 link_target = os.path.join(blddir, link_target)
149 if os.path.lexists(link_target):
150 if os.path.islink(link_target) and os.readlink(link_target) == libpath:
151 return
152 os.unlink(link_target)
153 os.symlink(libpath, link_target)
156 @feature('symlink_bin')
157 @after('apply_link')
158 def symlink_bin(self):
159 '''symlink a binary into the build directory'''
161 if self.target.endswith('.inst'):
162 return
164 blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
165 binpath = self.link_task.outputs[0].abspath(self.env)
166 bldpath = os.path.join(self.bld.env.BUILD_DIRECTORY, self.link_task.outputs[0].name)
168 if os.path.lexists(bldpath):
169 if os.path.islink(bldpath) and os.readlink(bldpath) == binpath:
170 return
171 os.unlink(bldpath)
172 os.symlink(binpath, bldpath)