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,
112 keep_underscore
=False,
114 autoproto_extra_source
='',
125 target_type
='LIBRARY',
126 bundled_extension
=True,
132 private_library
=False,
133 grouping_library
=False,
134 allow_undefined_symbols
=False,
136 '''define a Samba library'''
138 if LIB_MUST_BE_PRIVATE(bld
, libname
):
142 SET_TARGET_TYPE(bld
, libname
, 'DISABLED')
145 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
147 source
= bld
.SUBDIR(subdir
, source
)
149 # remember empty libraries, so we can strip the dependencies
150 if ((source
== '') or (source
== [])) and deps
== '' and public_deps
== '':
151 SET_TARGET_TYPE(bld
, libname
, 'EMPTY')
154 if BUILTIN_LIBRARY(bld
, libname
):
157 obj_target
= libname
+ '.objlist'
159 if group
== 'libraries':
160 subsystem_group
= 'main'
162 subsystem_group
= group
164 # first create a target for building the object files for this library
165 # by separating in this way, we avoid recompiling the C files
166 # separately for the install library and the build library
167 bld
.SAMBA_SUBSYSTEM(obj_target
,
170 public_deps
= public_deps
,
172 public_headers
= public_headers
,
173 public_headers_install
= public_headers_install
,
174 header_path
= header_path
,
176 group
= subsystem_group
,
177 autoproto
= autoproto
,
178 autoproto_extra_source
=autoproto_extra_source
,
179 depends_on
= depends_on
,
180 hide_symbols
= hide_symbols
,
183 local_include
= local_include
,
184 global_include
= global_include
)
186 if BUILTIN_LIBRARY(bld
, libname
):
189 if not SET_TARGET_TYPE(bld
, libname
, target_type
):
192 # the library itself will depend on that object target
193 deps
+= ' ' + public_deps
195 deps
.append(obj_target
)
197 realname
= bld
.map_shlib_extension(realname
, python
=(target_type
=='PYTHON'))
198 link_name
= bld
.map_shlib_extension(link_name
, python
=(target_type
=='PYTHON'))
200 # we don't want any public libraries without version numbers
201 if (not private_library
and target_type
!= 'PYTHON' and not realname
):
202 if vnum
is None and soname
is None:
203 raise Utils
.WafError("public library '%s' must have a vnum" %
206 raise Utils
.WafError("public library '%s' must have pkg-config file" %
208 if public_headers
is None:
209 raise Utils
.WafError("public library '%s' must have header files" %
212 if target_type
== 'PYTHON' or realname
or not private_library
:
214 bundled_name
= libname
216 bundled_name
= libname
.replace('_', '-')
218 bundled_name
= PRIVATE_NAME(bld
, libname
, bundled_extension
,
221 ldflags
= TO_LIST(ldflags
)
223 features
= 'cc cshlib symlink_lib install_lib'
227 features
+= ' pyembed'
230 features
+= ' abi_check'
233 if bld
.env
.HAVE_LD_VERSION_SCRIPT
:
235 version
= "%s_%s" % (Utils
.g_module
.APPNAME
, Utils
.g_module
.VERSION
)
237 version
= "%s_%s" % (libname
, vnum
)
241 vscript
= "%s.vscript" % libname
242 bld
.ABI_VSCRIPT(libname
, abi_directory
, version
, vscript
,
244 fullname
= apply_pattern(bundled_name
, bld
.env
.shlib_PATTERN
)
245 fullpath
= bld
.path
.find_or_declare(fullname
)
246 vscriptpath
= bld
.path
.find_or_declare(vscript
)
248 raise Utils
.WafError("unable to find fullpath for %s" % fullname
)
250 raise Utils
.WafError("unable to find vscript path for %s" % vscript
)
251 bld
.add_manual_dependency(fullpath
, vscriptpath
)
252 if Options
.is_install
:
253 # also make the .inst file depend on the vscript
254 instname
= apply_pattern(bundled_name
+ '.inst', bld
.env
.shlib_PATTERN
)
255 bld
.add_manual_dependency(bld
.path
.find_or_declare(instname
), bld
.path
.find_or_declare(vscript
))
256 vscript
= os
.path
.join(bld
.path
.abspath(bld
.env
), vscript
)
258 bld
.SET_BUILD_GROUP(group
)
262 target
= bundled_name
,
263 depends_on
= depends_on
,
264 samba_ldflags
= ldflags
,
266 samba_includes
= includes
,
267 version_script
= vscript
,
268 local_include
= local_include
,
269 global_include
= global_include
,
273 samba_inst_path
= install_path
,
275 samba_realname
= realname
,
276 samba_install
= install
,
277 abi_directory
= "%s/%s" % (bld
.path
.abspath(), abi_directory
),
278 abi_match
= abi_match
,
279 private_library
= private_library
,
280 grouping_library
=grouping_library
,
281 allow_undefined_symbols
=allow_undefined_symbols
284 if realname
and not link_name
:
285 link_name
= 'shared/%s' % realname
288 t
.link_name
= link_name
290 if pc_files
is not None and not private_library
:
291 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
)
293 if (manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and
294 bld
.env
['XSLTPROC_MANPAGES']):
295 bld
.MANPAGES(manpages
, install
)
298 Build
.BuildContext
.SAMBA_LIBRARY
= SAMBA_LIBRARY
301 #################################################################
302 def SAMBA_BINARY(bld
, binname
, source
,
312 use_global_deps
=True,
325 '''define a Samba binary'''
328 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
331 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
334 features
= 'cc cprogram symlink_bin install_bin'
336 features
+= ' pyembed'
338 obj_target
= binname
+ '.objlist'
340 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
342 source
= bld
.SUBDIR(subdir
, source
)
343 source
= unique_list(TO_LIST(source
))
345 if group
== 'binaries':
346 subsystem_group
= 'main'
348 subsystem_group
= group
350 # only specify PIE flags for binaries
352 pie_ldflags
= TO_LIST(ldflags
)
353 if bld
.env
['ENABLE_PIE'] == True:
354 pie_cflags
+= ' -fPIE'
355 pie_ldflags
.extend(TO_LIST('-pie'))
357 # first create a target for building the object files for this binary
358 # by separating in this way, we avoid recompiling the C files
359 # separately for the install binary and the build binary
360 bld
.SAMBA_SUBSYSTEM(obj_target
,
365 group
= subsystem_group
,
366 autoproto
= autoproto
,
367 subsystem_name
= subsystem_name
,
368 local_include
= local_include
,
369 global_include
= global_include
,
370 use_hostcc
= use_hostcc
,
372 use_global_deps
= use_global_deps
)
374 bld
.SET_BUILD_GROUP(group
)
376 # the binary itself will depend on that object target
378 deps
.append(obj_target
)
385 samba_includes
= includes
,
386 local_include
= local_include
,
387 global_include
= global_include
,
388 samba_modules
= modules
,
390 samba_subsystem
= subsystem_name
,
392 samba_inst_path
= install_path
,
393 samba_install
= install
,
394 samba_ldflags
= pie_ldflags
397 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
398 bld
.MANPAGES(manpages
, install
)
400 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
403 #################################################################
404 def SAMBA_MODULE(bld
, modname
, source
,
409 module_init_name
='samba_init_module',
411 autoproto_extra_source
='',
413 internal_module
=True,
421 allow_undefined_symbols
=False
423 '''define a Samba module.'''
425 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
427 source
= bld
.SUBDIR(subdir
, source
)
429 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
430 # Do not create modules for disabled subsystems
431 if subsystem
and GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
433 bld
.SAMBA_SUBSYSTEM(modname
, source
,
437 autoproto_extra_source
=autoproto_extra_source
,
439 local_include
=local_include
,
440 global_include
=global_include
,
443 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
447 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
450 # Do not create modules for disabled subsystems
451 if subsystem
and GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
454 obj_target
= modname
+ '.objlist'
457 if subsystem
is not None:
458 deps
+= ' ' + subsystem
459 while realname
.startswith("lib"+subsystem
+"_"):
460 realname
= realname
[len("lib"+subsystem
+"_"):]
461 while realname
.startswith(subsystem
+"_"):
462 realname
= realname
[len(subsystem
+"_"):]
464 realname
= bld
.make_libname(realname
)
465 while realname
.startswith("lib"):
466 realname
= realname
[len("lib"):]
468 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
471 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
473 bld
.SAMBA_LIBRARY(modname
,
479 autoproto
= autoproto
,
480 local_include
=local_include
,
481 global_include
=global_include
,
483 link_name
=build_link_name
,
484 install_path
="${MODULESDIR}/%s" % subsystem
,
487 allow_undefined_symbols
=allow_undefined_symbols
491 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
494 #################################################################
495 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
500 public_headers_install
=True,
505 init_function_sentinel
=None,
507 autoproto_extra_source
='',
510 local_include_first
=True,
515 use_global_deps
=True,
521 '''define a Samba subsystem'''
524 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
527 # remember empty subsystems, so we can strip the dependencies
528 if ((source
== '') or (source
== [])) and deps
== '' and public_deps
== '':
529 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
532 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
535 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
537 source
= bld
.SUBDIR(subdir
, source
)
538 source
= unique_list(TO_LIST(source
))
540 deps
+= ' ' + public_deps
542 bld
.SET_BUILD_GROUP(group
)
548 features
+= ' pyembed'
554 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
, hide_symbols
=hide_symbols
),
555 depends_on
= depends_on
,
556 samba_deps
= TO_LIST(deps
),
557 samba_includes
= includes
,
558 local_include
= local_include
,
559 local_include_first
= local_include_first
,
560 global_include
= global_include
,
561 samba_subsystem
= subsystem_name
,
562 samba_use_hostcc
= use_hostcc
,
563 samba_use_global_deps
= use_global_deps
,
566 if cflags_end
is not None:
567 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
569 if autoproto
is not None:
570 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
571 if public_headers
is not None:
572 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
573 public_headers_install
=public_headers_install
)
577 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
580 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
581 group
='generators', enabled
=True,
583 public_headers_install
=True,
588 '''A generic source generator target'''
590 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
596 dep_vars
.append('ruledeps')
597 dep_vars
.append('SAMBA_GENERATOR_VARS')
599 bld
.SET_BUILD_GROUP(group
)
602 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
604 shell
=isinstance(rule
, str),
608 samba_type
='GENERATOR',
614 t
.env
.SAMBA_GENERATOR_VARS
= vars
619 if public_headers
is not None:
620 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
621 public_headers_install
=public_headers_install
)
623 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
628 def SETUP_BUILD_GROUPS(bld
):
629 '''setup build groups used to ensure that the different build
630 phases happen consecutively'''
631 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
632 bld
.env
['USING_BUILD_GROUPS'] = True
633 bld
.add_group('setup')
634 bld
.add_group('build_compiler_source')
635 bld
.add_group('vscripts')
636 bld
.add_group('base_libraries')
637 bld
.add_group('generators')
638 bld
.add_group('compiler_prototypes')
639 bld
.add_group('compiler_libraries')
640 bld
.add_group('build_compilers')
641 bld
.add_group('build_source')
642 bld
.add_group('prototypes')
643 bld
.add_group('headers')
644 bld
.add_group('main')
645 bld
.add_group('symbolcheck')
646 bld
.add_group('syslibcheck')
647 bld
.add_group('final')
648 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
651 def SET_BUILD_GROUP(bld
, group
):
652 '''set the current build group'''
653 if not 'USING_BUILD_GROUPS' in bld
.env
:
656 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
661 def ENABLE_TIMESTAMP_DEPENDENCIES(conf
):
662 """use timestamps instead of file contents for deps
663 this currently doesn't work"""
664 def h_file(filename
):
666 st
= os
.stat(filename
)
667 if stat
.S_ISDIR(st
[stat
.ST_MODE
]): raise IOError('not a file')
669 m
.update(str(st
.st_mtime
))
670 m
.update(str(st
.st_size
))
673 Utils
.h_file
= h_file
676 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
677 '''used to copy scripts from the source tree into the build directory
678 for use by selftest'''
680 source
= bld
.path
.ant_glob(pattern
)
682 bld
.SET_BUILD_GROUP('build_source')
683 for s
in TO_LIST(source
):
685 if installname
is not None:
687 target
= os
.path
.join(installdir
, iname
)
688 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
690 link_src
= os
.path
.normpath(os
.path
.join(bld
.curdir
, s
))
691 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
692 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
694 if os
.path
.exists(link_dst
):
696 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
697 os
.symlink(link_src
, link_dst
)
698 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
701 def copy_and_fix_python_path(task
):
702 pattern
='sys.path.insert(0, "bin/python")'
703 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
705 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
706 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
708 replacement
="""sys.path.insert(0, "%s")
709 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
711 if task
.env
["PYTHON"][0] == "/":
712 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"]
714 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"]
716 installed_location
=task
.outputs
[0].bldpath(task
.env
)
717 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
718 installed_file
= open(installed_location
, 'w')
720 for line
in source_file
:
722 if lineno
== 0 and task
.env
["PYTHON_SPECIFIED"] == True and line
[:2] == "#!":
723 newline
= replacement_shebang
724 elif pattern
in line
:
725 newline
= line
.replace(pattern
, replacement
)
726 installed_file
.write(newline
)
728 installed_file
.close()
729 os
.chmod(installed_location
, 0755)
732 def copy_and_fix_perl_path(task
):
733 pattern
='use lib "$RealBin/lib";'
736 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
737 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
739 if task
.env
["PERL"][0] == "/":
740 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
742 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
744 installed_location
=task
.outputs
[0].bldpath(task
.env
)
745 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
746 installed_file
= open(installed_location
, 'w')
748 for line
in source_file
:
750 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
751 newline
= replacement_shebang
752 elif pattern
in line
:
753 newline
= line
.replace(pattern
, replacement
)
754 installed_file
.write(newline
)
756 installed_file
.close()
757 os
.chmod(installed_location
, 0755)
761 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
762 python_fixup
=False, perl_fixup
=False,
763 destname
=None, base_name
=None):
765 destdir
= bld
.EXPAND_VARIABLES(destdir
)
769 destname
= os
.path
.basename(destname
)
770 dest
= os
.path
.join(destdir
, destname
)
772 # fix the path python will use to find Samba modules
773 inst_file
= file + '.inst'
774 bld
.SAMBA_GENERATOR('python_%s' % destname
,
775 rule
=copy_and_fix_python_path
,
776 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
781 # fix the path perl will use to find Samba modules
782 inst_file
= file + '.inst'
783 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
784 rule
=copy_and_fix_perl_path
,
785 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
790 file = os
.path
.join(base_name
, file)
791 bld
.install_as(dest
, file, chmod
=chmod
)
794 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
795 python_fixup
=False, perl_fixup
=False,
796 destname
=None, base_name
=None):
797 '''install a set of files'''
798 for f
in TO_LIST(files
):
799 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
800 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
801 destname
=destname
, base_name
=base_name
)
802 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
805 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
806 python_fixup
=False, exclude
=None, trim_path
=None):
807 '''install a set of files matching a wildcard pattern'''
808 files
=TO_LIST(bld
.path
.ant_glob(pattern
))
812 files2
.append(os_path_relpath(f
, trim_path
))
817 if fnmatch
.fnmatch(f
, exclude
):
819 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
820 python_fixup
=python_fixup
, base_name
=trim_path
)
821 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
824 def INSTALL_DIRS(bld
, destdir
, dirs
):
825 '''install a set of directories'''
826 destdir
= bld
.EXPAND_VARIABLES(destdir
)
827 dirs
= bld
.EXPAND_VARIABLES(dirs
)
828 for d
in TO_LIST(dirs
):
829 bld
.install_dir(os
.path
.join(destdir
, d
))
830 Build
.BuildContext
.INSTALL_DIRS
= INSTALL_DIRS
833 def MANPAGES(bld
, manpages
, install
):
834 '''build and install manual pages'''
835 bld
.env
.MAN_XSL
= 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
836 for m
in manpages
.split():
838 bld
.SAMBA_GENERATOR(m
,
842 rule
='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
845 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
846 Build
.BuildContext
.MANPAGES
= MANPAGES
848 def SAMBAMANPAGES(bld
, manpages
, extra_source
=None):
849 '''build and install manual pages'''
850 bld
.env
.SAMBA_EXPAND_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
851 bld
.env
.SAMBA_MAN_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/man.xsl'
852 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'
854 for m
in manpages
.split():
856 if extra_source
is not None:
857 source
= [source
, extra_source
]
858 bld
.SAMBA_GENERATOR(m
,
862 rule
='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
863 export XML_CATALOG_FILES
864 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
865 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
867 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
868 Build
.BuildContext
.SAMBAMANPAGES
= SAMBAMANPAGES
870 #############################################################
871 # give a nicer display when building different types of files
872 def progress_display(self
, msg
, fname
):
873 col1
= Logs
.colors(self
.color
)
874 col2
= Logs
.colors
.NORMAL
875 total
= self
.position
[1]
877 fs
= '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n
, n
, msg
)
878 return fs
% (self
.position
[0], self
.position
[1], col1
, fname
, col2
)
880 def link_display(self
):
881 if Options
.options
.progress_bar
!= 0:
882 return Task
.Task
.old_display(self
)
883 fname
= self
.outputs
[0].bldpath(self
.env
)
884 return progress_display(self
, 'Linking', fname
)
885 Task
.TaskBase
.classes
['cc_link'].display
= link_display
887 def samba_display(self
):
888 if Options
.options
.progress_bar
!= 0:
889 return Task
.Task
.old_display(self
)
891 targets
= LOCAL_CACHE(self
, 'TARGET_TYPE')
892 if self
.name
in targets
:
893 target_type
= targets
[self
.name
]
894 type_map
= { 'GENERATOR' : 'Generating',
895 'PROTOTYPE' : 'Generating'
897 if target_type
in type_map
:
898 return progress_display(self
, type_map
[target_type
], self
.name
)
900 if len(self
.inputs
) == 0:
901 return Task
.Task
.old_display(self
)
903 fname
= self
.inputs
[0].bldpath(self
.env
)
904 if fname
[0:3] == '../':
906 ext_loc
= fname
.rfind('.')
908 return Task
.Task
.old_display(self
)
909 ext
= fname
[ext_loc
:]
911 ext_map
= { '.idl' : 'Compiling IDL',
912 '.et' : 'Compiling ERRTABLE',
913 '.asn1': 'Compiling ASN1',
916 return progress_display(self
, ext_map
[ext
], fname
)
917 return Task
.Task
.old_display(self
)
919 Task
.TaskBase
.classes
['Task'].old_display
= Task
.TaskBase
.classes
['Task'].display
920 Task
.TaskBase
.classes
['Task'].display
= samba_display
925 def apply_bundle_remove_dynamiclib_patch(self
):
926 if self
.env
['MACBUNDLE'] or getattr(self
,'mac_bundle',False):
927 if not getattr(self
,'vnum',None):
929 self
.env
['LINKFLAGS'].remove('-dynamiclib')
930 self
.env
['LINKFLAGS'].remove('-single_module')