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 *
23 import samba_conftests
37 # some systems have broken threading in python
38 if os
.environ
.get('WAF_NOTHREADS') == '1':
43 os
.environ
['PYTHONUNBUFFERED'] = '1'
46 if Constants
.HEXVERSION
< 0x105019:
48 Please use the version of waf that comes with Samba, not
49 a system installed version. See http://wiki.samba.org/index.php/Waf
52 Alternatively, please run ./configure and make as usual. That will
53 call the right version of waf.''')
58 def SAMBA_BUILD_ENV(conf
):
59 '''create the samba build environment'''
60 conf
.env
.BUILD_DIRECTORY
= conf
.blddir
61 mkdir_p(os
.path
.join(conf
.blddir
, LIB_PATH
))
62 mkdir_p(os
.path
.join(conf
.blddir
, LIB_PATH
, "private"))
63 mkdir_p(os
.path
.join(conf
.blddir
, "modules"))
64 mkdir_p(os
.path
.join(conf
.blddir
, 'python/samba/dcerpc'))
65 # this allows all of the bin/shared and bin/python targets
66 # to be expressed in terms of build directory paths
67 mkdir_p(os
.path
.join(conf
.blddir
, 'default'))
68 for (source
, target
) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
69 link_target
= os
.path
.join(conf
.blddir
, 'default/' + target
)
70 if not os
.path
.lexists(link_target
):
71 os
.symlink('../' + source
, link_target
)
73 # get perl to put the blib files in the build directory
74 blib_bld
= os
.path
.join(conf
.blddir
, 'default/pidl/blib')
75 blib_src
= os
.path
.join(conf
.srcdir
, 'pidl/blib')
76 mkdir_p(blib_bld
+ '/man1')
77 mkdir_p(blib_bld
+ '/man3')
78 if os
.path
.islink(blib_src
):
80 elif os
.path
.exists(blib_src
):
81 shutil
.rmtree(blib_src
)
84 def ADD_INIT_FUNCTION(bld
, subsystem
, target
, init_function
):
85 '''add an init_function to the list for a subsystem'''
86 if init_function
is None:
88 bld
.ASSERT(subsystem
is not None, "You must specify a subsystem for init_function '%s'" % init_function
)
89 cache
= LOCAL_CACHE(bld
, 'INIT_FUNCTIONS')
90 if not subsystem
in cache
:
92 cache
[subsystem
].append( { 'TARGET':target
, 'INIT_FUNCTION':init_function
} )
93 Build
.BuildContext
.ADD_INIT_FUNCTION
= ADD_INIT_FUNCTION
97 #################################################################
98 def SAMBA_LIBRARY(bld
, libname
, source
,
103 public_headers_install
=True,
110 external_library
=False,
113 autoproto_extra_source
='',
124 target_type
='LIBRARY',
125 bundled_extension
=True,
131 private_library
=False,
132 grouping_library
=False,
133 allow_undefined_symbols
=False,
135 '''define a Samba library'''
137 if LIB_MUST_BE_PRIVATE(bld
, libname
):
141 SET_TARGET_TYPE(bld
, libname
, 'DISABLED')
144 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
146 source
= bld
.SUBDIR(subdir
, source
)
148 # remember empty libraries, so we can strip the dependencies
149 if ((source
== '') or (source
== [])) and deps
== '' and public_deps
== '':
150 SET_TARGET_TYPE(bld
, libname
, 'EMPTY')
153 if BUILTIN_LIBRARY(bld
, libname
):
156 obj_target
= libname
+ '.objlist'
158 if group
== 'libraries':
159 subsystem_group
= 'main'
161 subsystem_group
= group
163 # first create a target for building the object files for this library
164 # by separating in this way, we avoid recompiling the C files
165 # separately for the install library and the build library
166 bld
.SAMBA_SUBSYSTEM(obj_target
,
169 public_deps
= public_deps
,
171 public_headers
= public_headers
,
172 public_headers_install
= public_headers_install
,
173 header_path
= header_path
,
175 group
= subsystem_group
,
176 autoproto
= autoproto
,
177 autoproto_extra_source
=autoproto_extra_source
,
178 depends_on
= depends_on
,
179 hide_symbols
= hide_symbols
,
182 local_include
= local_include
,
183 global_include
= global_include
)
185 if BUILTIN_LIBRARY(bld
, libname
):
188 if not SET_TARGET_TYPE(bld
, libname
, target_type
):
191 # the library itself will depend on that object target
192 deps
+= ' ' + public_deps
194 deps
.append(obj_target
)
196 realname
= bld
.map_shlib_extension(realname
, python
=(target_type
=='PYTHON'))
197 link_name
= bld
.map_shlib_extension(link_name
, python
=(target_type
=='PYTHON'))
199 # we don't want any public libraries without version numbers
200 if (not private_library
and target_type
!= 'PYTHON' and not realname
):
201 if vnum
is None and soname
is None:
202 raise Utils
.WafError("public library '%s' must have a vnum" %
205 raise Utils
.WafError("public library '%s' must have pkg-config file" %
207 if public_headers
is None:
208 raise Utils
.WafError("public library '%s' must have header files" %
211 if target_type
== 'PYTHON' or realname
or not private_library
:
212 bundled_name
= libname
.replace('_', '-')
214 bundled_name
= PRIVATE_NAME(bld
, libname
, bundled_extension
,
217 ldflags
= TO_LIST(ldflags
)
219 features
= 'cc cshlib symlink_lib install_lib'
223 features
+= ' pyembed'
226 features
+= ' abi_check'
229 if bld
.env
.HAVE_LD_VERSION_SCRIPT
:
231 version
= "%s_%s" % (Utils
.g_module
.APPNAME
, Utils
.g_module
.VERSION
)
233 version
= "%s_%s" % (libname
, vnum
)
237 vscript
= "%s.vscript" % libname
238 bld
.ABI_VSCRIPT(libname
, abi_directory
, version
, vscript
,
240 fullname
= apply_pattern(bundled_name
, bld
.env
.shlib_PATTERN
)
241 fullpath
= bld
.path
.find_or_declare(fullname
)
242 vscriptpath
= bld
.path
.find_or_declare(vscript
)
244 raise Utils
.WafError("unable to find fullpath for %s" % fullname
)
246 raise Utils
.WafError("unable to find vscript path for %s" % vscript
)
247 bld
.add_manual_dependency(fullpath
, vscriptpath
)
248 if Options
.is_install
:
249 # also make the .inst file depend on the vscript
250 instname
= apply_pattern(bundled_name
+ '.inst', bld
.env
.shlib_PATTERN
)
251 bld
.add_manual_dependency(bld
.path
.find_or_declare(instname
), bld
.path
.find_or_declare(vscript
))
252 vscript
= os
.path
.join(bld
.path
.abspath(bld
.env
), vscript
)
254 bld
.SET_BUILD_GROUP(group
)
258 target
= bundled_name
,
259 depends_on
= depends_on
,
260 samba_ldflags
= ldflags
,
262 samba_includes
= includes
,
263 version_script
= vscript
,
264 local_include
= local_include
,
265 global_include
= global_include
,
269 samba_inst_path
= install_path
,
271 samba_realname
= realname
,
272 samba_install
= install
,
273 abi_directory
= "%s/%s" % (bld
.path
.abspath(), abi_directory
),
274 abi_match
= abi_match
,
275 private_library
= private_library
,
276 grouping_library
=grouping_library
,
277 allow_undefined_symbols
=allow_undefined_symbols
280 if realname
and not link_name
:
281 link_name
= 'shared/%s' % realname
284 t
.link_name
= link_name
286 if pc_files
is not None and not private_library
:
287 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
)
289 if (manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and
290 bld
.env
['XSLTPROC_MANPAGES']):
291 bld
.MANPAGES(manpages
, install
)
294 Build
.BuildContext
.SAMBA_LIBRARY
= SAMBA_LIBRARY
297 #################################################################
298 def SAMBA_BINARY(bld
, binname
, source
,
308 use_global_deps
=True,
321 '''define a Samba binary'''
324 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
327 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
330 features
= 'cc cprogram symlink_bin install_bin'
332 features
+= ' pyembed'
334 obj_target
= binname
+ '.objlist'
336 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
338 source
= bld
.SUBDIR(subdir
, source
)
339 source
= unique_list(TO_LIST(source
))
341 if group
== 'binaries':
342 subsystem_group
= 'main'
344 subsystem_group
= group
346 # only specify PIE flags for binaries
348 pie_ldflags
= TO_LIST(ldflags
)
349 if bld
.env
['ENABLE_PIE'] == True:
350 pie_cflags
+= ' -fPIE'
351 pie_ldflags
.extend(TO_LIST('-pie'))
353 # first create a target for building the object files for this binary
354 # by separating in this way, we avoid recompiling the C files
355 # separately for the install binary and the build binary
356 bld
.SAMBA_SUBSYSTEM(obj_target
,
361 group
= subsystem_group
,
362 autoproto
= autoproto
,
363 subsystem_name
= subsystem_name
,
364 local_include
= local_include
,
365 global_include
= global_include
,
366 use_hostcc
= use_hostcc
,
368 use_global_deps
= use_global_deps
)
370 bld
.SET_BUILD_GROUP(group
)
372 # the binary itself will depend on that object target
374 deps
.append(obj_target
)
381 samba_includes
= includes
,
382 local_include
= local_include
,
383 global_include
= global_include
,
384 samba_modules
= modules
,
386 samba_subsystem
= subsystem_name
,
388 samba_inst_path
= install_path
,
389 samba_install
= install
,
390 samba_ldflags
= pie_ldflags
393 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
394 bld
.MANPAGES(manpages
, install
)
396 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
399 #################################################################
400 def SAMBA_MODULE(bld
, modname
, source
,
405 module_init_name
='samba_init_module',
407 autoproto_extra_source
='',
409 internal_module
=True,
417 allow_undefined_symbols
=False
419 '''define a Samba module.'''
421 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
423 source
= bld
.SUBDIR(subdir
, source
)
425 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
426 # Do not create modules for disabled subsystems
427 if subsystem
and GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
429 bld
.SAMBA_SUBSYSTEM(modname
, source
,
433 autoproto_extra_source
=autoproto_extra_source
,
435 local_include
=local_include
,
436 global_include
=global_include
,
439 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
443 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
446 # Do not create modules for disabled subsystems
447 if subsystem
and GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
450 obj_target
= modname
+ '.objlist'
453 if subsystem
is not None:
454 deps
+= ' ' + subsystem
455 while realname
.startswith("lib"+subsystem
+"_"):
456 realname
= realname
[len("lib"+subsystem
+"_"):]
457 while realname
.startswith(subsystem
+"_"):
458 realname
= realname
[len(subsystem
+"_"):]
460 realname
= bld
.make_libname(realname
)
461 while realname
.startswith("lib"):
462 realname
= realname
[len("lib"):]
464 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
467 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
469 bld
.SAMBA_LIBRARY(modname
,
475 autoproto
= autoproto
,
476 local_include
=local_include
,
477 global_include
=global_include
,
479 link_name
=build_link_name
,
480 install_path
="${MODULESDIR}/%s" % subsystem
,
483 allow_undefined_symbols
=allow_undefined_symbols
487 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
490 #################################################################
491 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
496 public_headers_install
=True,
501 init_function_sentinel
=None,
503 autoproto_extra_source
='',
506 local_include_first
=True,
511 use_global_deps
=True,
517 '''define a Samba subsystem'''
520 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
523 # remember empty subsystems, so we can strip the dependencies
524 if ((source
== '') or (source
== [])) and deps
== '' and public_deps
== '':
525 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
528 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
531 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
533 source
= bld
.SUBDIR(subdir
, source
)
534 source
= unique_list(TO_LIST(source
))
536 deps
+= ' ' + public_deps
538 bld
.SET_BUILD_GROUP(group
)
544 features
+= ' pyembed'
550 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
, hide_symbols
=hide_symbols
),
551 depends_on
= depends_on
,
552 samba_deps
= TO_LIST(deps
),
553 samba_includes
= includes
,
554 local_include
= local_include
,
555 local_include_first
= local_include_first
,
556 global_include
= global_include
,
557 samba_subsystem
= subsystem_name
,
558 samba_use_hostcc
= use_hostcc
,
559 samba_use_global_deps
= use_global_deps
,
562 if cflags_end
is not None:
563 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
565 if autoproto
is not None:
566 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
567 if public_headers
is not None:
568 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
569 public_headers_install
=public_headers_install
)
573 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
576 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
577 group
='generators', enabled
=True,
579 public_headers_install
=True,
584 '''A generic source generator target'''
586 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
592 dep_vars
.append('ruledeps')
593 dep_vars
.append('SAMBA_GENERATOR_VARS')
595 bld
.SET_BUILD_GROUP(group
)
598 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
600 shell
=isinstance(rule
, str),
604 samba_type
='GENERATOR',
610 t
.env
.SAMBA_GENERATOR_VARS
= vars
615 if public_headers
is not None:
616 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
617 public_headers_install
=public_headers_install
)
619 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
624 def SETUP_BUILD_GROUPS(bld
):
625 '''setup build groups used to ensure that the different build
626 phases happen consecutively'''
627 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
628 bld
.env
['USING_BUILD_GROUPS'] = True
629 bld
.add_group('setup')
630 bld
.add_group('build_compiler_source')
631 bld
.add_group('vscripts')
632 bld
.add_group('base_libraries')
633 bld
.add_group('generators')
634 bld
.add_group('compiler_prototypes')
635 bld
.add_group('compiler_libraries')
636 bld
.add_group('build_compilers')
637 bld
.add_group('build_source')
638 bld
.add_group('prototypes')
639 bld
.add_group('headers')
640 bld
.add_group('main')
641 bld
.add_group('symbolcheck')
642 bld
.add_group('syslibcheck')
643 bld
.add_group('final')
644 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
647 def SET_BUILD_GROUP(bld
, group
):
648 '''set the current build group'''
649 if not 'USING_BUILD_GROUPS' in bld
.env
:
652 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
657 def ENABLE_TIMESTAMP_DEPENDENCIES(conf
):
658 """use timestamps instead of file contents for deps
659 this currently doesn't work"""
660 def h_file(filename
):
662 st
= os
.stat(filename
)
663 if stat
.S_ISDIR(st
[stat
.ST_MODE
]): raise IOError('not a file')
665 m
.update(str(st
.st_mtime
))
666 m
.update(str(st
.st_size
))
669 Utils
.h_file
= h_file
672 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
673 '''used to copy scripts from the source tree into the build directory
674 for use by selftest'''
676 source
= bld
.path
.ant_glob(pattern
)
678 bld
.SET_BUILD_GROUP('build_source')
679 for s
in TO_LIST(source
):
681 if installname
is not None:
683 target
= os
.path
.join(installdir
, iname
)
684 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
686 link_src
= os
.path
.normpath(os
.path
.join(bld
.curdir
, s
))
687 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
688 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
690 if os
.path
.exists(link_dst
):
692 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
693 os
.symlink(link_src
, link_dst
)
694 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
697 def copy_and_fix_python_path(task
):
698 pattern
='sys.path.insert(0, "bin/python")'
699 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
701 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
702 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
704 replacement
="""sys.path.insert(0, "%s")
705 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
707 if task
.env
["PYTHON"][0] == "/":
708 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"]
710 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"]
712 installed_location
=task
.outputs
[0].bldpath(task
.env
)
713 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
714 installed_file
= open(installed_location
, 'w')
716 for line
in source_file
:
718 if lineno
== 0 and task
.env
["PYTHON_SPECIFIED"] == True and line
[:2] == "#!":
719 newline
= replacement_shebang
720 elif pattern
in line
:
721 newline
= line
.replace(pattern
, replacement
)
722 installed_file
.write(newline
)
724 installed_file
.close()
725 os
.chmod(installed_location
, 0755)
728 def copy_and_fix_perl_path(task
):
729 pattern
='use lib "$RealBin/lib";'
732 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
733 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
735 if task
.env
["PERL"][0] == "/":
736 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
738 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
740 installed_location
=task
.outputs
[0].bldpath(task
.env
)
741 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
742 installed_file
= open(installed_location
, 'w')
744 for line
in source_file
:
746 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
747 newline
= replacement_shebang
748 elif pattern
in line
:
749 newline
= line
.replace(pattern
, replacement
)
750 installed_file
.write(newline
)
752 installed_file
.close()
753 os
.chmod(installed_location
, 0755)
757 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
758 python_fixup
=False, perl_fixup
=False,
759 destname
=None, base_name
=None):
761 destdir
= bld
.EXPAND_VARIABLES(destdir
)
765 destname
= os
.path
.basename(destname
)
766 dest
= os
.path
.join(destdir
, destname
)
768 # fix the path python will use to find Samba modules
769 inst_file
= file + '.inst'
770 bld
.SAMBA_GENERATOR('python_%s' % destname
,
771 rule
=copy_and_fix_python_path
,
772 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
777 # fix the path perl will use to find Samba modules
778 inst_file
= file + '.inst'
779 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
780 rule
=copy_and_fix_perl_path
,
781 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
786 file = os
.path
.join(base_name
, file)
787 bld
.install_as(dest
, file, chmod
=chmod
)
790 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
791 python_fixup
=False, perl_fixup
=False,
792 destname
=None, base_name
=None):
793 '''install a set of files'''
794 for f
in TO_LIST(files
):
795 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
796 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
797 destname
=destname
, base_name
=base_name
)
798 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
801 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
802 python_fixup
=False, exclude
=None, trim_path
=None):
803 '''install a set of files matching a wildcard pattern'''
804 files
=TO_LIST(bld
.path
.ant_glob(pattern
))
808 files2
.append(os_path_relpath(f
, trim_path
))
813 if fnmatch
.fnmatch(f
, exclude
):
815 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
816 python_fixup
=python_fixup
, base_name
=trim_path
)
817 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
820 def INSTALL_DIRS(bld
, destdir
, dirs
):
821 '''install a set of directories'''
822 destdir
= bld
.EXPAND_VARIABLES(destdir
)
823 dirs
= bld
.EXPAND_VARIABLES(dirs
)
824 for d
in TO_LIST(dirs
):
825 bld
.install_dir(os
.path
.join(destdir
, d
))
826 Build
.BuildContext
.INSTALL_DIRS
= INSTALL_DIRS
829 def MANPAGES(bld
, manpages
, install
):
830 '''build and install manual pages'''
831 bld
.env
.MAN_XSL
= 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
832 for m
in manpages
.split():
834 bld
.SAMBA_GENERATOR(m
,
838 rule
='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
841 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
842 Build
.BuildContext
.MANPAGES
= MANPAGES
844 def SAMBAMANPAGES(bld
, manpages
, extra_source
=None):
845 '''build and install manual pages'''
846 bld
.env
.SAMBA_EXPAND_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
847 bld
.env
.SAMBA_MAN_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/man.xsl'
848 bld
.env
.SAMBA_CATALOGS
= 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld
.srcnode
.abspath() + '/bin/default/docs-xml/build/catalog.xml'
850 for m
in manpages
.split():
852 if extra_source
is not None:
853 source
= [source
, extra_source
]
854 bld
.SAMBA_GENERATOR(m
,
858 rule
='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
859 export XML_CATALOG_FILES
860 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
861 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
863 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
864 Build
.BuildContext
.SAMBAMANPAGES
= SAMBAMANPAGES
866 #############################################################
867 # give a nicer display when building different types of files
868 def progress_display(self
, msg
, fname
):
869 col1
= Logs
.colors(self
.color
)
870 col2
= Logs
.colors
.NORMAL
871 total
= self
.position
[1]
873 fs
= '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n
, n
, msg
)
874 return fs
% (self
.position
[0], self
.position
[1], col1
, fname
, col2
)
876 def link_display(self
):
877 if Options
.options
.progress_bar
!= 0:
878 return Task
.Task
.old_display(self
)
879 fname
= self
.outputs
[0].bldpath(self
.env
)
880 return progress_display(self
, 'Linking', fname
)
881 Task
.TaskBase
.classes
['cc_link'].display
= link_display
883 def samba_display(self
):
884 if Options
.options
.progress_bar
!= 0:
885 return Task
.Task
.old_display(self
)
887 targets
= LOCAL_CACHE(self
, 'TARGET_TYPE')
888 if self
.name
in targets
:
889 target_type
= targets
[self
.name
]
890 type_map
= { 'GENERATOR' : 'Generating',
891 'PROTOTYPE' : 'Generating'
893 if target_type
in type_map
:
894 return progress_display(self
, type_map
[target_type
], self
.name
)
896 if len(self
.inputs
) == 0:
897 return Task
.Task
.old_display(self
)
899 fname
= self
.inputs
[0].bldpath(self
.env
)
900 if fname
[0:3] == '../':
902 ext_loc
= fname
.rfind('.')
904 return Task
.Task
.old_display(self
)
905 ext
= fname
[ext_loc
:]
907 ext_map
= { '.idl' : 'Compiling IDL',
908 '.et' : 'Compiling ERRTABLE',
909 '.asn1': 'Compiling ASN1',
912 return progress_display(self
, ext_map
[ext
], fname
)
913 return Task
.Task
.old_display(self
)
915 Task
.TaskBase
.classes
['Task'].old_display
= Task
.TaskBase
.classes
['Task'].display
916 Task
.TaskBase
.classes
['Task'].display
= samba_display
921 def apply_bundle_remove_dynamiclib_patch(self
):
922 if self
.env
['MACBUNDLE'] or getattr(self
,'mac_bundle',False):
923 if not getattr(self
,'vnum',None):
925 self
.env
['LINKFLAGS'].remove('-dynamiclib')
926 self
.env
['LINKFLAGS'].remove('-single_module')