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
98 #################################################################
99 def SAMBA_LIBRARY(bld
, libname
, source
,
104 public_headers_install
=True,
111 external_library
=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,
137 '''define a Samba library'''
139 if LIB_MUST_BE_PRIVATE(bld
, libname
):
143 SET_TARGET_TYPE(bld
, libname
, 'DISABLED')
146 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
148 source
= bld
.SUBDIR(subdir
, source
)
150 # remember empty libraries, so we can strip the dependencies
151 if ((source
== '') or (source
== [])) and deps
== '' and public_deps
== '':
152 SET_TARGET_TYPE(bld
, libname
, 'EMPTY')
155 if BUILTIN_LIBRARY(bld
, libname
):
158 obj_target
= libname
+ '.objlist'
160 if group
== 'libraries':
161 subsystem_group
= 'main'
163 subsystem_group
= group
165 # first create a target for building the object files for this library
166 # by separating in this way, we avoid recompiling the C files
167 # separately for the install library and the build library
168 bld
.SAMBA_SUBSYSTEM(obj_target
,
171 public_deps
= public_deps
,
173 public_headers
= public_headers
,
174 public_headers_install
= public_headers_install
,
175 header_path
= header_path
,
177 group
= subsystem_group
,
178 autoproto
= autoproto
,
179 autoproto_extra_source
=autoproto_extra_source
,
180 depends_on
= depends_on
,
181 hide_symbols
= hide_symbols
,
182 allow_warnings
= allow_warnings
,
185 local_include
= local_include
,
186 global_include
= global_include
)
188 if BUILTIN_LIBRARY(bld
, libname
):
191 if not SET_TARGET_TYPE(bld
, libname
, target_type
):
194 # the library itself will depend on that object target
195 deps
+= ' ' + public_deps
197 deps
.append(obj_target
)
199 realname
= bld
.map_shlib_extension(realname
, python
=(target_type
=='PYTHON'))
200 link_name
= bld
.map_shlib_extension(link_name
, python
=(target_type
=='PYTHON'))
202 # we don't want any public libraries without version numbers
203 if (not private_library
and target_type
!= 'PYTHON' and not realname
):
204 if vnum
is None and soname
is None:
205 raise Utils
.WafError("public library '%s' must have a vnum" %
208 raise Utils
.WafError("public library '%s' must have pkg-config file" %
210 if public_headers
is None:
211 raise Utils
.WafError("public library '%s' must have header files" %
214 if target_type
== 'PYTHON' or realname
or not private_library
:
215 bundled_name
= libname
.replace('_', '-')
217 bundled_name
= PRIVATE_NAME(bld
, libname
, bundled_extension
,
220 ldflags
= TO_LIST(ldflags
)
222 features
= 'cc cshlib symlink_lib install_lib'
226 features
+= ' pyembed'
229 features
+= ' abi_check'
232 if bld
.env
.HAVE_LD_VERSION_SCRIPT
:
234 version
= "%s_%s" % (Utils
.g_module
.APPNAME
, Utils
.g_module
.VERSION
)
236 version
= "%s_%s" % (libname
, vnum
)
240 vscript
= "%s.vscript" % libname
241 bld
.ABI_VSCRIPT(libname
, abi_directory
, version
, vscript
,
243 fullname
= apply_pattern(bundled_name
, bld
.env
.shlib_PATTERN
)
244 fullpath
= bld
.path
.find_or_declare(fullname
)
245 vscriptpath
= bld
.path
.find_or_declare(vscript
)
247 raise Utils
.WafError("unable to find fullpath for %s" % fullname
)
249 raise Utils
.WafError("unable to find vscript path for %s" % vscript
)
250 bld
.add_manual_dependency(fullpath
, vscriptpath
)
251 if Options
.is_install
:
252 # also make the .inst file depend on the vscript
253 instname
= apply_pattern(bundled_name
+ '.inst', bld
.env
.shlib_PATTERN
)
254 bld
.add_manual_dependency(bld
.path
.find_or_declare(instname
), bld
.path
.find_or_declare(vscript
))
255 vscript
= os
.path
.join(bld
.path
.abspath(bld
.env
), vscript
)
257 bld
.SET_BUILD_GROUP(group
)
261 target
= bundled_name
,
262 depends_on
= depends_on
,
263 samba_ldflags
= ldflags
,
265 samba_includes
= includes
,
266 version_script
= vscript
,
267 local_include
= local_include
,
268 global_include
= global_include
,
272 samba_inst_path
= install_path
,
274 samba_realname
= realname
,
275 samba_install
= install
,
276 abi_directory
= "%s/%s" % (bld
.path
.abspath(), abi_directory
),
277 abi_match
= abi_match
,
278 private_library
= private_library
,
279 grouping_library
=grouping_library
,
280 allow_undefined_symbols
=allow_undefined_symbols
283 if realname
and not link_name
:
284 link_name
= 'shared/%s' % realname
287 t
.link_name
= link_name
289 if pc_files
is not None and not private_library
:
290 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
)
292 if (manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and
293 bld
.env
['XSLTPROC_MANPAGES']):
294 bld
.MANPAGES(manpages
, install
)
297 Build
.BuildContext
.SAMBA_LIBRARY
= SAMBA_LIBRARY
300 #################################################################
301 def SAMBA_BINARY(bld
, binname
, source
,
311 use_global_deps
=True,
324 '''define a Samba binary'''
327 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
330 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
333 features
= 'cc cprogram symlink_bin install_bin'
335 features
+= ' pyembed'
337 obj_target
= binname
+ '.objlist'
339 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
341 source
= bld
.SUBDIR(subdir
, source
)
342 source
= unique_list(TO_LIST(source
))
344 if group
== 'binaries':
345 subsystem_group
= 'main'
347 subsystem_group
= group
349 # only specify PIE flags for binaries
351 pie_ldflags
= TO_LIST(ldflags
)
352 if bld
.env
['ENABLE_PIE'] == True:
353 pie_cflags
+= ' -fPIE'
354 pie_ldflags
.extend(TO_LIST('-pie'))
355 if bld
.env
['ENABLE_RELRO'] == True:
356 pie_ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
358 # first create a target for building the object files for this binary
359 # by separating in this way, we avoid recompiling the C files
360 # separately for the install binary and the build binary
361 bld
.SAMBA_SUBSYSTEM(obj_target
,
366 group
= subsystem_group
,
367 autoproto
= autoproto
,
368 subsystem_name
= subsystem_name
,
369 local_include
= local_include
,
370 global_include
= global_include
,
371 use_hostcc
= use_hostcc
,
373 use_global_deps
= use_global_deps
)
375 bld
.SET_BUILD_GROUP(group
)
377 # the binary itself will depend on that object target
379 deps
.append(obj_target
)
386 samba_includes
= includes
,
387 local_include
= local_include
,
388 global_include
= global_include
,
389 samba_modules
= modules
,
391 samba_subsystem
= subsystem_name
,
393 samba_inst_path
= install_path
,
394 samba_install
= install
,
395 samba_ldflags
= pie_ldflags
398 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
399 bld
.MANPAGES(manpages
, install
)
401 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
404 #################################################################
405 def SAMBA_MODULE(bld
, modname
, source
,
410 module_init_name
='samba_init_module',
412 autoproto_extra_source
='',
414 internal_module
=True,
422 allow_undefined_symbols
=False,
425 '''define a Samba module.'''
427 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
429 source
= bld
.SUBDIR(subdir
, source
)
431 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
432 # Do not create modules for disabled subsystems
433 if subsystem
and GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
435 bld
.SAMBA_SUBSYSTEM(modname
, source
,
439 autoproto_extra_source
=autoproto_extra_source
,
441 local_include
=local_include
,
442 global_include
=global_include
,
443 allow_warnings
=allow_warnings
,
446 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
450 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
453 # Do not create modules for disabled subsystems
454 if subsystem
and GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
457 obj_target
= modname
+ '.objlist'
460 if subsystem
is not None:
461 deps
+= ' ' + subsystem
462 while realname
.startswith("lib"+subsystem
+"_"):
463 realname
= realname
[len("lib"+subsystem
+"_"):]
464 while realname
.startswith(subsystem
+"_"):
465 realname
= realname
[len(subsystem
+"_"):]
467 realname
= bld
.make_libname(realname
)
468 while realname
.startswith("lib"):
469 realname
= realname
[len("lib"):]
471 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
474 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
476 bld
.SAMBA_LIBRARY(modname
,
482 autoproto
= autoproto
,
483 local_include
=local_include
,
484 global_include
=global_include
,
486 link_name
=build_link_name
,
487 install_path
="${MODULESDIR}/%s" % subsystem
,
490 allow_undefined_symbols
=allow_undefined_symbols
,
491 allow_warnings
=allow_warnings
495 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
498 #################################################################
499 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
504 public_headers_install
=True,
509 init_function_sentinel
=None,
511 autoproto_extra_source
='',
514 local_include_first
=True,
519 use_global_deps
=True,
526 '''define a Samba subsystem'''
529 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
532 # remember empty subsystems, so we can strip the dependencies
533 if ((source
== '') or (source
== [])) and deps
== '' and public_deps
== '':
534 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
537 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
540 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
542 source
= bld
.SUBDIR(subdir
, source
)
543 source
= unique_list(TO_LIST(source
))
545 deps
+= ' ' + public_deps
547 bld
.SET_BUILD_GROUP(group
)
553 features
+= ' pyembed'
559 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
,
560 allow_warnings
=allow_warnings
,
561 hide_symbols
=hide_symbols
),
562 depends_on
= depends_on
,
563 samba_deps
= TO_LIST(deps
),
564 samba_includes
= includes
,
565 local_include
= local_include
,
566 local_include_first
= local_include_first
,
567 global_include
= global_include
,
568 samba_subsystem
= subsystem_name
,
569 samba_use_hostcc
= use_hostcc
,
570 samba_use_global_deps
= use_global_deps
,
573 if cflags_end
is not None:
574 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
576 if autoproto
is not None:
577 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
578 if public_headers
is not None:
579 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
580 public_headers_install
=public_headers_install
)
584 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
587 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
588 group
='generators', enabled
=True,
590 public_headers_install
=True,
595 '''A generic source generator target'''
597 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
603 dep_vars
.append('ruledeps')
604 dep_vars
.append('SAMBA_GENERATOR_VARS')
606 bld
.SET_BUILD_GROUP(group
)
609 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
611 shell
=isinstance(rule
, str),
615 samba_type
='GENERATOR',
621 t
.env
.SAMBA_GENERATOR_VARS
= vars
626 if public_headers
is not None:
627 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
628 public_headers_install
=public_headers_install
)
630 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
635 def SETUP_BUILD_GROUPS(bld
):
636 '''setup build groups used to ensure that the different build
637 phases happen consecutively'''
638 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
639 bld
.env
['USING_BUILD_GROUPS'] = True
640 bld
.add_group('setup')
641 bld
.add_group('build_compiler_source')
642 bld
.add_group('vscripts')
643 bld
.add_group('base_libraries')
644 bld
.add_group('generators')
645 bld
.add_group('compiler_prototypes')
646 bld
.add_group('compiler_libraries')
647 bld
.add_group('build_compilers')
648 bld
.add_group('build_source')
649 bld
.add_group('prototypes')
650 bld
.add_group('headers')
651 bld
.add_group('main')
652 bld
.add_group('symbolcheck')
653 bld
.add_group('syslibcheck')
654 bld
.add_group('final')
655 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
658 def SET_BUILD_GROUP(bld
, group
):
659 '''set the current build group'''
660 if not 'USING_BUILD_GROUPS' in bld
.env
:
663 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
668 def ENABLE_TIMESTAMP_DEPENDENCIES(conf
):
669 """use timestamps instead of file contents for deps
670 this currently doesn't work"""
671 def h_file(filename
):
673 st
= os
.stat(filename
)
674 if stat
.S_ISDIR(st
[stat
.ST_MODE
]): raise IOError('not a file')
676 m
.update(str(st
.st_mtime
))
677 m
.update(str(st
.st_size
))
680 Utils
.h_file
= h_file
683 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
684 '''used to copy scripts from the source tree into the build directory
685 for use by selftest'''
687 source
= bld
.path
.ant_glob(pattern
)
689 bld
.SET_BUILD_GROUP('build_source')
690 for s
in TO_LIST(source
):
692 if installname
is not None:
694 target
= os
.path
.join(installdir
, iname
)
695 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
697 link_src
= os
.path
.normpath(os
.path
.join(bld
.curdir
, s
))
698 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
699 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
701 if os
.path
.exists(link_dst
):
703 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
704 os
.symlink(link_src
, link_dst
)
705 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
708 def copy_and_fix_python_path(task
):
709 pattern
='sys.path.insert(0, "bin/python")'
710 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
712 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
713 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
715 replacement
="""sys.path.insert(0, "%s")
716 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
718 if task
.env
["PYTHON"][0] == "/":
719 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"]
721 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"]
723 installed_location
=task
.outputs
[0].bldpath(task
.env
)
724 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
725 installed_file
= open(installed_location
, 'w')
727 for line
in source_file
:
729 if lineno
== 0 and task
.env
["PYTHON_SPECIFIED"] == True and line
[:2] == "#!":
730 newline
= replacement_shebang
731 elif pattern
in line
:
732 newline
= line
.replace(pattern
, replacement
)
733 installed_file
.write(newline
)
735 installed_file
.close()
736 os
.chmod(installed_location
, 0755)
739 def copy_and_fix_perl_path(task
):
740 pattern
='use lib "$RealBin/lib";'
743 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
744 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
746 if task
.env
["PERL"][0] == "/":
747 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
749 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
751 installed_location
=task
.outputs
[0].bldpath(task
.env
)
752 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
753 installed_file
= open(installed_location
, 'w')
755 for line
in source_file
:
757 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
758 newline
= replacement_shebang
759 elif pattern
in line
:
760 newline
= line
.replace(pattern
, replacement
)
761 installed_file
.write(newline
)
763 installed_file
.close()
764 os
.chmod(installed_location
, 0755)
768 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
769 python_fixup
=False, perl_fixup
=False,
770 destname
=None, base_name
=None):
772 destdir
= bld
.EXPAND_VARIABLES(destdir
)
776 destname
= os
.path
.basename(destname
)
777 dest
= os
.path
.join(destdir
, destname
)
779 # fix the path python will use to find Samba modules
780 inst_file
= file + '.inst'
781 bld
.SAMBA_GENERATOR('python_%s' % destname
,
782 rule
=copy_and_fix_python_path
,
783 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
788 # fix the path perl will use to find Samba modules
789 inst_file
= file + '.inst'
790 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
791 rule
=copy_and_fix_perl_path
,
792 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
797 file = os
.path
.join(base_name
, file)
798 bld
.install_as(dest
, file, chmod
=chmod
)
801 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
802 python_fixup
=False, perl_fixup
=False,
803 destname
=None, base_name
=None):
804 '''install a set of files'''
805 for f
in TO_LIST(files
):
806 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
807 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
808 destname
=destname
, base_name
=base_name
)
809 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
812 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
813 python_fixup
=False, exclude
=None, trim_path
=None):
814 '''install a set of files matching a wildcard pattern'''
815 files
=TO_LIST(bld
.path
.ant_glob(pattern
))
819 files2
.append(os_path_relpath(f
, trim_path
))
824 if fnmatch
.fnmatch(f
, exclude
):
826 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
827 python_fixup
=python_fixup
, base_name
=trim_path
)
828 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
831 def INSTALL_DIRS(bld
, destdir
, dirs
):
832 '''install a set of directories'''
833 destdir
= bld
.EXPAND_VARIABLES(destdir
)
834 dirs
= bld
.EXPAND_VARIABLES(dirs
)
835 for d
in TO_LIST(dirs
):
836 bld
.install_dir(os
.path
.join(destdir
, d
))
837 Build
.BuildContext
.INSTALL_DIRS
= INSTALL_DIRS
840 def MANPAGES(bld
, manpages
, install
):
841 '''build and install manual pages'''
842 bld
.env
.MAN_XSL
= 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
843 for m
in manpages
.split():
845 bld
.SAMBA_GENERATOR(m
,
849 rule
='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
852 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
853 Build
.BuildContext
.MANPAGES
= MANPAGES
855 def SAMBAMANPAGES(bld
, manpages
, extra_source
=None):
856 '''build and install manual pages'''
857 bld
.env
.SAMBA_EXPAND_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
858 bld
.env
.SAMBA_MAN_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/man.xsl'
859 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'
861 for m
in manpages
.split():
863 if extra_source
is not None:
864 source
= [source
, extra_source
]
865 bld
.SAMBA_GENERATOR(m
,
869 rule
='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
870 export XML_CATALOG_FILES
871 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
872 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
874 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
875 Build
.BuildContext
.SAMBAMANPAGES
= SAMBAMANPAGES
877 #############################################################
878 # give a nicer display when building different types of files
879 def progress_display(self
, msg
, fname
):
880 col1
= Logs
.colors(self
.color
)
881 col2
= Logs
.colors
.NORMAL
882 total
= self
.position
[1]
884 fs
= '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n
, n
, msg
)
885 return fs
% (self
.position
[0], self
.position
[1], col1
, fname
, col2
)
887 def link_display(self
):
888 if Options
.options
.progress_bar
!= 0:
889 return Task
.Task
.old_display(self
)
890 fname
= self
.outputs
[0].bldpath(self
.env
)
891 return progress_display(self
, 'Linking', fname
)
892 Task
.TaskBase
.classes
['cc_link'].display
= link_display
894 def samba_display(self
):
895 if Options
.options
.progress_bar
!= 0:
896 return Task
.Task
.old_display(self
)
898 targets
= LOCAL_CACHE(self
, 'TARGET_TYPE')
899 if self
.name
in targets
:
900 target_type
= targets
[self
.name
]
901 type_map
= { 'GENERATOR' : 'Generating',
902 'PROTOTYPE' : 'Generating'
904 if target_type
in type_map
:
905 return progress_display(self
, type_map
[target_type
], self
.name
)
907 if len(self
.inputs
) == 0:
908 return Task
.Task
.old_display(self
)
910 fname
= self
.inputs
[0].bldpath(self
.env
)
911 if fname
[0:3] == '../':
913 ext_loc
= fname
.rfind('.')
915 return Task
.Task
.old_display(self
)
916 ext
= fname
[ext_loc
:]
918 ext_map
= { '.idl' : 'Compiling IDL',
919 '.et' : 'Compiling ERRTABLE',
920 '.asn1': 'Compiling ASN1',
923 return progress_display(self
, ext_map
[ext
], fname
)
924 return Task
.Task
.old_display(self
)
926 Task
.TaskBase
.classes
['Task'].old_display
= Task
.TaskBase
.classes
['Task'].display
927 Task
.TaskBase
.classes
['Task'].display
= samba_display
932 def apply_bundle_remove_dynamiclib_patch(self
):
933 if self
.env
['MACBUNDLE'] or getattr(self
,'mac_bundle',False):
934 if not getattr(self
,'vnum',None):
936 self
.env
['LINKFLAGS'].remove('-dynamiclib')
937 self
.env
['LINKFLAGS'].remove('-single_module')