s3:smbd: check the share level access mask in smbd_calculate_access_mask()
[Samba/gebeck_regimport.git] / buildtools / wafsamba / wafsamba.py
blob3858770a6fc916d50808cb96fb16d62bdc9f547d
1 # a waf tool to add autoconf-like macros to the configure section
2 # and for SAMBA_ macros for building libraries, binaries etc
4 import Build, os, sys, Options, Task, Utils, cc, TaskGen, fnmatch, re, shutil, Logs, Constants
5 from Configure import conf
6 from Logs import debug
7 from samba_utils import SUBST_VARS_RECURSIVE
8 TaskGen.task_gen.apply_verif = Utils.nada
10 # bring in the other samba modules
11 from samba_optimisation import *
12 from samba_utils import *
13 from samba_version import *
14 from samba_autoconf import *
15 from samba_patterns import *
16 from samba_pidl import *
17 from samba_autoproto import *
18 from samba_python import *
19 from samba_deps import *
20 from samba_bundled import *
21 import samba_install
22 import samba_conftests
23 import samba_abi
24 import samba_headers
25 import tru64cc
26 import irixcc
27 import hpuxcc
28 import generic_cc
29 import samba_dist
30 import samba_wildcard
31 import stale_files
32 import symbols
33 import pkgconfig
35 # some systems have broken threading in python
36 if os.environ.get('WAF_NOTHREADS') == '1':
37 import nothreads
39 LIB_PATH="shared"
41 os.environ['PYTHONUNBUFFERED'] = '1'
44 if Constants.HEXVERSION < 0x105019:
45 Logs.error('''
46 Please use the version of waf that comes with Samba, not
47 a system installed version. See http://wiki.samba.org/index.php/Waf
48 for details.
50 Alternatively, please run ./configure and make as usual. That will
51 call the right version of waf.''')
52 sys.exit(1)
55 @conf
56 def SAMBA_BUILD_ENV(conf):
57 '''create the samba build environment'''
58 conf.env.BUILD_DIRECTORY = conf.blddir
59 mkdir_p(os.path.join(conf.blddir, LIB_PATH))
60 mkdir_p(os.path.join(conf.blddir, LIB_PATH, "private"))
61 mkdir_p(os.path.join(conf.blddir, "modules"))
62 mkdir_p(os.path.join(conf.blddir, 'python/samba/dcerpc'))
63 # this allows all of the bin/shared and bin/python targets
64 # to be expressed in terms of build directory paths
65 mkdir_p(os.path.join(conf.blddir, 'default'))
66 for p in ['python','shared', 'modules']:
67 link_target = os.path.join(conf.blddir, 'default/' + p)
68 if not os.path.lexists(link_target):
69 os.symlink('../' + p, link_target)
71 # get perl to put the blib files in the build directory
72 blib_bld = os.path.join(conf.blddir, 'default/pidl/blib')
73 blib_src = os.path.join(conf.srcdir, 'pidl/blib')
74 mkdir_p(blib_bld + '/man1')
75 mkdir_p(blib_bld + '/man3')
76 if os.path.islink(blib_src):
77 os.unlink(blib_src)
78 elif os.path.exists(blib_src):
79 shutil.rmtree(blib_src)
82 def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
83 '''add an init_function to the list for a subsystem'''
84 if init_function is None:
85 return
86 bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
87 cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
88 if not subsystem in cache:
89 cache[subsystem] = []
90 cache[subsystem].append( { 'TARGET':target, 'INIT_FUNCTION':init_function } )
91 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
95 #################################################################
96 def SAMBA_LIBRARY(bld, libname, source,
97 deps='',
98 public_deps='',
99 includes='',
100 public_headers=None,
101 public_headers_install=True,
102 header_path=None,
103 pc_files=None,
104 vnum=None,
105 soname=None,
106 cflags='',
107 ldflags='',
108 external_library=False,
109 realname=None,
110 autoproto=None,
111 autoproto_extra_source='',
112 group='libraries',
113 depends_on='',
114 local_include=True,
115 global_include=True,
116 vars=None,
117 subdir=None,
118 install_path=None,
119 install=True,
120 pyembed=False,
121 pyext=False,
122 target_type='LIBRARY',
123 bundled_extension=True,
124 link_name=None,
125 abi_directory=None,
126 abi_match=None,
127 hide_symbols=False,
128 manpages=None,
129 private_library=False,
130 grouping_library=False,
131 allow_undefined_symbols=False,
132 enabled=True):
133 '''define a Samba library'''
135 if not enabled:
136 SET_TARGET_TYPE(bld, libname, 'DISABLED')
137 return
139 source = bld.EXPAND_VARIABLES(source, vars=vars)
140 if subdir:
141 source = bld.SUBDIR(subdir, source)
143 # remember empty libraries, so we can strip the dependencies
144 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
145 SET_TARGET_TYPE(bld, libname, 'EMPTY')
146 return
148 if BUILTIN_LIBRARY(bld, libname):
149 obj_target = libname
150 else:
151 obj_target = libname + '.objlist'
153 if group == 'libraries':
154 subsystem_group = 'main'
155 else:
156 subsystem_group = group
158 # first create a target for building the object files for this library
159 # by separating in this way, we avoid recompiling the C files
160 # separately for the install library and the build library
161 bld.SAMBA_SUBSYSTEM(obj_target,
162 source = source,
163 deps = deps,
164 public_deps = public_deps,
165 includes = includes,
166 public_headers = public_headers,
167 public_headers_install = public_headers_install,
168 header_path = header_path,
169 cflags = cflags,
170 group = subsystem_group,
171 autoproto = autoproto,
172 autoproto_extra_source=autoproto_extra_source,
173 depends_on = depends_on,
174 hide_symbols = hide_symbols,
175 pyext = pyext or (target_type == "PYTHON"),
176 local_include = local_include,
177 global_include = global_include)
179 if BUILTIN_LIBRARY(bld, libname):
180 return
182 if not SET_TARGET_TYPE(bld, libname, target_type):
183 return
185 # the library itself will depend on that object target
186 deps += ' ' + public_deps
187 deps = TO_LIST(deps)
188 deps.append(obj_target)
190 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
191 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
193 # we don't want any public libraries without version numbers
194 if not private_library and vnum is None and soname is None and target_type != 'PYTHON' and not realname:
195 raise Utils.WafError("public library '%s' must have a vnum" % libname)
197 if target_type == 'PYTHON' or realname or not private_library:
198 bundled_name = libname.replace('_', '-')
199 else:
200 bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library)
202 ldflags = TO_LIST(ldflags)
204 features = 'cc cshlib symlink_lib install_lib'
205 if target_type == 'PYTHON':
206 features += ' pyext'
207 if pyext or pyembed:
208 # this is quite strange. we should add pyext feature for pyext
209 # but that breaks the build. This may be a bug in the waf python tool
210 features += ' pyembed'
212 if abi_directory:
213 features += ' abi_check'
215 vscript = None
216 if bld.env.HAVE_LD_VERSION_SCRIPT:
217 if private_library:
218 version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
219 elif vnum:
220 version = "%s_%s" % (libname, vnum)
221 else:
222 version = None
223 if version:
224 vscript = "%s.vscript" % libname
225 bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
226 abi_match)
227 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
228 fullpath = bld.path.find_or_declare(fullname)
229 vscriptpath = bld.path.find_or_declare(vscript)
230 if not fullpath:
231 raise Utils.WafError("unable to find fullpath for %s" % fullname)
232 if not vscriptpath:
233 raise Utils.WafError("unable to find vscript path for %s" % vscript)
234 bld.add_manual_dependency(fullpath, vscriptpath)
235 if Options.is_install:
236 # also make the .inst file depend on the vscript
237 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
238 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
239 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
241 bld.SET_BUILD_GROUP(group)
242 t = bld(
243 features = features,
244 source = [],
245 target = bundled_name,
246 depends_on = depends_on,
247 samba_ldflags = ldflags,
248 samba_deps = deps,
249 samba_includes = includes,
250 version_script = vscript,
251 local_include = local_include,
252 global_include = global_include,
253 vnum = vnum,
254 soname = soname,
255 install_path = None,
256 samba_inst_path = install_path,
257 name = libname,
258 samba_realname = realname,
259 samba_install = install,
260 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
261 abi_match = abi_match,
262 private_library = private_library,
263 grouping_library=grouping_library,
264 allow_undefined_symbols=allow_undefined_symbols
267 if realname and not link_name:
268 link_name = 'shared/%s' % realname
270 if link_name:
271 t.link_name = link_name
273 if pc_files is not None:
274 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
276 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
277 bld.MANPAGES(manpages)
280 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
283 #################################################################
284 def SAMBA_BINARY(bld, binname, source,
285 deps='',
286 includes='',
287 public_headers=None,
288 header_path=None,
289 modules=None,
290 ldflags=None,
291 cflags='',
292 autoproto=None,
293 use_hostcc=False,
294 use_global_deps=True,
295 compiler=None,
296 group='binaries',
297 manpages=None,
298 local_include=True,
299 global_include=True,
300 subsystem_name=None,
301 pyembed=False,
302 vars=None,
303 subdir=None,
304 install=True,
305 install_path=None,
306 enabled=True):
307 '''define a Samba binary'''
309 if not enabled:
310 SET_TARGET_TYPE(bld, binname, 'DISABLED')
311 return
313 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
314 return
316 features = 'cc cprogram symlink_bin install_bin'
317 if pyembed:
318 features += ' pyembed'
320 obj_target = binname + '.objlist'
322 source = bld.EXPAND_VARIABLES(source, vars=vars)
323 if subdir:
324 source = bld.SUBDIR(subdir, source)
325 source = unique_list(TO_LIST(source))
327 if group == 'binaries':
328 subsystem_group = 'main'
329 else:
330 subsystem_group = group
332 # first create a target for building the object files for this binary
333 # by separating in this way, we avoid recompiling the C files
334 # separately for the install binary and the build binary
335 bld.SAMBA_SUBSYSTEM(obj_target,
336 source = source,
337 deps = deps,
338 includes = includes,
339 cflags = cflags,
340 group = subsystem_group,
341 autoproto = autoproto,
342 subsystem_name = subsystem_name,
343 local_include = local_include,
344 global_include = global_include,
345 use_hostcc = use_hostcc,
346 pyext = pyembed,
347 use_global_deps= use_global_deps)
349 bld.SET_BUILD_GROUP(group)
351 # the binary itself will depend on that object target
352 deps = TO_LIST(deps)
353 deps.append(obj_target)
355 t = bld(
356 features = features,
357 source = [],
358 target = binname,
359 samba_deps = deps,
360 samba_includes = includes,
361 local_include = local_include,
362 global_include = global_include,
363 samba_modules = modules,
364 top = True,
365 samba_subsystem= subsystem_name,
366 install_path = None,
367 samba_inst_path= install_path,
368 samba_install = install,
369 samba_ldflags = TO_LIST(ldflags)
372 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
373 bld.MANPAGES(manpages)
375 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
378 #################################################################
379 def SAMBA_MODULE(bld, modname, source,
380 deps='',
381 includes='',
382 subsystem=None,
383 init_function=None,
384 module_init_name='samba_init_module',
385 autoproto=None,
386 autoproto_extra_source='',
387 cflags='',
388 internal_module=True,
389 local_include=True,
390 global_include=True,
391 vars=None,
392 subdir=None,
393 enabled=True,
394 pyembed=False,
395 allow_undefined_symbols=False
397 '''define a Samba module.'''
399 source = bld.EXPAND_VARIABLES(source, vars=vars)
400 if subdir:
401 source = bld.SUBDIR(subdir, source)
403 if internal_module or BUILTIN_LIBRARY(bld, modname):
404 bld.SAMBA_SUBSYSTEM(modname, source,
405 deps=deps,
406 includes=includes,
407 autoproto=autoproto,
408 autoproto_extra_source=autoproto_extra_source,
409 cflags=cflags,
410 local_include=local_include,
411 global_include=global_include,
412 enabled=enabled)
414 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
415 return
417 if not enabled:
418 SET_TARGET_TYPE(bld, modname, 'DISABLED')
419 return
421 obj_target = modname + '.objlist'
423 realname = modname
424 if subsystem is not None:
425 deps += ' ' + subsystem
426 while realname.startswith("lib"+subsystem+"_"):
427 realname = realname[len("lib"+subsystem+"_"):]
428 while realname.startswith(subsystem+"_"):
429 realname = realname[len(subsystem+"_"):]
431 realname = bld.make_libname(realname)
432 while realname.startswith("lib"):
433 realname = realname[len("lib"):]
435 build_link_name = "modules/%s/%s" % (subsystem, realname)
437 if init_function:
438 cflags += " -D%s=%s" % (init_function, module_init_name)
440 bld.SAMBA_LIBRARY(modname,
441 source,
442 deps=deps,
443 includes=includes,
444 cflags=cflags,
445 realname = realname,
446 autoproto = autoproto,
447 local_include=local_include,
448 global_include=global_include,
449 vars=vars,
450 link_name=build_link_name,
451 install_path="${MODULESDIR}/%s" % subsystem,
452 pyembed=pyembed,
453 allow_undefined_symbols=allow_undefined_symbols
457 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
460 #################################################################
461 def SAMBA_SUBSYSTEM(bld, modname, source,
462 deps='',
463 public_deps='',
464 includes='',
465 public_headers=None,
466 public_headers_install=True,
467 header_path=None,
468 cflags='',
469 cflags_end=None,
470 group='main',
471 init_function_sentinal=None,
472 autoproto=None,
473 autoproto_extra_source='',
474 depends_on='',
475 local_include=True,
476 local_include_first=True,
477 global_include=True,
478 subsystem_name=None,
479 enabled=True,
480 use_hostcc=False,
481 use_global_deps=True,
482 vars=None,
483 subdir=None,
484 hide_symbols=False,
485 pyext=False):
486 '''define a Samba subsystem'''
488 if not enabled:
489 SET_TARGET_TYPE(bld, modname, 'DISABLED')
490 return
492 # remember empty subsystems, so we can strip the dependencies
493 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
494 SET_TARGET_TYPE(bld, modname, 'EMPTY')
495 return
497 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
498 return
500 source = bld.EXPAND_VARIABLES(source, vars=vars)
501 if subdir:
502 source = bld.SUBDIR(subdir, source)
503 source = unique_list(TO_LIST(source))
505 deps += ' ' + public_deps
507 bld.SET_BUILD_GROUP(group)
509 features = 'cc'
510 if pyext:
511 features += ' pyext'
513 t = bld(
514 features = features,
515 source = source,
516 target = modname,
517 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols),
518 depends_on = depends_on,
519 samba_deps = TO_LIST(deps),
520 samba_includes = includes,
521 local_include = local_include,
522 local_include_first = local_include_first,
523 global_include = global_include,
524 samba_subsystem= subsystem_name,
525 samba_use_hostcc = use_hostcc,
526 samba_use_global_deps = use_global_deps
529 if cflags_end is not None:
530 t.samba_cflags.extend(TO_LIST(cflags_end))
532 if autoproto is not None:
533 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
534 if public_headers is not None:
535 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
536 public_headers_install=public_headers_install)
537 return t
540 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
543 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
544 group='generators', enabled=True,
545 public_headers=None,
546 public_headers_install=True,
547 header_path=None,
548 vars=None,
549 always=False):
550 '''A generic source generator target'''
552 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
553 return
555 if not enabled:
556 return
558 bld.SET_BUILD_GROUP(group)
559 t = bld(
560 rule=rule,
561 source=bld.EXPAND_VARIABLES(source, vars=vars),
562 target=target,
563 shell=isinstance(rule, str),
564 on_results=True,
565 before='cc',
566 ext_out='.c',
567 samba_type='GENERATOR',
568 dep_vars = [rule] + (vars or []),
569 name=name)
571 if always:
572 t.always = True
574 if public_headers is not None:
575 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
576 public_headers_install=public_headers_install)
577 return t
578 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
582 @runonce
583 def SETUP_BUILD_GROUPS(bld):
584 '''setup build groups used to ensure that the different build
585 phases happen consecutively'''
586 bld.p_ln = bld.srcnode # we do want to see all targets!
587 bld.env['USING_BUILD_GROUPS'] = True
588 bld.add_group('setup')
589 bld.add_group('build_compiler_source')
590 bld.add_group('vscripts')
591 bld.add_group('base_libraries')
592 bld.add_group('generators')
593 bld.add_group('compiler_prototypes')
594 bld.add_group('compiler_libraries')
595 bld.add_group('build_compilers')
596 bld.add_group('build_source')
597 bld.add_group('prototypes')
598 bld.add_group('headers')
599 bld.add_group('main')
600 bld.add_group('symbolcheck')
601 bld.add_group('libraries')
602 bld.add_group('binaries')
603 bld.add_group('syslibcheck')
604 bld.add_group('final')
605 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
608 def SET_BUILD_GROUP(bld, group):
609 '''set the current build group'''
610 if not 'USING_BUILD_GROUPS' in bld.env:
611 return
612 bld.set_group(group)
613 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
617 @conf
618 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
619 """use timestamps instead of file contents for deps
620 this currently doesn't work"""
621 def h_file(filename):
622 import stat
623 st = os.stat(filename)
624 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
625 m = Utils.md5()
626 m.update(str(st.st_mtime))
627 m.update(str(st.st_size))
628 m.update(filename)
629 return m.digest()
630 Utils.h_file = h_file
633 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
634 '''used to copy scripts from the source tree into the build directory
635 for use by selftest'''
637 source = bld.path.ant_glob(pattern)
639 bld.SET_BUILD_GROUP('build_source')
640 for s in TO_LIST(source):
641 iname = s
642 if installname != None:
643 iname = installname
644 target = os.path.join(installdir, iname)
645 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
646 mkdir_p(tgtdir)
647 link_src = os.path.normpath(os.path.join(bld.curdir, s))
648 link_dst = os.path.join(tgtdir, os.path.basename(iname))
649 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
650 continue
651 if os.path.exists(link_dst):
652 os.unlink(link_dst)
653 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
654 os.symlink(link_src, link_dst)
655 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
658 def copy_and_fix_python_path(task):
659 pattern='sys.path.insert(0, "bin/python")'
660 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
661 replacement = ""
662 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
663 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
664 else:
665 replacement="""sys.path.insert(0, "%s")
666 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
668 installed_location=task.outputs[0].bldpath(task.env)
669 source_file = open(task.inputs[0].srcpath(task.env))
670 installed_file = open(installed_location, 'w')
671 for line in source_file:
672 newline = line
673 if pattern in line:
674 newline = line.replace(pattern, replacement)
675 installed_file.write(newline)
676 installed_file.close()
677 os.chmod(installed_location, 0755)
678 return 0
681 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
682 python_fixup=False, destname=None, base_name=None):
683 '''install a file'''
684 destdir = bld.EXPAND_VARIABLES(destdir)
685 if not destname:
686 destname = file
687 if flat:
688 destname = os.path.basename(destname)
689 dest = os.path.join(destdir, destname)
690 if python_fixup:
691 # fixup the python path it will use to find Samba modules
692 inst_file = file + '.inst'
693 bld.SAMBA_GENERATOR('python_%s' % destname,
694 rule=copy_and_fix_python_path,
695 source=file,
696 target=inst_file)
697 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONARCHDIR"])
698 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONDIR"])
699 file = inst_file
700 if base_name:
701 file = os.path.join(base_name, file)
702 bld.install_as(dest, file, chmod=chmod)
705 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
706 python_fixup=False, destname=None, base_name=None):
707 '''install a set of files'''
708 for f in TO_LIST(files):
709 install_file(bld, destdir, f, chmod=chmod, flat=flat,
710 python_fixup=python_fixup, destname=destname,
711 base_name=base_name)
712 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
715 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
716 python_fixup=False, exclude=None, trim_path=None):
717 '''install a set of files matching a wildcard pattern'''
718 files=TO_LIST(bld.path.ant_glob(pattern))
719 if trim_path:
720 files2 = []
721 for f in files:
722 files2.append(os_path_relpath(f, trim_path))
723 files = files2
725 if exclude:
726 for f in files[:]:
727 if fnmatch.fnmatch(f, exclude):
728 files.remove(f)
729 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
730 python_fixup=python_fixup, base_name=trim_path)
731 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
734 def INSTALL_DIRS(bld, destdir, dirs):
735 '''install a set of directories'''
736 destdir = bld.EXPAND_VARIABLES(destdir)
737 dirs = bld.EXPAND_VARIABLES(dirs)
738 for d in TO_LIST(dirs):
739 bld.install_dir(os.path.join(destdir, d))
740 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
743 def MANPAGES(bld, manpages):
744 '''build and install manual pages'''
745 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
746 for m in manpages.split():
747 source = m + '.xml'
748 bld.SAMBA_GENERATOR(m,
749 source=source,
750 target=m,
751 group='final',
752 rule='${XSLTPROC} -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
754 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
755 Build.BuildContext.MANPAGES = MANPAGES
758 #############################################################
759 # give a nicer display when building different types of files
760 def progress_display(self, msg, fname):
761 col1 = Logs.colors(self.color)
762 col2 = Logs.colors.NORMAL
763 total = self.position[1]
764 n = len(str(total))
765 fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
766 return fs % (self.position[0], self.position[1], col1, fname, col2)
768 def link_display(self):
769 if Options.options.progress_bar != 0:
770 return Task.Task.old_display(self)
771 fname = self.outputs[0].bldpath(self.env)
772 return progress_display(self, 'Linking', fname)
773 Task.TaskBase.classes['cc_link'].display = link_display
775 def samba_display(self):
776 if Options.options.progress_bar != 0:
777 return Task.Task.old_display(self)
779 targets = LOCAL_CACHE(self, 'TARGET_TYPE')
780 if self.name in targets:
781 target_type = targets[self.name]
782 type_map = { 'GENERATOR' : 'Generating',
783 'PROTOTYPE' : 'Generating'
785 if target_type in type_map:
786 return progress_display(self, type_map[target_type], self.name)
788 if len(self.inputs) == 0:
789 return Task.Task.old_display(self)
791 fname = self.inputs[0].bldpath(self.env)
792 if fname[0:3] == '../':
793 fname = fname[3:]
794 ext_loc = fname.rfind('.')
795 if ext_loc == -1:
796 return Task.Task.old_display(self)
797 ext = fname[ext_loc:]
799 ext_map = { '.idl' : 'Compiling IDL',
800 '.et' : 'Compiling ERRTABLE',
801 '.asn1': 'Compiling ASN1',
802 '.c' : 'Compiling' }
803 if ext in ext_map:
804 return progress_display(self, ext_map[ext], fname)
805 return Task.Task.old_display(self)
807 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
808 Task.TaskBase.classes['Task'].display = samba_display
811 @after('apply_link')
812 @feature('cshlib')
813 def apply_bundle_remove_dynamiclib_patch(self):
814 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
815 if not getattr(self,'vnum',None):
816 try:
817 self.env['LINKFLAGS'].remove('-dynamiclib')
818 self.env['LINKFLAGS'].remove('-single_module')
819 except ValueError:
820 pass