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
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_perl import *
20 from samba_deps import *
21 from samba_bundled import *
22 from samba_third_party import *
25 import samba_conftests
39 # some systems have broken threading in python
40 if os.environ.get('WAF_NOTHREADS') == '1':
45 os.environ['PYTHONUNBUFFERED'] = '1'
48 if Constants.HEXVERSION < 0x105019:
50 Please use the version of waf that comes with Samba, not
51 a system installed version. See http://wiki.samba.org/index.php/Waf
54 Alternatively, please run ./configure and make as usual. That will
55 call the right version of waf.''')
60 def SAMBA_BUILD_ENV(conf):
61 '''create the samba build environment'''
62 conf.env.BUILD_DIRECTORY = conf.blddir
63 mkdir_p(os.path.join(conf.blddir, LIB_PATH))
64 mkdir_p(os.path.join(conf.blddir, LIB_PATH, "private"))
65 mkdir_p(os.path.join(conf.blddir, "modules"))
66 mkdir_p(os.path.join(conf.blddir, 'python/samba/dcerpc'))
67 # this allows all of the bin/shared and bin/python targets
68 # to be expressed in terms of build directory paths
69 mkdir_p(os.path.join(conf.blddir, 'default'))
70 for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
71 link_target = os.path.join(conf.blddir, 'default/' + target)
72 if not os.path.lexists(link_target):
73 os.symlink('../' + source, link_target)
75 # get perl to put the blib files in the build directory
76 blib_bld = os.path.join(conf.blddir, 'default/pidl/blib')
77 blib_src = os.path.join(conf.srcdir, 'pidl/blib')
78 mkdir_p(blib_bld + '/man1')
79 mkdir_p(blib_bld + '/man3')
80 if os.path.islink(blib_src):
82 elif os.path.exists(blib_src):
83 shutil.rmtree(blib_src)
86 def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
87 '''add an init_function to the list for a subsystem'''
88 if init_function is None:
90 bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
91 cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
92 if not subsystem in cache:
94 cache[subsystem].append( { 'TARGET':target, 'INIT_FUNCTION':init_function } )
95 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
98 def generate_empty_file(task):
99 task.outputs[0].write('')
102 #################################################################
103 def SAMBA_LIBRARY(bld, libname, source,
108 public_headers_install=True,
115 external_library=False,
117 keep_underscore=False,
119 autoproto_extra_source='',
130 target_type='LIBRARY',
131 bundled_extension=False,
138 private_library=False,
139 grouping_library=False,
140 allow_undefined_symbols=False,
141 allow_warnings=False,
143 '''define a Samba library'''
145 if pyembed and bld.env['IS_EXTRA_PYTHON']:
146 public_headers = pc_files = None
148 if LIB_MUST_BE_PRIVATE(bld, libname):
152 SET_TARGET_TYPE(bld, libname, 'DISABLED')
155 source = bld.EXPAND_VARIABLES(source, vars=vars)
157 source = bld.SUBDIR(subdir, source)
159 # remember empty libraries, so we can strip the dependencies
160 if ((source == '') or (source == [])):
161 if deps == '' and public_deps == '':
162 SET_TARGET_TYPE(bld, libname, 'EMPTY')
164 empty_c = libname + '.empty.c'
165 bld.SAMBA_GENERATOR('%s_empty_c' % libname,
166 rule=generate_empty_file,
170 if BUILTIN_LIBRARY(bld, libname):
173 obj_target = libname + '.objlist'
175 if group == 'libraries':
176 subsystem_group = 'main'
178 subsystem_group = group
180 # first create a target for building the object files for this library
181 # by separating in this way, we avoid recompiling the C files
182 # separately for the install library and the build library
183 bld.SAMBA_SUBSYSTEM(obj_target,
186 public_deps = public_deps,
188 public_headers = public_headers,
189 public_headers_install = public_headers_install,
190 header_path = header_path,
192 group = subsystem_group,
193 autoproto = autoproto,
194 autoproto_extra_source=autoproto_extra_source,
195 depends_on = depends_on,
196 hide_symbols = hide_symbols,
197 allow_warnings = allow_warnings,
200 local_include = local_include,
201 global_include = global_include)
203 if BUILTIN_LIBRARY(bld, libname):
206 if not SET_TARGET_TYPE(bld, libname, target_type):
209 # the library itself will depend on that object target
210 deps += ' ' + public_deps
212 deps.append(obj_target)
214 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
215 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
217 # we don't want any public libraries without version numbers
218 if (not private_library and target_type != 'PYTHON' and not realname):
219 if vnum is None and soname is None:
220 raise Utils.WafError("public library '%s' must have a vnum" %
222 if pc_files is None and not bld.env['IS_EXTRA_PYTHON']:
223 raise Utils.WafError("public library '%s' must have pkg-config file" %
225 if public_headers is None and not bld.env['IS_EXTRA_PYTHON']:
226 raise Utils.WafError("public library '%s' must have header files" %
229 if bundled_name is not None:
231 elif target_type == 'PYTHON' or realname or not private_library:
233 bundled_name = libname
235 bundled_name = libname.replace('_', '-')
237 assert (private_library == True and realname is None)
238 if abi_directory or vnum or soname:
239 bundled_extension=True
240 bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-'),
241 bundled_extension, private_library)
243 ldflags = TO_LIST(ldflags)
244 if bld.env['ENABLE_RELRO'] is True:
245 ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
247 features = 'c cshlib symlink_lib install_lib'
251 features += ' pyembed'
254 features += ' abi_check'
257 if bld.env.HAVE_LD_VERSION_SCRIPT:
259 version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
261 version = "%s_%s" % (libname, vnum)
265 vscript = "%s.vscript" % libname
266 bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
268 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
269 fullpath = bld.path.find_or_declare(fullname)
270 vscriptpath = bld.path.find_or_declare(vscript)
272 raise Utils.WafError("unable to find fullpath for %s" % fullname)
274 raise Utils.WafError("unable to find vscript path for %s" % vscript)
275 bld.add_manual_dependency(fullpath, vscriptpath)
276 if Options.is_install:
277 # also make the .inst file depend on the vscript
278 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
279 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
280 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
282 bld.SET_BUILD_GROUP(group)
286 target = bundled_name,
287 depends_on = depends_on,
288 samba_ldflags = ldflags,
290 samba_includes = includes,
291 version_script = vscript,
292 local_include = local_include,
293 global_include = global_include,
297 samba_inst_path = install_path,
299 samba_realname = realname,
300 samba_install = install,
301 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
302 abi_match = abi_match,
303 private_library = private_library,
304 grouping_library=grouping_library,
305 allow_undefined_symbols=allow_undefined_symbols
308 if realname and not link_name:
309 link_name = 'shared/%s' % realname
312 t.link_name = link_name
314 if pc_files is not None and not private_library:
315 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
317 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
318 bld.env['XSLTPROC_MANPAGES']):
319 bld.MANPAGES(manpages, install)
322 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
325 #################################################################
326 def SAMBA_BINARY(bld, binname, source,
336 use_global_deps=True,
349 '''define a Samba binary'''
352 SET_TARGET_TYPE(bld, binname, 'DISABLED')
355 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
358 features = 'c cprogram symlink_bin install_bin'
360 features += ' pyembed'
362 obj_target = binname + '.objlist'
364 source = bld.EXPAND_VARIABLES(source, vars=vars)
366 source = bld.SUBDIR(subdir, source)
367 source = unique_list(TO_LIST(source))
369 if group == 'binaries':
370 subsystem_group = 'main'
372 subsystem_group = group
374 # only specify PIE flags for binaries
376 pie_ldflags = TO_LIST(ldflags)
377 if bld.env['ENABLE_PIE'] is True:
378 pie_cflags += ' -fPIE'
379 pie_ldflags.extend(TO_LIST('-pie'))
380 if bld.env['ENABLE_RELRO'] is True:
381 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
383 # first create a target for building the object files for this binary
384 # by separating in this way, we avoid recompiling the C files
385 # separately for the install binary and the build binary
386 bld.SAMBA_SUBSYSTEM(obj_target,
391 group = subsystem_group,
392 autoproto = autoproto,
393 subsystem_name = subsystem_name,
394 local_include = local_include,
395 global_include = global_include,
396 use_hostcc = use_hostcc,
398 use_global_deps= use_global_deps)
400 bld.SET_BUILD_GROUP(group)
402 # the binary itself will depend on that object target
404 deps.append(obj_target)
411 samba_includes = includes,
412 local_include = local_include,
413 global_include = global_include,
414 samba_modules = modules,
416 samba_subsystem= subsystem_name,
418 samba_inst_path= install_path,
419 samba_install = install,
420 samba_ldflags = pie_ldflags
423 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
424 bld.MANPAGES(manpages, install)
426 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
429 #################################################################
430 def SAMBA_MODULE(bld, modname, source,
435 module_init_name='samba_init_module',
437 autoproto_extra_source='',
439 internal_module=True,
447 allow_undefined_symbols=False,
450 '''define a Samba module.'''
452 bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname)
454 source = bld.EXPAND_VARIABLES(source, vars=vars)
456 source = bld.SUBDIR(subdir, source)
458 if internal_module or BUILTIN_LIBRARY(bld, modname):
459 # Do not create modules for disabled subsystems
460 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
462 bld.SAMBA_SUBSYSTEM(modname, source,
466 autoproto_extra_source=autoproto_extra_source,
468 local_include=local_include,
469 global_include=global_include,
470 allow_warnings=allow_warnings,
473 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
477 SET_TARGET_TYPE(bld, modname, 'DISABLED')
480 # Do not create modules for disabled subsystems
481 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
485 deps += ' ' + subsystem
486 while realname.startswith("lib"+subsystem+"_"):
487 realname = realname[len("lib"+subsystem+"_"):]
488 while realname.startswith(subsystem+"_"):
489 realname = realname[len(subsystem+"_"):]
491 build_name = "%s_module_%s" % (subsystem, realname)
493 realname = bld.make_libname(realname)
494 while realname.startswith("lib"):
495 realname = realname[len("lib"):]
497 build_link_name = "modules/%s/%s" % (subsystem, realname)
500 cflags += " -D%s=%s" % (init_function, module_init_name)
502 bld.SAMBA_LIBRARY(modname,
508 autoproto = autoproto,
509 local_include=local_include,
510 global_include=global_include,
512 bundled_name=build_name,
513 link_name=build_link_name,
514 install_path="${MODULESDIR}/%s" % subsystem,
517 allow_undefined_symbols=allow_undefined_symbols,
518 allow_warnings=allow_warnings
522 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
525 #################################################################
526 def SAMBA_SUBSYSTEM(bld, modname, source,
531 public_headers_install=True,
536 init_function_sentinel=None,
538 autoproto_extra_source='',
541 local_include_first=True,
546 use_global_deps=True,
550 allow_warnings=False,
553 '''define a Samba subsystem'''
556 SET_TARGET_TYPE(bld, modname, 'DISABLED')
559 # remember empty subsystems, so we can strip the dependencies
560 if ((source == '') or (source == [])):
561 if deps == '' and public_deps == '':
562 SET_TARGET_TYPE(bld, modname, 'EMPTY')
564 empty_c = modname + '.empty.c'
565 bld.SAMBA_GENERATOR('%s_empty_c' % modname,
566 rule=generate_empty_file,
570 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
573 source = bld.EXPAND_VARIABLES(source, vars=vars)
575 source = bld.SUBDIR(subdir, source)
576 source = unique_list(TO_LIST(source))
578 deps += ' ' + public_deps
580 bld.SET_BUILD_GROUP(group)
586 features += ' pyembed'
592 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags,
593 allow_warnings=allow_warnings,
594 hide_symbols=hide_symbols),
595 depends_on = depends_on,
596 samba_deps = TO_LIST(deps),
597 samba_includes = includes,
598 local_include = local_include,
599 local_include_first = local_include_first,
600 global_include = global_include,
601 samba_subsystem= subsystem_name,
602 samba_use_hostcc = use_hostcc,
603 samba_use_global_deps = use_global_deps,
606 if cflags_end is not None:
607 t.samba_cflags.extend(TO_LIST(cflags_end))
609 if autoproto is not None:
610 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
611 if public_headers is not None:
612 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
613 public_headers_install=public_headers_install)
617 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
620 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
621 group='generators', enabled=True,
623 public_headers_install=True,
628 '''A generic source generator target'''
630 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
636 dep_vars.append('ruledeps')
637 dep_vars.append('SAMBA_GENERATOR_VARS')
639 bld.SET_BUILD_GROUP(group)
642 source=bld.EXPAND_VARIABLES(source, vars=vars),
644 shell=isinstance(rule, str),
648 samba_type='GENERATOR',
654 t.env.SAMBA_GENERATOR_VARS = vars
659 if public_headers is not None:
660 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
661 public_headers_install=public_headers_install)
663 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
668 def SETUP_BUILD_GROUPS(bld):
669 '''setup build groups used to ensure that the different build
670 phases happen consecutively'''
671 bld.p_ln = bld.srcnode # we do want to see all targets!
672 bld.env['USING_BUILD_GROUPS'] = True
673 bld.add_group('setup')
674 bld.add_group('build_compiler_source')
675 bld.add_group('vscripts')
676 bld.add_group('base_libraries')
677 bld.add_group('generators')
678 bld.add_group('compiler_prototypes')
679 bld.add_group('compiler_libraries')
680 bld.add_group('build_compilers')
681 bld.add_group('build_source')
682 bld.add_group('prototypes')
683 bld.add_group('headers')
684 bld.add_group('main')
685 bld.add_group('symbolcheck')
686 bld.add_group('syslibcheck')
687 bld.add_group('final')
688 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
691 def SET_BUILD_GROUP(bld, group):
692 '''set the current build group'''
693 if not 'USING_BUILD_GROUPS' in bld.env:
696 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
701 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
702 """use timestamps instead of file contents for deps
703 this currently doesn't work"""
704 def h_file(filename):
706 st = os.stat(filename)
707 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
709 m.update(str(st.st_mtime))
710 m.update(str(st.st_size))
713 Utils.h_file = h_file
716 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
717 '''used to copy scripts from the source tree into the build directory
718 for use by selftest'''
720 source = bld.path.ant_glob(pattern)
722 bld.SET_BUILD_GROUP('build_source')
723 for s in TO_LIST(source):
725 if installname is not None:
727 target = os.path.join(installdir, iname)
728 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
730 link_src = os.path.normpath(os.path.join(bld.curdir, s))
731 link_dst = os.path.join(tgtdir, os.path.basename(iname))
732 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
734 if os.path.exists(link_dst):
736 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
737 os.symlink(link_src, link_dst)
738 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
741 def copy_and_fix_python_path(task):
742 pattern='sys.path.insert(0, "bin/python")'
743 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
745 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
746 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
748 replacement="""sys.path.insert(0, "%s")
749 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
751 if task.env["PYTHON"][0] == "/":
752 replacement_shebang = "#!%s\n" % task.env["PYTHON"]
754 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"]
756 installed_location=task.outputs[0].bldpath(task.env)
757 source_file = open(task.inputs[0].srcpath(task.env))
758 installed_file = open(installed_location, 'w')
760 for line in source_file:
762 if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and
764 newline = replacement_shebang
765 elif pattern in line:
766 newline = line.replace(pattern, replacement)
767 installed_file.write(newline)
769 installed_file.close()
770 os.chmod(installed_location, 0755)
773 def copy_and_fix_perl_path(task):
774 pattern='use lib "$RealBin/lib";'
777 if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]:
778 replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"]
780 if task.env["PERL"][0] == "/":
781 replacement_shebang = "#!%s\n" % task.env["PERL"]
783 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"]
785 installed_location=task.outputs[0].bldpath(task.env)
786 source_file = open(task.inputs[0].srcpath(task.env))
787 installed_file = open(installed_location, 'w')
789 for line in source_file:
791 if lineno == 0 and task.env["PERL_SPECIFIED"] == True and line[:2] == "#!":
792 newline = replacement_shebang
793 elif pattern in line:
794 newline = line.replace(pattern, replacement)
795 installed_file.write(newline)
797 installed_file.close()
798 os.chmod(installed_location, 0755)
802 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
803 python_fixup=False, perl_fixup=False,
804 destname=None, base_name=None):
806 destdir = bld.EXPAND_VARIABLES(destdir)
810 destname = os.path.basename(destname)
811 dest = os.path.join(destdir, destname)
813 # fix the path python will use to find Samba modules
814 inst_file = file + '.inst'
815 bld.SAMBA_GENERATOR('python_%s' % destname,
816 rule=copy_and_fix_python_path,
817 dep_vars=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
822 # fix the path perl will use to find Samba modules
823 inst_file = file + '.inst'
824 bld.SAMBA_GENERATOR('perl_%s' % destname,
825 rule=copy_and_fix_perl_path,
826 dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
831 file = os.path.join(base_name, file)
832 bld.install_as(dest, file, chmod=chmod)
835 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
836 python_fixup=False, perl_fixup=False,
837 destname=None, base_name=None):
838 '''install a set of files'''
839 for f in TO_LIST(files):
840 install_file(bld, destdir, f, chmod=chmod, flat=flat,
841 python_fixup=python_fixup, perl_fixup=perl_fixup,
842 destname=destname, base_name=base_name)
843 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
846 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
847 python_fixup=False, exclude=None, trim_path=None):
848 '''install a set of files matching a wildcard pattern'''
849 files=TO_LIST(bld.path.ant_glob(pattern))
853 files2.append(os_path_relpath(f, trim_path))
858 if fnmatch.fnmatch(f, exclude):
860 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
861 python_fixup=python_fixup, base_name=trim_path)
862 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
865 def INSTALL_DIRS(bld, destdir, dirs):
866 '''install a set of directories'''
867 destdir = bld.EXPAND_VARIABLES(destdir)
868 dirs = bld.EXPAND_VARIABLES(dirs)
869 for d in TO_LIST(dirs):
870 bld.install_dir(os.path.join(destdir, d))
871 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
874 def MANPAGES(bld, manpages, install):
875 '''build and install manual pages'''
876 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
877 for m in manpages.split():
879 bld.SAMBA_GENERATOR(m,
883 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
886 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
887 Build.BuildContext.MANPAGES = MANPAGES
889 def SAMBAMANPAGES(bld, manpages, extra_source=None):
890 '''build and install manual pages'''
891 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
892 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
893 bld.env.SAMBA_CATALOG = bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
894 bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.env.SAMBA_CATALOG
896 for m in manpages.split():
898 if extra_source is not None:
899 source = [source, extra_source]
900 bld.SAMBA_GENERATOR(m,
904 dep_vars=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
905 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
906 export XML_CATALOG_FILES
907 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
908 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
910 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
911 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
913 #############################################################
914 # give a nicer display when building different types of files
915 def progress_display(self, msg, fname):
916 col1 = Logs.colors(self.color)
917 col2 = Logs.colors.NORMAL
918 total = self.position[1]
920 fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
921 return fs % (self.position[0], self.position[1], col1, fname, col2)
923 def link_display(self):
924 if Options.options.progress_bar != 0:
925 return Task.Task.old_display(self)
926 fname = self.outputs[0].bldpath(self.env)
927 return progress_display(self, 'Linking', fname)
928 Task.TaskBase.classes['cc_link'].display = link_display
930 def samba_display(self):
931 if Options.options.progress_bar != 0:
932 return Task.Task.old_display(self)
934 targets = LOCAL_CACHE(self, 'TARGET_TYPE')
935 if self.name in targets:
936 target_type = targets[self.name]
937 type_map = { 'GENERATOR' : 'Generating',
938 'PROTOTYPE' : 'Generating'
940 if target_type in type_map:
941 return progress_display(self, type_map[target_type], self.name)
943 if len(self.inputs) == 0:
944 return Task.Task.old_display(self)
946 fname = self.inputs[0].bldpath(self.env)
947 if fname[0:3] == '../':
949 ext_loc = fname.rfind('.')
951 return Task.Task.old_display(self)
952 ext = fname[ext_loc:]
954 ext_map = { '.idl' : 'Compiling IDL',
955 '.et' : 'Compiling ERRTABLE',
956 '.asn1': 'Compiling ASN1',
959 return progress_display(self, ext_map[ext], fname)
960 return Task.Task.old_display(self)
962 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
963 Task.TaskBase.classes['Task'].display = samba_display
968 def apply_bundle_remove_dynamiclib_patch(self):
969 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
970 if not getattr(self,'vnum',None):
972 self.env['LINKFLAGS'].remove('-dynamiclib')
973 self.env['LINKFLAGS'].remove('-single_module')