s3: Fix bug 8066, wrong output in smbget
[Samba.git] / buildtools / wafsamba / wafsamba.py
blob2a1c82a30779cbab6177f1a979d0359465f228d7
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 group='libraries',
112 depends_on='',
113 local_include=True,
114 global_include=True,
115 vars=None,
116 subdir=None,
117 install_path=None,
118 install=True,
119 pyembed=False,
120 pyext=False,
121 target_type='LIBRARY',
122 bundled_extension=True,
123 link_name=None,
124 abi_directory=None,
125 abi_match=None,
126 hide_symbols=False,
127 manpages=None,
128 private_library=False,
129 grouping_library=False,
130 allow_undefined_symbols=False,
131 enabled=True):
132 '''define a Samba library'''
134 if not enabled:
135 SET_TARGET_TYPE(bld, libname, 'DISABLED')
136 return
138 source = bld.EXPAND_VARIABLES(source, vars=vars)
139 if subdir:
140 source = bld.SUBDIR(subdir, source)
142 # remember empty libraries, so we can strip the dependencies
143 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
144 SET_TARGET_TYPE(bld, libname, 'EMPTY')
145 return
147 if BUILTIN_LIBRARY(bld, libname):
148 obj_target = libname
149 else:
150 obj_target = libname + '.objlist'
152 if group == 'libraries':
153 subsystem_group = 'main'
154 else:
155 subsystem_group = group
157 # first create a target for building the object files for this library
158 # by separating in this way, we avoid recompiling the C files
159 # separately for the install library and the build library
160 bld.SAMBA_SUBSYSTEM(obj_target,
161 source = source,
162 deps = deps,
163 public_deps = public_deps,
164 includes = includes,
165 public_headers = public_headers,
166 public_headers_install = public_headers_install,
167 header_path = header_path,
168 cflags = cflags,
169 group = subsystem_group,
170 autoproto = autoproto,
171 depends_on = depends_on,
172 hide_symbols = hide_symbols,
173 pyext = pyext or (target_type == "PYTHON"),
174 local_include = local_include,
175 global_include = global_include)
177 if BUILTIN_LIBRARY(bld, libname):
178 return
180 if not SET_TARGET_TYPE(bld, libname, target_type):
181 return
183 # the library itself will depend on that object target
184 deps += ' ' + public_deps
185 deps = TO_LIST(deps)
186 deps.append(obj_target)
188 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
189 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
191 # we don't want any public libraries without version numbers
192 if not private_library and vnum is None and soname is None and target_type != 'PYTHON' and not realname:
193 raise Utils.WafError("public library '%s' must have a vnum" % libname)
195 if target_type == 'PYTHON' or realname or not private_library:
196 bundled_name = libname.replace('_', '-')
197 else:
198 bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library)
200 ldflags = TO_LIST(ldflags)
202 features = 'cc cshlib symlink_lib install_lib'
203 if target_type == 'PYTHON':
204 features += ' pyext'
205 if pyext or pyembed:
206 # this is quite strange. we should add pyext feature for pyext
207 # but that breaks the build. This may be a bug in the waf python tool
208 features += ' pyembed'
210 if abi_directory:
211 features += ' abi_check'
213 vscript = None
214 if bld.env.HAVE_LD_VERSION_SCRIPT:
215 if private_library:
216 version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
217 elif vnum:
218 version = "%s_%s" % (libname, vnum)
219 else:
220 version = None
221 if version:
222 vscript = "%s.vscript" % libname
223 bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
224 abi_match)
225 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
226 fullpath = bld.path.find_or_declare(fullname)
227 vscriptpath = bld.path.find_or_declare(vscript)
228 if not fullpath:
229 raise Utils.WafError("unable to find fullpath for %s" % fullname)
230 if not vscriptpath:
231 raise Utils.WafError("unable to find vscript path for %s" % vscript)
232 bld.add_manual_dependency(fullpath, vscriptpath)
233 if Options.is_install:
234 # also make the .inst file depend on the vscript
235 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
236 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
237 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
239 bld.SET_BUILD_GROUP(group)
240 t = bld(
241 features = features,
242 source = [],
243 target = bundled_name,
244 depends_on = depends_on,
245 samba_ldflags = ldflags,
246 samba_deps = deps,
247 samba_includes = includes,
248 version_script = vscript,
249 local_include = local_include,
250 global_include = global_include,
251 vnum = vnum,
252 soname = soname,
253 install_path = None,
254 samba_inst_path = install_path,
255 name = libname,
256 samba_realname = realname,
257 samba_install = install,
258 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
259 abi_match = abi_match,
260 private_library = private_library,
261 grouping_library=grouping_library,
262 allow_undefined_symbols=allow_undefined_symbols
265 if realname and not link_name:
266 link_name = 'shared/%s' % realname
268 if link_name:
269 t.link_name = link_name
271 if pc_files is not None:
272 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
274 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
275 bld.MANPAGES(manpages)
278 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
281 #################################################################
282 def SAMBA_BINARY(bld, binname, source,
283 deps='',
284 includes='',
285 public_headers=None,
286 header_path=None,
287 modules=None,
288 ldflags=None,
289 cflags='',
290 autoproto=None,
291 use_hostcc=False,
292 use_global_deps=True,
293 compiler=None,
294 group='binaries',
295 manpages=None,
296 local_include=True,
297 global_include=True,
298 subsystem_name=None,
299 pyembed=False,
300 vars=None,
301 subdir=None,
302 install=True,
303 install_path=None,
304 enabled=True):
305 '''define a Samba binary'''
307 if not enabled:
308 SET_TARGET_TYPE(bld, binname, 'DISABLED')
309 return
311 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
312 return
314 features = 'cc cprogram symlink_bin install_bin'
315 if pyembed:
316 features += ' pyembed'
318 obj_target = binname + '.objlist'
320 source = bld.EXPAND_VARIABLES(source, vars=vars)
321 if subdir:
322 source = bld.SUBDIR(subdir, source)
323 source = unique_list(TO_LIST(source))
325 if group == 'binaries':
326 subsystem_group = 'main'
327 else:
328 subsystem_group = group
330 # first create a target for building the object files for this binary
331 # by separating in this way, we avoid recompiling the C files
332 # separately for the install binary and the build binary
333 bld.SAMBA_SUBSYSTEM(obj_target,
334 source = source,
335 deps = deps,
336 includes = includes,
337 cflags = cflags,
338 group = subsystem_group,
339 autoproto = autoproto,
340 subsystem_name = subsystem_name,
341 local_include = local_include,
342 global_include = global_include,
343 use_hostcc = use_hostcc,
344 pyext = pyembed,
345 use_global_deps= use_global_deps)
347 bld.SET_BUILD_GROUP(group)
349 # the binary itself will depend on that object target
350 deps = TO_LIST(deps)
351 deps.append(obj_target)
353 t = bld(
354 features = features,
355 source = [],
356 target = binname,
357 samba_deps = deps,
358 samba_includes = includes,
359 local_include = local_include,
360 global_include = global_include,
361 samba_modules = modules,
362 top = True,
363 samba_subsystem= subsystem_name,
364 install_path = None,
365 samba_inst_path= install_path,
366 samba_install = install,
367 samba_ldflags = TO_LIST(ldflags)
370 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
371 bld.MANPAGES(manpages)
373 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
376 #################################################################
377 def SAMBA_MODULE(bld, modname, source,
378 deps='',
379 includes='',
380 subsystem=None,
381 init_function=None,
382 module_init_name='samba_init_module',
383 autoproto=None,
384 autoproto_extra_source='',
385 cflags='',
386 internal_module=True,
387 local_include=True,
388 global_include=True,
389 vars=None,
390 subdir=None,
391 enabled=True,
392 pyembed=False,
393 allow_undefined_symbols=False
395 '''define a Samba module.'''
397 source = bld.EXPAND_VARIABLES(source, vars=vars)
398 if subdir:
399 source = bld.SUBDIR(subdir, source)
401 if internal_module or BUILTIN_LIBRARY(bld, modname):
402 bld.SAMBA_SUBSYSTEM(modname, source,
403 deps=deps,
404 includes=includes,
405 autoproto=autoproto,
406 autoproto_extra_source=autoproto_extra_source,
407 cflags=cflags,
408 local_include=local_include,
409 global_include=global_include,
410 enabled=enabled)
412 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
413 return
415 if not enabled:
416 SET_TARGET_TYPE(bld, modname, 'DISABLED')
417 return
419 obj_target = modname + '.objlist'
421 realname = modname
422 if subsystem is not None:
423 deps += ' ' + subsystem
424 while realname.startswith("lib"+subsystem+"_"):
425 realname = realname[len("lib"+subsystem+"_"):]
426 while realname.startswith(subsystem+"_"):
427 realname = realname[len(subsystem+"_"):]
429 realname = bld.make_libname(realname)
430 while realname.startswith("lib"):
431 realname = realname[len("lib"):]
433 build_link_name = "modules/%s/%s" % (subsystem, realname)
435 if init_function:
436 cflags += " -D%s=%s" % (init_function, module_init_name)
438 bld.SAMBA_LIBRARY(modname,
439 source,
440 deps=deps,
441 includes=includes,
442 cflags=cflags,
443 realname = realname,
444 autoproto = autoproto,
445 local_include=local_include,
446 global_include=global_include,
447 vars=vars,
448 link_name=build_link_name,
449 install_path="${MODULESDIR}/%s" % subsystem,
450 pyembed=pyembed,
451 allow_undefined_symbols=allow_undefined_symbols
455 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
458 #################################################################
459 def SAMBA_SUBSYSTEM(bld, modname, source,
460 deps='',
461 public_deps='',
462 includes='',
463 public_headers=None,
464 public_headers_install=True,
465 header_path=None,
466 cflags='',
467 cflags_end=None,
468 group='main',
469 init_function_sentinal=None,
470 autoproto=None,
471 autoproto_extra_source='',
472 depends_on='',
473 local_include=True,
474 local_include_first=True,
475 global_include=True,
476 subsystem_name=None,
477 enabled=True,
478 use_hostcc=False,
479 use_global_deps=True,
480 vars=None,
481 subdir=None,
482 hide_symbols=False,
483 pyext=False):
484 '''define a Samba subsystem'''
486 if not enabled:
487 SET_TARGET_TYPE(bld, modname, 'DISABLED')
488 return
490 # remember empty subsystems, so we can strip the dependencies
491 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
492 SET_TARGET_TYPE(bld, modname, 'EMPTY')
493 return
495 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
496 return
498 source = bld.EXPAND_VARIABLES(source, vars=vars)
499 if subdir:
500 source = bld.SUBDIR(subdir, source)
501 source = unique_list(TO_LIST(source))
503 deps += ' ' + public_deps
505 bld.SET_BUILD_GROUP(group)
507 features = 'cc'
508 if pyext:
509 features += ' pyext'
511 t = bld(
512 features = features,
513 source = source,
514 target = modname,
515 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols),
516 depends_on = depends_on,
517 samba_deps = TO_LIST(deps),
518 samba_includes = includes,
519 local_include = local_include,
520 local_include_first = local_include_first,
521 global_include = global_include,
522 samba_subsystem= subsystem_name,
523 samba_use_hostcc = use_hostcc,
524 samba_use_global_deps = use_global_deps
527 if cflags_end is not None:
528 t.samba_cflags.extend(TO_LIST(cflags_end))
530 if autoproto is not None:
531 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
532 if public_headers is not None:
533 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
534 public_headers_install=public_headers_install)
535 return t
538 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
541 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
542 group='generators', enabled=True,
543 public_headers=None,
544 public_headers_install=True,
545 header_path=None,
546 vars=None,
547 always=False):
548 '''A generic source generator target'''
550 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
551 return
553 if not enabled:
554 return
556 bld.SET_BUILD_GROUP(group)
557 t = bld(
558 rule=rule,
559 source=bld.EXPAND_VARIABLES(source, vars=vars),
560 target=target,
561 shell=isinstance(rule, str),
562 on_results=True,
563 before='cc',
564 ext_out='.c',
565 samba_type='GENERATOR',
566 dep_vars = [rule] + (vars or []),
567 name=name)
569 if always:
570 t.always = True
572 if public_headers is not None:
573 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
574 public_headers_install=public_headers_install)
575 return t
576 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
580 @runonce
581 def SETUP_BUILD_GROUPS(bld):
582 '''setup build groups used to ensure that the different build
583 phases happen consecutively'''
584 bld.p_ln = bld.srcnode # we do want to see all targets!
585 bld.env['USING_BUILD_GROUPS'] = True
586 bld.add_group('setup')
587 bld.add_group('build_compiler_source')
588 bld.add_group('vscripts')
589 bld.add_group('base_libraries')
590 bld.add_group('generators')
591 bld.add_group('compiler_prototypes')
592 bld.add_group('compiler_libraries')
593 bld.add_group('build_compilers')
594 bld.add_group('build_source')
595 bld.add_group('prototypes')
596 bld.add_group('headers')
597 bld.add_group('main')
598 bld.add_group('symbolcheck')
599 bld.add_group('libraries')
600 bld.add_group('binaries')
601 bld.add_group('syslibcheck')
602 bld.add_group('final')
603 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
606 def SET_BUILD_GROUP(bld, group):
607 '''set the current build group'''
608 if not 'USING_BUILD_GROUPS' in bld.env:
609 return
610 bld.set_group(group)
611 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
615 @conf
616 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
617 """use timestamps instead of file contents for deps
618 this currently doesn't work"""
619 def h_file(filename):
620 import stat
621 st = os.stat(filename)
622 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
623 m = Utils.md5()
624 m.update(str(st.st_mtime))
625 m.update(str(st.st_size))
626 m.update(filename)
627 return m.digest()
628 Utils.h_file = h_file
632 t = Task.simple_task_type('copy_script', 'rm -f "${LINK_TARGET}" && ln -s "${SRC[0].abspath(env)}" ${LINK_TARGET}',
633 shell=True, color='PINK', ext_in='.bin')
634 t.quiet = True
636 @feature('copy_script')
637 @before('apply_link')
638 def copy_script(self):
639 tsk = self.create_task('copy_script', self.allnodes[0])
640 tsk.env.TARGET = self.target
642 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
643 '''used to copy scripts from the source tree into the build directory
644 for use by selftest'''
646 source = bld.path.ant_glob(pattern)
648 bld.SET_BUILD_GROUP('build_source')
649 for s in TO_LIST(source):
650 iname = s
651 if installname != None:
652 iname = installname
653 target = os.path.join(installdir, iname)
654 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
655 mkdir_p(tgtdir)
656 t = bld(features='copy_script',
657 source = s,
658 target = target,
659 always = True,
660 install_path = None)
661 t.env.LINK_TARGET = target
663 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
665 def copy_and_fix_python_path(task):
666 pattern='sys.path.insert(0, "bin/python")'
667 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
668 replacement = ""
669 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
670 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
671 else:
672 replacement="""sys.path.insert(0, "%s")
673 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
675 installed_location=task.outputs[0].bldpath(task.env)
676 source_file = open(task.inputs[0].srcpath(task.env))
677 installed_file = open(installed_location, 'w')
678 for line in source_file:
679 newline = line
680 if pattern in line:
681 newline = line.replace(pattern, replacement)
682 installed_file.write(newline)
683 installed_file.close()
684 os.chmod(installed_location, 0755)
685 return 0
688 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
689 python_fixup=False, destname=None, base_name=None):
690 '''install a file'''
691 destdir = bld.EXPAND_VARIABLES(destdir)
692 if not destname:
693 destname = file
694 if flat:
695 destname = os.path.basename(destname)
696 dest = os.path.join(destdir, destname)
697 if python_fixup:
698 # fixup the python path it will use to find Samba modules
699 inst_file = file + '.inst'
700 bld.SAMBA_GENERATOR('python_%s' % destname,
701 rule=copy_and_fix_python_path,
702 source=file,
703 target=inst_file)
704 file = inst_file
705 if base_name:
706 file = os.path.join(base_name, file)
707 bld.install_as(dest, file, chmod=chmod)
710 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
711 python_fixup=False, destname=None, base_name=None):
712 '''install a set of files'''
713 for f in TO_LIST(files):
714 install_file(bld, destdir, f, chmod=chmod, flat=flat,
715 python_fixup=python_fixup, destname=destname,
716 base_name=base_name)
717 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
720 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
721 python_fixup=False, exclude=None, trim_path=None):
722 '''install a set of files matching a wildcard pattern'''
723 files=TO_LIST(bld.path.ant_glob(pattern))
724 if trim_path:
725 files2 = []
726 for f in files:
727 files2.append(os_path_relpath(f, trim_path))
728 files = files2
730 if exclude:
731 for f in files[:]:
732 if fnmatch.fnmatch(f, exclude):
733 files.remove(f)
734 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
735 python_fixup=python_fixup, base_name=trim_path)
736 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
739 def INSTALL_DIRS(bld, destdir, dirs):
740 '''install a set of directories'''
741 destdir = bld.EXPAND_VARIABLES(destdir)
742 dirs = bld.EXPAND_VARIABLES(dirs)
743 for d in TO_LIST(dirs):
744 bld.install_dir(os.path.join(destdir, d))
745 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
748 def MANPAGES(bld, manpages):
749 '''build and install manual pages'''
750 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
751 for m in manpages.split():
752 source = m + '.xml'
753 bld.SAMBA_GENERATOR(m,
754 source=source,
755 target=m,
756 group='final',
757 rule='${XSLTPROC} -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
759 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
760 Build.BuildContext.MANPAGES = MANPAGES
763 #############################################################
764 # give a nicer display when building different types of files
765 def progress_display(self, msg, fname):
766 col1 = Logs.colors(self.color)
767 col2 = Logs.colors.NORMAL
768 total = self.position[1]
769 n = len(str(total))
770 fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
771 return fs % (self.position[0], self.position[1], col1, fname, col2)
773 def link_display(self):
774 if Options.options.progress_bar != 0:
775 return Task.Task.old_display(self)
776 fname = self.outputs[0].bldpath(self.env)
777 return progress_display(self, 'Linking', fname)
778 Task.TaskBase.classes['cc_link'].display = link_display
780 def samba_display(self):
781 if Options.options.progress_bar != 0:
782 return Task.Task.old_display(self)
784 targets = LOCAL_CACHE(self, 'TARGET_TYPE')
785 if self.name in targets:
786 target_type = targets[self.name]
787 type_map = { 'GENERATOR' : 'Generating',
788 'PROTOTYPE' : 'Generating'
790 if target_type in type_map:
791 return progress_display(self, type_map[target_type], self.name)
793 if len(self.inputs) == 0:
794 return Task.Task.old_display(self)
796 fname = self.inputs[0].bldpath(self.env)
797 if fname[0:3] == '../':
798 fname = fname[3:]
799 ext_loc = fname.rfind('.')
800 if ext_loc == -1:
801 return Task.Task.old_display(self)
802 ext = fname[ext_loc:]
804 ext_map = { '.idl' : 'Compiling IDL',
805 '.et' : 'Compiling ERRTABLE',
806 '.asn1': 'Compiling ASN1',
807 '.c' : 'Compiling' }
808 if ext in ext_map:
809 return progress_display(self, ext_map[ext], fname)
810 return Task.Task.old_display(self)
812 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
813 Task.TaskBase.classes['Task'].display = samba_display
816 @after('apply_link')
817 @feature('cshlib')
818 def apply_bundle_remove_dynamiclib_patch(self):
819 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
820 if not getattr(self,'vnum',None):
821 try:
822 self.env['LINKFLAGS'].remove('-dynamiclib')
823 self.env['LINKFLAGS'].remove('-single_module')
824 except ValueError:
825 pass