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 target_fname
= installed_location
=task
.outputs
[0].bldpath(task
.env
)
99 target_file
= open(installed_location
, 'w')
103 #################################################################
104 def SAMBA_LIBRARY(bld
, libname
, source
,
109 public_headers_install
=True,
116 external_library
=False,
118 keep_underscore
=False,
120 autoproto_extra_source
='',
131 target_type
='LIBRARY',
132 bundled_extension
=False,
139 private_library
=False,
140 grouping_library
=False,
141 allow_undefined_symbols
=False,
142 allow_warnings
=False,
144 '''define a Samba library'''
146 if LIB_MUST_BE_PRIVATE(bld
, libname
):
150 SET_TARGET_TYPE(bld
, libname
, 'DISABLED')
153 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
155 source
= bld
.SUBDIR(subdir
, source
)
157 # remember empty libraries, so we can strip the dependencies
158 if ((source
== '') or (source
== [])):
159 if deps
== '' and public_deps
== '':
160 SET_TARGET_TYPE(bld
, libname
, 'EMPTY')
162 empty_c
= libname
+ '.empty.c'
163 bld
.SAMBA_GENERATOR('%s_empty_c' % libname
,
164 rule
=generate_empty_file
,
168 if BUILTIN_LIBRARY(bld
, libname
):
171 obj_target
= libname
+ '.objlist'
173 if group
== 'libraries':
174 subsystem_group
= 'main'
176 subsystem_group
= group
178 # first create a target for building the object files for this library
179 # by separating in this way, we avoid recompiling the C files
180 # separately for the install library and the build library
181 bld
.SAMBA_SUBSYSTEM(obj_target
,
184 public_deps
= public_deps
,
186 public_headers
= public_headers
,
187 public_headers_install
= public_headers_install
,
188 header_path
= header_path
,
190 group
= subsystem_group
,
191 autoproto
= autoproto
,
192 autoproto_extra_source
=autoproto_extra_source
,
193 depends_on
= depends_on
,
194 hide_symbols
= hide_symbols
,
195 allow_warnings
= allow_warnings
,
198 local_include
= local_include
,
199 global_include
= global_include
)
201 if BUILTIN_LIBRARY(bld
, libname
):
204 if not SET_TARGET_TYPE(bld
, libname
, target_type
):
207 # the library itself will depend on that object target
208 deps
+= ' ' + public_deps
210 deps
.append(obj_target
)
212 realname
= bld
.map_shlib_extension(realname
, python
=(target_type
=='PYTHON'))
213 link_name
= bld
.map_shlib_extension(link_name
, python
=(target_type
=='PYTHON'))
215 # we don't want any public libraries without version numbers
216 if (not private_library
and target_type
!= 'PYTHON' and not realname
):
217 if vnum
is None and soname
is None:
218 raise Utils
.WafError("public library '%s' must have a vnum" %
220 if pc_files
is None and not bld
.env
['IS_EXTRA_PYTHON']:
221 raise Utils
.WafError("public library '%s' must have pkg-config file" %
223 if public_headers
is None and not bld
.env
['IS_EXTRA_PYTHON']:
224 raise Utils
.WafError("public library '%s' must have header files" %
227 if bundled_name
is not None:
229 elif target_type
== 'PYTHON' or realname
or not private_library
:
231 bundled_name
= libname
233 bundled_name
= libname
.replace('_', '-')
235 assert (private_library
== True and realname
is None)
236 if abi_directory
or vnum
or soname
:
237 bundled_extension
=True
238 bundled_name
= PRIVATE_NAME(bld
, libname
.replace('_', '-'),
239 bundled_extension
, private_library
)
241 ldflags
= TO_LIST(ldflags
)
243 features
= 'cc cshlib symlink_lib install_lib'
247 features
+= ' pyembed'
250 features
+= ' abi_check'
253 if bld
.env
.HAVE_LD_VERSION_SCRIPT
:
255 version
= "%s_%s" % (Utils
.g_module
.APPNAME
, Utils
.g_module
.VERSION
)
257 version
= "%s_%s" % (libname
, vnum
)
261 vscript
= "%s.vscript" % libname
262 bld
.ABI_VSCRIPT(libname
, abi_directory
, version
, vscript
,
264 fullname
= apply_pattern(bundled_name
, bld
.env
.shlib_PATTERN
)
265 fullpath
= bld
.path
.find_or_declare(fullname
)
266 vscriptpath
= bld
.path
.find_or_declare(vscript
)
268 raise Utils
.WafError("unable to find fullpath for %s" % fullname
)
270 raise Utils
.WafError("unable to find vscript path for %s" % vscript
)
271 bld
.add_manual_dependency(fullpath
, vscriptpath
)
272 if Options
.is_install
:
273 # also make the .inst file depend on the vscript
274 instname
= apply_pattern(bundled_name
+ '.inst', bld
.env
.shlib_PATTERN
)
275 bld
.add_manual_dependency(bld
.path
.find_or_declare(instname
), bld
.path
.find_or_declare(vscript
))
276 vscript
= os
.path
.join(bld
.path
.abspath(bld
.env
), vscript
)
278 bld
.SET_BUILD_GROUP(group
)
282 target
= bundled_name
,
283 depends_on
= depends_on
,
284 samba_ldflags
= ldflags
,
286 samba_includes
= includes
,
287 version_script
= vscript
,
288 local_include
= local_include
,
289 global_include
= global_include
,
293 samba_inst_path
= install_path
,
295 samba_realname
= realname
,
296 samba_install
= install
,
297 abi_directory
= "%s/%s" % (bld
.path
.abspath(), abi_directory
),
298 abi_match
= abi_match
,
299 private_library
= private_library
,
300 grouping_library
=grouping_library
,
301 allow_undefined_symbols
=allow_undefined_symbols
304 if realname
and not link_name
:
305 link_name
= 'shared/%s' % realname
308 t
.link_name
= link_name
310 if pc_files
is not None and not private_library
:
311 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
)
313 if (manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and
314 bld
.env
['XSLTPROC_MANPAGES']):
315 bld
.MANPAGES(manpages
, install
)
318 Build
.BuildContext
.SAMBA_LIBRARY
= SAMBA_LIBRARY
321 #################################################################
322 def SAMBA_BINARY(bld
, binname
, source
,
332 use_global_deps
=True,
345 '''define a Samba binary'''
348 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
351 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
354 features
= 'cc cprogram symlink_bin install_bin'
356 features
+= ' pyembed'
358 obj_target
= binname
+ '.objlist'
360 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
362 source
= bld
.SUBDIR(subdir
, source
)
363 source
= unique_list(TO_LIST(source
))
365 if group
== 'binaries':
366 subsystem_group
= 'main'
368 subsystem_group
= group
370 # only specify PIE flags for binaries
372 pie_ldflags
= TO_LIST(ldflags
)
373 if bld
.env
['ENABLE_PIE'] is True:
374 pie_cflags
+= ' -fPIE'
375 pie_ldflags
.extend(TO_LIST('-pie'))
376 if bld
.env
['ENABLE_RELRO'] is True:
377 pie_ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
379 # first create a target for building the object files for this binary
380 # by separating in this way, we avoid recompiling the C files
381 # separately for the install binary and the build binary
382 bld
.SAMBA_SUBSYSTEM(obj_target
,
387 group
= subsystem_group
,
388 autoproto
= autoproto
,
389 subsystem_name
= subsystem_name
,
390 local_include
= local_include
,
391 global_include
= global_include
,
392 use_hostcc
= use_hostcc
,
394 use_global_deps
= use_global_deps
)
396 bld
.SET_BUILD_GROUP(group
)
398 # the binary itself will depend on that object target
400 deps
.append(obj_target
)
407 samba_includes
= includes
,
408 local_include
= local_include
,
409 global_include
= global_include
,
410 samba_modules
= modules
,
412 samba_subsystem
= subsystem_name
,
414 samba_inst_path
= install_path
,
415 samba_install
= install
,
416 samba_ldflags
= pie_ldflags
419 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
420 bld
.MANPAGES(manpages
, install
)
422 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
425 #################################################################
426 def SAMBA_MODULE(bld
, modname
, source
,
431 module_init_name
='samba_init_module',
433 autoproto_extra_source
='',
435 internal_module
=True,
443 allow_undefined_symbols
=False,
446 '''define a Samba module.'''
448 bld
.ASSERT(subsystem
, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname
)
450 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
452 source
= bld
.SUBDIR(subdir
, source
)
454 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
455 # Do not create modules for disabled subsystems
456 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
458 bld
.SAMBA_SUBSYSTEM(modname
, source
,
462 autoproto_extra_source
=autoproto_extra_source
,
464 local_include
=local_include
,
465 global_include
=global_include
,
466 allow_warnings
=allow_warnings
,
469 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
473 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
476 # Do not create modules for disabled subsystems
477 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
481 deps
+= ' ' + subsystem
482 while realname
.startswith("lib"+subsystem
+"_"):
483 realname
= realname
[len("lib"+subsystem
+"_"):]
484 while realname
.startswith(subsystem
+"_"):
485 realname
= realname
[len(subsystem
+"_"):]
487 build_name
= "%s_module_%s" % (subsystem
, realname
)
489 realname
= bld
.make_libname(realname
)
490 while realname
.startswith("lib"):
491 realname
= realname
[len("lib"):]
493 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
496 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
498 bld
.SAMBA_LIBRARY(modname
,
504 autoproto
= autoproto
,
505 local_include
=local_include
,
506 global_include
=global_include
,
508 bundled_name
=build_name
,
509 link_name
=build_link_name
,
510 install_path
="${MODULESDIR}/%s" % subsystem
,
513 allow_undefined_symbols
=allow_undefined_symbols
,
514 allow_warnings
=allow_warnings
518 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
521 #################################################################
522 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
527 public_headers_install
=True,
532 init_function_sentinel
=None,
534 autoproto_extra_source
='',
537 local_include_first
=True,
542 use_global_deps
=True,
546 allow_warnings
=False,
549 '''define a Samba subsystem'''
552 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
555 # remember empty subsystems, so we can strip the dependencies
556 if ((source
== '') or (source
== [])):
557 if deps
== '' and public_deps
== '':
558 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
560 empty_c
= modname
+ '.empty.c'
561 bld
.SAMBA_GENERATOR('%s_empty_c' % modname
,
562 rule
=generate_empty_file
,
566 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
569 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
571 source
= bld
.SUBDIR(subdir
, source
)
572 source
= unique_list(TO_LIST(source
))
574 deps
+= ' ' + public_deps
576 bld
.SET_BUILD_GROUP(group
)
582 features
+= ' pyembed'
588 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
,
589 allow_warnings
=allow_warnings
,
590 hide_symbols
=hide_symbols
),
591 depends_on
= depends_on
,
592 samba_deps
= TO_LIST(deps
),
593 samba_includes
= includes
,
594 local_include
= local_include
,
595 local_include_first
= local_include_first
,
596 global_include
= global_include
,
597 samba_subsystem
= subsystem_name
,
598 samba_use_hostcc
= use_hostcc
,
599 samba_use_global_deps
= use_global_deps
,
602 if cflags_end
is not None:
603 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
605 if autoproto
is not None:
606 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
607 if public_headers
is not None:
608 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
609 public_headers_install
=public_headers_install
)
613 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
616 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
617 group
='generators', enabled
=True,
619 public_headers_install
=True,
624 '''A generic source generator target'''
626 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
632 dep_vars
.append('ruledeps')
633 dep_vars
.append('SAMBA_GENERATOR_VARS')
635 bld
.SET_BUILD_GROUP(group
)
638 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
640 shell
=isinstance(rule
, str),
644 samba_type
='GENERATOR',
650 t
.env
.SAMBA_GENERATOR_VARS
= vars
655 if public_headers
is not None:
656 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
657 public_headers_install
=public_headers_install
)
659 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
664 def SETUP_BUILD_GROUPS(bld
):
665 '''setup build groups used to ensure that the different build
666 phases happen consecutively'''
667 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
668 bld
.env
['USING_BUILD_GROUPS'] = True
669 bld
.add_group('setup')
670 bld
.add_group('build_compiler_source')
671 bld
.add_group('vscripts')
672 bld
.add_group('base_libraries')
673 bld
.add_group('generators')
674 bld
.add_group('compiler_prototypes')
675 bld
.add_group('compiler_libraries')
676 bld
.add_group('build_compilers')
677 bld
.add_group('build_source')
678 bld
.add_group('prototypes')
679 bld
.add_group('headers')
680 bld
.add_group('main')
681 bld
.add_group('symbolcheck')
682 bld
.add_group('syslibcheck')
683 bld
.add_group('final')
684 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
687 def SET_BUILD_GROUP(bld
, group
):
688 '''set the current build group'''
689 if not 'USING_BUILD_GROUPS' in bld
.env
:
692 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
697 def ENABLE_TIMESTAMP_DEPENDENCIES(conf
):
698 """use timestamps instead of file contents for deps
699 this currently doesn't work"""
700 def h_file(filename
):
702 st
= os
.stat(filename
)
703 if stat
.S_ISDIR(st
[stat
.ST_MODE
]): raise IOError('not a file')
705 m
.update(str(st
.st_mtime
))
706 m
.update(str(st
.st_size
))
709 Utils
.h_file
= h_file
712 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
713 '''used to copy scripts from the source tree into the build directory
714 for use by selftest'''
716 source
= bld
.path
.ant_glob(pattern
)
718 bld
.SET_BUILD_GROUP('build_source')
719 for s
in TO_LIST(source
):
721 if installname
is not None:
723 target
= os
.path
.join(installdir
, iname
)
724 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
726 link_src
= os
.path
.normpath(os
.path
.join(bld
.curdir
, s
))
727 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
728 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
730 if os
.path
.exists(link_dst
):
732 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
733 os
.symlink(link_src
, link_dst
)
734 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
737 def copy_and_fix_python_path(task
):
738 pattern
='sys.path.insert(0, "bin/python")'
739 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
741 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
742 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
744 replacement
="""sys.path.insert(0, "%s")
745 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
747 if task
.env
["PYTHON"][0] == "/":
748 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"]
750 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"]
752 installed_location
=task
.outputs
[0].bldpath(task
.env
)
753 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
754 installed_file
= open(installed_location
, 'w')
756 for line
in source_file
:
758 if (lineno
== 0 and task
.env
["PYTHON_SPECIFIED"] is True and
760 newline
= replacement_shebang
761 elif pattern
in line
:
762 newline
= line
.replace(pattern
, replacement
)
763 installed_file
.write(newline
)
765 installed_file
.close()
766 os
.chmod(installed_location
, 0755)
769 def copy_and_fix_perl_path(task
):
770 pattern
='use lib "$RealBin/lib";'
773 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
774 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
776 if task
.env
["PERL"][0] == "/":
777 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
779 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
781 installed_location
=task
.outputs
[0].bldpath(task
.env
)
782 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
783 installed_file
= open(installed_location
, 'w')
785 for line
in source_file
:
787 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
788 newline
= replacement_shebang
789 elif pattern
in line
:
790 newline
= line
.replace(pattern
, replacement
)
791 installed_file
.write(newline
)
793 installed_file
.close()
794 os
.chmod(installed_location
, 0755)
798 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
799 python_fixup
=False, perl_fixup
=False,
800 destname
=None, base_name
=None):
802 destdir
= bld
.EXPAND_VARIABLES(destdir
)
806 destname
= os
.path
.basename(destname
)
807 dest
= os
.path
.join(destdir
, destname
)
809 # fix the path python will use to find Samba modules
810 inst_file
= file + '.inst'
811 bld
.SAMBA_GENERATOR('python_%s' % destname
,
812 rule
=copy_and_fix_python_path
,
813 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
818 # fix the path perl will use to find Samba modules
819 inst_file
= file + '.inst'
820 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
821 rule
=copy_and_fix_perl_path
,
822 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
827 file = os
.path
.join(base_name
, file)
828 bld
.install_as(dest
, file, chmod
=chmod
)
831 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
832 python_fixup
=False, perl_fixup
=False,
833 destname
=None, base_name
=None):
834 '''install a set of files'''
835 for f
in TO_LIST(files
):
836 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
837 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
838 destname
=destname
, base_name
=base_name
)
839 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
842 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
843 python_fixup
=False, exclude
=None, trim_path
=None):
844 '''install a set of files matching a wildcard pattern'''
845 files
=TO_LIST(bld
.path
.ant_glob(pattern
))
849 files2
.append(os_path_relpath(f
, trim_path
))
854 if fnmatch
.fnmatch(f
, exclude
):
856 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
857 python_fixup
=python_fixup
, base_name
=trim_path
)
858 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
861 def INSTALL_DIRS(bld
, destdir
, dirs
):
862 '''install a set of directories'''
863 destdir
= bld
.EXPAND_VARIABLES(destdir
)
864 dirs
= bld
.EXPAND_VARIABLES(dirs
)
865 for d
in TO_LIST(dirs
):
866 bld
.install_dir(os
.path
.join(destdir
, d
))
867 Build
.BuildContext
.INSTALL_DIRS
= INSTALL_DIRS
870 def MANPAGES(bld
, manpages
, install
):
871 '''build and install manual pages'''
872 bld
.env
.MAN_XSL
= 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
873 for m
in manpages
.split():
875 bld
.SAMBA_GENERATOR(m
,
879 rule
='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
882 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
883 Build
.BuildContext
.MANPAGES
= MANPAGES
885 def SAMBAMANPAGES(bld
, manpages
, extra_source
=None):
886 '''build and install manual pages'''
887 bld
.env
.SAMBA_EXPAND_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
888 bld
.env
.SAMBA_MAN_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/man.xsl'
889 bld
.env
.SAMBA_CATALOG
= bld
.srcnode
.abspath() + '/bin/default/docs-xml/build/catalog.xml'
890 bld
.env
.SAMBA_CATALOGS
= 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld
.env
.SAMBA_CATALOG
892 for m
in manpages
.split():
894 if extra_source
is not None:
895 source
= [source
, extra_source
]
896 bld
.SAMBA_GENERATOR(m
,
900 dep_vars
=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
901 rule
='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
902 export XML_CATALOG_FILES
903 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
904 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
906 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
907 Build
.BuildContext
.SAMBAMANPAGES
= SAMBAMANPAGES
909 #############################################################
910 # give a nicer display when building different types of files
911 def progress_display(self
, msg
, fname
):
912 col1
= Logs
.colors(self
.color
)
913 col2
= Logs
.colors
.NORMAL
914 total
= self
.position
[1]
916 fs
= '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n
, n
, msg
)
917 return fs
% (self
.position
[0], self
.position
[1], col1
, fname
, col2
)
919 def link_display(self
):
920 if Options
.options
.progress_bar
!= 0:
921 return Task
.Task
.old_display(self
)
922 fname
= self
.outputs
[0].bldpath(self
.env
)
923 return progress_display(self
, 'Linking', fname
)
924 Task
.TaskBase
.classes
['cc_link'].display
= link_display
926 def samba_display(self
):
927 if Options
.options
.progress_bar
!= 0:
928 return Task
.Task
.old_display(self
)
930 targets
= LOCAL_CACHE(self
, 'TARGET_TYPE')
931 if self
.name
in targets
:
932 target_type
= targets
[self
.name
]
933 type_map
= { 'GENERATOR' : 'Generating',
934 'PROTOTYPE' : 'Generating'
936 if target_type
in type_map
:
937 return progress_display(self
, type_map
[target_type
], self
.name
)
939 if len(self
.inputs
) == 0:
940 return Task
.Task
.old_display(self
)
942 fname
= self
.inputs
[0].bldpath(self
.env
)
943 if fname
[0:3] == '../':
945 ext_loc
= fname
.rfind('.')
947 return Task
.Task
.old_display(self
)
948 ext
= fname
[ext_loc
:]
950 ext_map
= { '.idl' : 'Compiling IDL',
951 '.et' : 'Compiling ERRTABLE',
952 '.asn1': 'Compiling ASN1',
955 return progress_display(self
, ext_map
[ext
], fname
)
956 return Task
.Task
.old_display(self
)
958 Task
.TaskBase
.classes
['Task'].old_display
= Task
.TaskBase
.classes
['Task'].display
959 Task
.TaskBase
.classes
['Task'].display
= samba_display
964 def apply_bundle_remove_dynamiclib_patch(self
):
965 if self
.env
['MACBUNDLE'] or getattr(self
,'mac_bundle',False):
966 if not getattr(self
,'vnum',None):
968 self
.env
['LINKFLAGS'].remove('-dynamiclib')
969 self
.env
['LINKFLAGS'].remove('-single_module')