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 *
24 import samba_conftests
38 # some systems have broken threading in python
39 if os.environ.get('WAF_NOTHREADS') == '1':
44 os.environ['PYTHONUNBUFFERED'] = '1'
47 if Constants.HEXVERSION < 0x105019:
49 Please use the version of waf that comes with Samba, not
50 a system installed version. See http://wiki.samba.org/index.php/Waf
53 Alternatively, please run ./configure and make as usual. That will
54 call the right version of waf.''')
59 def SAMBA_BUILD_ENV(conf):
60 '''create the samba build environment'''
61 conf.env.BUILD_DIRECTORY = conf.blddir
62 mkdir_p(os.path.join(conf.blddir, LIB_PATH))
63 mkdir_p(os.path.join(conf.blddir, LIB_PATH, "private"))
64 mkdir_p(os.path.join(conf.blddir, "modules"))
65 mkdir_p(os.path.join(conf.blddir, 'python/samba/dcerpc'))
66 # this allows all of the bin/shared and bin/python targets
67 # to be expressed in terms of build directory paths
68 mkdir_p(os.path.join(conf.blddir, 'default'))
69 for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
70 link_target = os.path.join(conf.blddir, 'default/' + target)
71 if not os.path.lexists(link_target):
72 os.symlink('../' + source, link_target)
74 # get perl to put the blib files in the build directory
75 blib_bld = os.path.join(conf.blddir, 'default/pidl/blib')
76 blib_src = os.path.join(conf.srcdir, 'pidl/blib')
77 mkdir_p(blib_bld + '/man1')
78 mkdir_p(blib_bld + '/man3')
79 if os.path.islink(blib_src):
81 elif os.path.exists(blib_src):
82 shutil.rmtree(blib_src)
85 def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
86 '''add an init_function to the list for a subsystem'''
87 if init_function is None:
89 bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
90 cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
91 if not subsystem in cache:
93 cache[subsystem].append( { 'TARGET':target, 'INIT_FUNCTION':init_function } )
94 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
97 def generate_empty_file(task):
98 task.outputs[0].write('')
101 #################################################################
102 def SAMBA_LIBRARY(bld, libname, source,
107 public_headers_install=True,
114 external_library=False,
116 keep_underscore=False,
118 autoproto_extra_source='',
129 target_type='LIBRARY',
130 bundled_extension=False,
137 private_library=False,
138 grouping_library=False,
139 allow_undefined_symbols=False,
140 allow_warnings=False,
142 '''define a Samba library'''
144 if pyembed and bld.env['IS_EXTRA_PYTHON']:
145 public_headers = pc_files = None
147 if LIB_MUST_BE_PRIVATE(bld, libname):
151 SET_TARGET_TYPE(bld, libname, 'DISABLED')
154 source = bld.EXPAND_VARIABLES(source, vars=vars)
156 source = bld.SUBDIR(subdir, source)
158 # remember empty libraries, so we can strip the dependencies
159 if ((source == '') or (source == [])):
160 if deps == '' and public_deps == '':
161 SET_TARGET_TYPE(bld, libname, 'EMPTY')
163 empty_c = libname + '.empty.c'
164 bld.SAMBA_GENERATOR('%s_empty_c' % libname,
165 rule=generate_empty_file,
169 if BUILTIN_LIBRARY(bld, libname):
172 obj_target = libname + '.objlist'
174 if group == 'libraries':
175 subsystem_group = 'main'
177 subsystem_group = group
179 # first create a target for building the object files for this library
180 # by separating in this way, we avoid recompiling the C files
181 # separately for the install library and the build library
182 bld.SAMBA_SUBSYSTEM(obj_target,
185 public_deps = public_deps,
187 public_headers = public_headers,
188 public_headers_install = public_headers_install,
189 header_path = header_path,
191 group = subsystem_group,
192 autoproto = autoproto,
193 autoproto_extra_source=autoproto_extra_source,
194 depends_on = depends_on,
195 hide_symbols = hide_symbols,
196 allow_warnings = allow_warnings,
199 local_include = local_include,
200 global_include = global_include)
202 if BUILTIN_LIBRARY(bld, libname):
205 if not SET_TARGET_TYPE(bld, libname, target_type):
208 # the library itself will depend on that object target
209 deps += ' ' + public_deps
211 deps.append(obj_target)
213 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
214 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
216 # we don't want any public libraries without version numbers
217 if (not private_library and target_type != 'PYTHON' and not realname):
218 if vnum is None and soname is None:
219 raise Utils.WafError("public library '%s' must have a vnum" %
221 if pc_files is None and not bld.env['IS_EXTRA_PYTHON']:
222 raise Utils.WafError("public library '%s' must have pkg-config file" %
224 if public_headers is None and not bld.env['IS_EXTRA_PYTHON']:
225 raise Utils.WafError("public library '%s' must have header files" %
228 if bundled_name is not None:
230 elif target_type == 'PYTHON' or realname or not private_library:
232 bundled_name = libname
234 bundled_name = libname.replace('_', '-')
236 assert (private_library == True and realname is None)
237 if abi_directory or vnum or soname:
238 bundled_extension=True
239 bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-'),
240 bundled_extension, private_library)
242 ldflags = TO_LIST(ldflags)
243 if bld.env['ENABLE_RELRO'] is True:
244 ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
246 features = 'cc cshlib symlink_lib install_lib'
250 features += ' pyembed'
253 features += ' abi_check'
256 if bld.env.HAVE_LD_VERSION_SCRIPT:
258 version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
260 version = "%s_%s" % (libname, vnum)
264 vscript = "%s.vscript" % libname
265 bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
267 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
268 fullpath = bld.path.find_or_declare(fullname)
269 vscriptpath = bld.path.find_or_declare(vscript)
271 raise Utils.WafError("unable to find fullpath for %s" % fullname)
273 raise Utils.WafError("unable to find vscript path for %s" % vscript)
274 bld.add_manual_dependency(fullpath, vscriptpath)
275 if Options.is_install:
276 # also make the .inst file depend on the vscript
277 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
278 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
279 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
281 bld.SET_BUILD_GROUP(group)
285 target = bundled_name,
286 depends_on = depends_on,
287 samba_ldflags = ldflags,
289 samba_includes = includes,
290 version_script = vscript,
291 local_include = local_include,
292 global_include = global_include,
296 samba_inst_path = install_path,
298 samba_realname = realname,
299 samba_install = install,
300 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
301 abi_match = abi_match,
302 private_library = private_library,
303 grouping_library=grouping_library,
304 allow_undefined_symbols=allow_undefined_symbols
307 if realname and not link_name:
308 link_name = 'shared/%s' % realname
311 t.link_name = link_name
313 if pc_files is not None and not private_library:
314 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
316 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
317 bld.env['XSLTPROC_MANPAGES']):
318 bld.MANPAGES(manpages, install)
321 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
324 #################################################################
325 def SAMBA_BINARY(bld, binname, source,
335 use_global_deps=True,
348 '''define a Samba binary'''
351 SET_TARGET_TYPE(bld, binname, 'DISABLED')
354 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
357 features = 'cc cprogram symlink_bin install_bin'
359 features += ' pyembed'
361 obj_target = binname + '.objlist'
363 source = bld.EXPAND_VARIABLES(source, vars=vars)
365 source = bld.SUBDIR(subdir, source)
366 source = unique_list(TO_LIST(source))
368 if group == 'binaries':
369 subsystem_group = 'main'
371 subsystem_group = group
373 # only specify PIE flags for binaries
375 pie_ldflags = TO_LIST(ldflags)
376 if bld.env['ENABLE_PIE'] is True:
377 pie_cflags += ' -fPIE'
378 pie_ldflags.extend(TO_LIST('-pie'))
379 if bld.env['ENABLE_RELRO'] is True:
380 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
382 # first create a target for building the object files for this binary
383 # by separating in this way, we avoid recompiling the C files
384 # separately for the install binary and the build binary
385 bld.SAMBA_SUBSYSTEM(obj_target,
390 group = subsystem_group,
391 autoproto = autoproto,
392 subsystem_name = subsystem_name,
393 local_include = local_include,
394 global_include = global_include,
395 use_hostcc = use_hostcc,
397 use_global_deps= use_global_deps)
399 bld.SET_BUILD_GROUP(group)
401 # the binary itself will depend on that object target
403 deps.append(obj_target)
410 samba_includes = includes,
411 local_include = local_include,
412 global_include = global_include,
413 samba_modules = modules,
415 samba_subsystem= subsystem_name,
417 samba_inst_path= install_path,
418 samba_install = install,
419 samba_ldflags = pie_ldflags
422 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
423 bld.MANPAGES(manpages, install)
425 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
428 #################################################################
429 def SAMBA_MODULE(bld, modname, source,
434 module_init_name='samba_init_module',
436 autoproto_extra_source='',
438 internal_module=True,
446 allow_undefined_symbols=False,
449 '''define a Samba module.'''
451 bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname)
453 source = bld.EXPAND_VARIABLES(source, vars=vars)
455 source = bld.SUBDIR(subdir, source)
457 if internal_module or BUILTIN_LIBRARY(bld, modname):
458 # Do not create modules for disabled subsystems
459 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
461 bld.SAMBA_SUBSYSTEM(modname, source,
465 autoproto_extra_source=autoproto_extra_source,
467 local_include=local_include,
468 global_include=global_include,
469 allow_warnings=allow_warnings,
472 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
476 SET_TARGET_TYPE(bld, modname, 'DISABLED')
479 # Do not create modules for disabled subsystems
480 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
484 deps += ' ' + subsystem
485 while realname.startswith("lib"+subsystem+"_"):
486 realname = realname[len("lib"+subsystem+"_"):]
487 while realname.startswith(subsystem+"_"):
488 realname = realname[len(subsystem+"_"):]
490 build_name = "%s_module_%s" % (subsystem, realname)
492 realname = bld.make_libname(realname)
493 while realname.startswith("lib"):
494 realname = realname[len("lib"):]
496 build_link_name = "modules/%s/%s" % (subsystem, realname)
499 cflags += " -D%s=%s" % (init_function, module_init_name)
501 bld.SAMBA_LIBRARY(modname,
507 autoproto = autoproto,
508 local_include=local_include,
509 global_include=global_include,
511 bundled_name=build_name,
512 link_name=build_link_name,
513 install_path="${MODULESDIR}/%s" % subsystem,
516 allow_undefined_symbols=allow_undefined_symbols,
517 allow_warnings=allow_warnings
521 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
524 #################################################################
525 def SAMBA_SUBSYSTEM(bld, modname, source,
530 public_headers_install=True,
535 init_function_sentinel=None,
537 autoproto_extra_source='',
540 local_include_first=True,
545 use_global_deps=True,
549 allow_warnings=False,
552 '''define a Samba subsystem'''
555 SET_TARGET_TYPE(bld, modname, 'DISABLED')
558 # remember empty subsystems, so we can strip the dependencies
559 if ((source == '') or (source == [])):
560 if deps == '' and public_deps == '':
561 SET_TARGET_TYPE(bld, modname, 'EMPTY')
563 empty_c = modname + '.empty.c'
564 bld.SAMBA_GENERATOR('%s_empty_c' % modname,
565 rule=generate_empty_file,
569 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
572 source = bld.EXPAND_VARIABLES(source, vars=vars)
574 source = bld.SUBDIR(subdir, source)
575 source = unique_list(TO_LIST(source))
577 deps += ' ' + public_deps
579 bld.SET_BUILD_GROUP(group)
585 features += ' pyembed'
591 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags,
592 allow_warnings=allow_warnings,
593 hide_symbols=hide_symbols),
594 depends_on = depends_on,
595 samba_deps = TO_LIST(deps),
596 samba_includes = includes,
597 local_include = local_include,
598 local_include_first = local_include_first,
599 global_include = global_include,
600 samba_subsystem= subsystem_name,
601 samba_use_hostcc = use_hostcc,
602 samba_use_global_deps = use_global_deps,
605 if cflags_end is not None:
606 t.samba_cflags.extend(TO_LIST(cflags_end))
608 if autoproto is not None:
609 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
610 if public_headers is not None:
611 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
612 public_headers_install=public_headers_install)
616 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
619 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
620 group='generators', enabled=True,
622 public_headers_install=True,
627 '''A generic source generator target'''
629 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
635 dep_vars.append('ruledeps')
636 dep_vars.append('SAMBA_GENERATOR_VARS')
638 bld.SET_BUILD_GROUP(group)
641 source=bld.EXPAND_VARIABLES(source, vars=vars),
643 shell=isinstance(rule, str),
647 samba_type='GENERATOR',
653 t.env.SAMBA_GENERATOR_VARS = vars
658 if public_headers is not None:
659 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
660 public_headers_install=public_headers_install)
662 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
667 def SETUP_BUILD_GROUPS(bld):
668 '''setup build groups used to ensure that the different build
669 phases happen consecutively'''
670 bld.p_ln = bld.srcnode # we do want to see all targets!
671 bld.env['USING_BUILD_GROUPS'] = True
672 bld.add_group('setup')
673 bld.add_group('build_compiler_source')
674 bld.add_group('vscripts')
675 bld.add_group('base_libraries')
676 bld.add_group('generators')
677 bld.add_group('compiler_prototypes')
678 bld.add_group('compiler_libraries')
679 bld.add_group('build_compilers')
680 bld.add_group('build_source')
681 bld.add_group('prototypes')
682 bld.add_group('headers')
683 bld.add_group('main')
684 bld.add_group('symbolcheck')
685 bld.add_group('syslibcheck')
686 bld.add_group('final')
687 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
690 def SET_BUILD_GROUP(bld, group):
691 '''set the current build group'''
692 if not 'USING_BUILD_GROUPS' in bld.env:
695 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
700 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
701 """use timestamps instead of file contents for deps
702 this currently doesn't work"""
703 def h_file(filename):
705 st = os.stat(filename)
706 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
708 m.update(str(st.st_mtime))
709 m.update(str(st.st_size))
712 Utils.h_file = h_file
715 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
716 '''used to copy scripts from the source tree into the build directory
717 for use by selftest'''
719 source = bld.path.ant_glob(pattern)
721 bld.SET_BUILD_GROUP('build_source')
722 for s in TO_LIST(source):
724 if installname is not None:
726 target = os.path.join(installdir, iname)
727 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
729 link_src = os.path.normpath(os.path.join(bld.curdir, s))
730 link_dst = os.path.join(tgtdir, os.path.basename(iname))
731 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
733 if os.path.exists(link_dst):
735 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
736 os.symlink(link_src, link_dst)
737 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
740 def copy_and_fix_python_path(task):
741 pattern='sys.path.insert(0, "bin/python")'
742 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
744 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
745 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
747 replacement="""sys.path.insert(0, "%s")
748 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
750 if task.env["PYTHON"][0] == "/":
751 replacement_shebang = "#!%s\n" % task.env["PYTHON"]
753 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"]
755 installed_location=task.outputs[0].bldpath(task.env)
756 source_file = open(task.inputs[0].srcpath(task.env))
757 installed_file = open(installed_location, 'w')
759 for line in source_file:
761 if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and
763 newline = replacement_shebang
764 elif pattern in line:
765 newline = line.replace(pattern, replacement)
766 installed_file.write(newline)
768 installed_file.close()
769 os.chmod(installed_location, 0755)
772 def copy_and_fix_perl_path(task):
773 pattern='use lib "$RealBin/lib";'
776 if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]:
777 replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"]
779 if task.env["PERL"][0] == "/":
780 replacement_shebang = "#!%s\n" % task.env["PERL"]
782 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"]
784 installed_location=task.outputs[0].bldpath(task.env)
785 source_file = open(task.inputs[0].srcpath(task.env))
786 installed_file = open(installed_location, 'w')
788 for line in source_file:
790 if lineno == 0 and task.env["PERL_SPECIFIED"] == True and line[:2] == "#!":
791 newline = replacement_shebang
792 elif pattern in line:
793 newline = line.replace(pattern, replacement)
794 installed_file.write(newline)
796 installed_file.close()
797 os.chmod(installed_location, 0755)
801 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
802 python_fixup=False, perl_fixup=False,
803 destname=None, base_name=None):
805 destdir = bld.EXPAND_VARIABLES(destdir)
809 destname = os.path.basename(destname)
810 dest = os.path.join(destdir, destname)
812 # fix the path python will use to find Samba modules
813 inst_file = file + '.inst'
814 bld.SAMBA_GENERATOR('python_%s' % destname,
815 rule=copy_and_fix_python_path,
816 dep_vars=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
821 # fix the path perl will use to find Samba modules
822 inst_file = file + '.inst'
823 bld.SAMBA_GENERATOR('perl_%s' % destname,
824 rule=copy_and_fix_perl_path,
825 dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
830 file = os.path.join(base_name, file)
831 bld.install_as(dest, file, chmod=chmod)
834 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
835 python_fixup=False, perl_fixup=False,
836 destname=None, base_name=None):
837 '''install a set of files'''
838 for f in TO_LIST(files):
839 install_file(bld, destdir, f, chmod=chmod, flat=flat,
840 python_fixup=python_fixup, perl_fixup=perl_fixup,
841 destname=destname, base_name=base_name)
842 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
845 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
846 python_fixup=False, exclude=None, trim_path=None):
847 '''install a set of files matching a wildcard pattern'''
848 files=TO_LIST(bld.path.ant_glob(pattern))
852 files2.append(os_path_relpath(f, trim_path))
857 if fnmatch.fnmatch(f, exclude):
859 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
860 python_fixup=python_fixup, base_name=trim_path)
861 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
864 def INSTALL_DIRS(bld, destdir, dirs):
865 '''install a set of directories'''
866 destdir = bld.EXPAND_VARIABLES(destdir)
867 dirs = bld.EXPAND_VARIABLES(dirs)
868 for d in TO_LIST(dirs):
869 bld.install_dir(os.path.join(destdir, d))
870 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
873 def MANPAGES(bld, manpages, install):
874 '''build and install manual pages'''
875 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
876 for m in manpages.split():
878 bld.SAMBA_GENERATOR(m,
882 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
885 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
886 Build.BuildContext.MANPAGES = MANPAGES
888 def SAMBAMANPAGES(bld, manpages, extra_source=None):
889 '''build and install manual pages'''
890 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
891 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
892 bld.env.SAMBA_CATALOG = bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
893 bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.env.SAMBA_CATALOG
895 for m in manpages.split():
897 if extra_source is not None:
898 source = [source, extra_source]
899 bld.SAMBA_GENERATOR(m,
903 dep_vars=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
904 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
905 export XML_CATALOG_FILES
906 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
907 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
909 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
910 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
912 #############################################################
913 # give a nicer display when building different types of files
914 def progress_display(self, msg, fname):
915 col1 = Logs.colors(self.color)
916 col2 = Logs.colors.NORMAL
917 total = self.position[1]
919 fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
920 return fs % (self.position[0], self.position[1], col1, fname, col2)
922 def link_display(self):
923 if Options.options.progress_bar != 0:
924 return Task.Task.old_display(self)
925 fname = self.outputs[0].bldpath(self.env)
926 return progress_display(self, 'Linking', fname)
927 Task.TaskBase.classes['cc_link'].display = link_display
929 def samba_display(self):
930 if Options.options.progress_bar != 0:
931 return Task.Task.old_display(self)
933 targets = LOCAL_CACHE(self, 'TARGET_TYPE')
934 if self.name in targets:
935 target_type = targets[self.name]
936 type_map = { 'GENERATOR' : 'Generating',
937 'PROTOTYPE' : 'Generating'
939 if target_type in type_map:
940 return progress_display(self, type_map[target_type], self.name)
942 if len(self.inputs) == 0:
943 return Task.Task.old_display(self)
945 fname = self.inputs[0].bldpath(self.env)
946 if fname[0:3] == '../':
948 ext_loc = fname.rfind('.')
950 return Task.Task.old_display(self)
951 ext = fname[ext_loc:]
953 ext_map = { '.idl' : 'Compiling IDL',
954 '.et' : 'Compiling ERRTABLE',
955 '.asn1': 'Compiling ASN1',
958 return progress_display(self, ext_map[ext], fname)
959 return Task.Task.old_display(self)
961 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
962 Task.TaskBase.classes['Task'].display = samba_display
967 def apply_bundle_remove_dynamiclib_patch(self):
968 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
969 if not getattr(self,'vnum',None):
971 self.env['LINKFLAGS'].remove('-dynamiclib')
972 self.env['LINKFLAGS'].remove('-single_module')