dnsp.idl: fix payload for DSPROPERTY_ZONE_DELETED_FROM_HOSTNAME
[Samba.git] / buildtools / wafsamba / pkgconfig.py
blobb83d5f382a58352bb3318b594aa2b45fc02d87d5
1 # handle substitution of variables in pc files
3 import os, re, sys
4 from waflib import Build, Logs
5 from samba_utils import SUBST_VARS_RECURSIVE, TO_LIST
7 def subst_at_vars(task):
8 '''substiture @VAR@ style variables in a file'''
10 s = task.inputs[0].read()
11 # split on the vars
12 a = re.split('(@\w+@)', s)
13 out = []
14 done_var = {}
15 back_sub = [ ('PREFIX', '${prefix}'), ('EXEC_PREFIX', '${exec_prefix}')]
16 for v in a:
17 if re.match('@\w+@', v):
18 vname = v[1:-1]
19 if not vname in task.env and vname.upper() in task.env:
20 vname = vname.upper()
21 if not vname in task.env:
22 Logs.error("Unknown substitution %s in %s" % (v, task.name))
23 sys.exit(1)
24 v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
25 # now we back substitute the allowed pc vars
26 for (b, m) in back_sub:
27 s = task.env[b]
28 if s == v[0:len(s)]:
29 if not b in done_var:
30 # we don't want to substitute the first usage
31 done_var[b] = True
32 else:
33 v = m + v[len(s):]
34 break
35 out.append(v)
36 contents = ''.join(out)
37 task.outputs[0].write(contents)
38 return 0
41 def PKG_CONFIG_FILES(bld, pc_files, vnum=None, extra_name=None):
42 '''install some pkg_config pc files'''
43 dest = '${PKGCONFIGDIR}'
44 dest = bld.EXPAND_VARIABLES(dest)
45 for f in TO_LIST(pc_files):
46 if extra_name:
47 target = f.split('.pc')[0] + extra_name + ".pc"
48 else:
49 target = f
50 base=os.path.basename(target)
51 t = bld.SAMBA_GENERATOR('PKGCONFIG_%s' % base,
52 rule=subst_at_vars,
53 source=f+'.in',
54 target=target)
55 bld.add_manual_dependency(bld.path.find_or_declare(f), bld.env['PREFIX'].encode('utf8'))
56 t.vars = []
57 if t.env.RPATH_ON_INSTALL:
58 t.env.LIB_RPATH = t.env.RPATH_ST % t.env.LIBDIR
59 else:
60 t.env.LIB_RPATH = ''
61 if vnum:
62 t.env.PACKAGE_VERSION = vnum
63 for v in [ 'PREFIX', 'EXEC_PREFIX', 'LIB_RPATH' ]:
64 t.vars.append(t.env[v])
65 bld.INSTALL_FILES(dest, target, flat=True, destname=base)
66 Build.BuildContext.PKG_CONFIG_FILES = PKG_CONFIG_FILES