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 *
25 import samba_conftests
39 # some systems have broken threading in python
40 if os
.environ
.get('WAF_NOTHREADS') == '1':
45 os
.environ
['PYTHONUNBUFFERED'] = '1'
48 if Constants
.HEXVERSION
< 0x105019:
50 Please use the version of waf that comes with Samba, not
51 a system installed version. See http://wiki.samba.org/index.php/Waf
54 Alternatively, please run ./configure and make as usual. That will
55 call the right version of waf.''')
60 def SAMBA_BUILD_ENV(conf
):
61 '''create the samba build environment'''
62 conf
.env
.BUILD_DIRECTORY
= conf
.blddir
63 mkdir_p(os
.path
.join(conf
.blddir
, LIB_PATH
))
64 mkdir_p(os
.path
.join(conf
.blddir
, LIB_PATH
, "private"))
65 mkdir_p(os
.path
.join(conf
.blddir
, "modules"))
66 mkdir_p(os
.path
.join(conf
.blddir
, 'python/samba/dcerpc'))
67 # this allows all of the bin/shared and bin/python targets
68 # to be expressed in terms of build directory paths
69 mkdir_p(os
.path
.join(conf
.blddir
, 'default'))
70 for (source
, target
) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
71 link_target
= os
.path
.join(conf
.blddir
, 'default/' + target
)
72 if not os
.path
.lexists(link_target
):
73 os
.symlink('../' + source
, link_target
)
75 # get perl to put the blib files in the build directory
76 blib_bld
= os
.path
.join(conf
.blddir
, 'default/pidl/blib')
77 blib_src
= os
.path
.join(conf
.srcdir
, 'pidl/blib')
78 mkdir_p(blib_bld
+ '/man1')
79 mkdir_p(blib_bld
+ '/man3')
80 if os
.path
.islink(blib_src
):
82 elif os
.path
.exists(blib_src
):
83 shutil
.rmtree(blib_src
)
86 def ADD_INIT_FUNCTION(bld
, subsystem
, target
, init_function
):
87 '''add an init_function to the list for a subsystem'''
88 if init_function
is None:
90 bld
.ASSERT(subsystem
is not None, "You must specify a subsystem for init_function '%s'" % init_function
)
91 cache
= LOCAL_CACHE(bld
, 'INIT_FUNCTIONS')
92 if not subsystem
in cache
:
94 cache
[subsystem
].append( { 'TARGET':target
, 'INIT_FUNCTION':init_function
} )
95 Build
.BuildContext
.ADD_INIT_FUNCTION
= ADD_INIT_FUNCTION
98 def generate_empty_file(task
):
99 task
.outputs
[0].write('')
102 #################################################################
103 def SAMBA_LIBRARY(bld
, libname
, source
,
108 public_headers_install
=True,
109 private_headers
=None,
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 pyembed
and bld
.env
['IS_EXTRA_PYTHON']:
147 public_headers
= pc_files
= None
149 if private_library
and public_headers
:
150 raise Utils
.WafError("private library '%s' must not have public header files" %
153 if LIB_MUST_BE_PRIVATE(bld
, libname
):
154 private_library
= True
157 SET_TARGET_TYPE(bld
, libname
, 'DISABLED')
160 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
162 source
= bld
.SUBDIR(subdir
, source
)
164 # remember empty libraries, so we can strip the dependencies
165 if ((source
== '') or (source
== [])):
166 if deps
== '' and public_deps
== '':
167 SET_TARGET_TYPE(bld
, libname
, 'EMPTY')
169 empty_c
= libname
+ '.empty.c'
170 bld
.SAMBA_GENERATOR('%s_empty_c' % libname
,
171 rule
=generate_empty_file
,
175 if BUILTIN_LIBRARY(bld
, libname
):
178 obj_target
= libname
+ '.objlist'
180 if group
== 'libraries':
181 subsystem_group
= 'main'
183 subsystem_group
= group
185 # first create a target for building the object files for this library
186 # by separating in this way, we avoid recompiling the C files
187 # separately for the install library and the build library
188 bld
.SAMBA_SUBSYSTEM(obj_target
,
191 public_deps
= public_deps
,
193 public_headers
= public_headers
,
194 public_headers_install
= public_headers_install
,
195 private_headers
= private_headers
,
196 header_path
= header_path
,
198 group
= subsystem_group
,
199 autoproto
= autoproto
,
200 autoproto_extra_source
=autoproto_extra_source
,
201 depends_on
= depends_on
,
202 hide_symbols
= hide_symbols
,
203 allow_warnings
= allow_warnings
,
206 local_include
= local_include
,
207 global_include
= global_include
)
209 if BUILTIN_LIBRARY(bld
, libname
):
212 if not SET_TARGET_TYPE(bld
, libname
, target_type
):
215 # the library itself will depend on that object target
216 deps
+= ' ' + public_deps
218 deps
.append(obj_target
)
220 realname
= bld
.map_shlib_extension(realname
, python
=(target_type
=='PYTHON'))
221 link_name
= bld
.map_shlib_extension(link_name
, python
=(target_type
=='PYTHON'))
223 # we don't want any public libraries without version numbers
224 if (not private_library
and target_type
!= 'PYTHON' and not realname
):
225 if vnum
is None and soname
is None:
226 raise Utils
.WafError("public library '%s' must have a vnum" %
228 if pc_files
is None and not bld
.env
['IS_EXTRA_PYTHON']:
229 raise Utils
.WafError("public library '%s' must have pkg-config file" %
231 if public_headers
is None and not bld
.env
['IS_EXTRA_PYTHON']:
232 raise Utils
.WafError("public library '%s' must have header files" %
235 if bundled_name
is not None:
237 elif target_type
== 'PYTHON' or realname
or not private_library
:
239 bundled_name
= libname
241 bundled_name
= libname
.replace('_', '-')
243 assert (private_library
== True and realname
is None)
244 if abi_directory
or vnum
or soname
:
245 bundled_extension
=True
246 bundled_name
= PRIVATE_NAME(bld
, libname
.replace('_', '-'),
247 bundled_extension
, private_library
)
249 ldflags
= TO_LIST(ldflags
)
250 if bld
.env
['ENABLE_RELRO'] is True:
251 ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
253 features
= 'c cshlib symlink_lib install_lib'
257 features
+= ' pyembed'
260 features
+= ' abi_check'
262 if pyembed
and bld
.env
['PYTHON_SO_ABI_FLAG']:
263 # For ABI checking, we don't care about the exact Python version.
264 # Replace the Python ABI tag (e.g. ".cpython-35m") by a generic ".py3"
265 abi_flag
= bld
.env
['PYTHON_SO_ABI_FLAG']
266 replacement
= '.py%s' % bld
.env
['PYTHON_VERSION'].split('.')[0]
267 version_libname
= libname
.replace(abi_flag
, replacement
)
269 version_libname
= libname
272 if bld
.env
.HAVE_LD_VERSION_SCRIPT
:
274 version
= "%s_%s" % (Utils
.g_module
.APPNAME
, Utils
.g_module
.VERSION
)
276 version
= "%s_%s" % (libname
, vnum
)
280 vscript
= "%s.vscript" % libname
281 bld
.ABI_VSCRIPT(version_libname
, abi_directory
, version
, vscript
,
283 fullname
= apply_pattern(bundled_name
, bld
.env
.shlib_PATTERN
)
284 fullpath
= bld
.path
.find_or_declare(fullname
)
285 vscriptpath
= bld
.path
.find_or_declare(vscript
)
287 raise Utils
.WafError("unable to find fullpath for %s" % fullname
)
289 raise Utils
.WafError("unable to find vscript path for %s" % vscript
)
290 bld
.add_manual_dependency(fullpath
, vscriptpath
)
292 # also make the .inst file depend on the vscript
293 instname
= apply_pattern(bundled_name
+ '.inst', bld
.env
.shlib_PATTERN
)
294 bld
.add_manual_dependency(bld
.path
.find_or_declare(instname
), bld
.path
.find_or_declare(vscript
))
295 vscript
= os
.path
.join(bld
.path
.abspath(bld
.env
), vscript
)
297 bld
.SET_BUILD_GROUP(group
)
301 target
= bundled_name
,
302 depends_on
= depends_on
,
303 samba_ldflags
= ldflags
,
305 samba_includes
= includes
,
306 version_script
= vscript
,
307 version_libname
= version_libname
,
308 local_include
= local_include
,
309 global_include
= global_include
,
313 samba_inst_path
= install_path
,
315 samba_realname
= realname
,
316 samba_install
= install
,
317 abi_directory
= "%s/%s" % (bld
.path
.abspath(), abi_directory
),
318 abi_match
= abi_match
,
319 private_library
= private_library
,
320 grouping_library
=grouping_library
,
321 allow_undefined_symbols
=allow_undefined_symbols
324 if realname
and not link_name
:
325 link_name
= 'shared/%s' % realname
328 t
.link_name
= link_name
330 if pc_files
is not None and not private_library
:
331 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
)
333 if (manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and
334 bld
.env
['XSLTPROC_MANPAGES']):
335 bld
.MANPAGES(manpages
, install
)
338 Build
.BuildContext
.SAMBA_LIBRARY
= SAMBA_LIBRARY
341 #################################################################
342 def SAMBA_BINARY(bld
, binname
, source
,
346 private_headers
=None,
353 use_global_deps
=True,
366 '''define a Samba binary'''
369 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
372 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
375 features
= 'c cprogram symlink_bin install_bin'
377 features
+= ' pyembed'
379 obj_target
= binname
+ '.objlist'
381 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
383 source
= bld
.SUBDIR(subdir
, source
)
384 source
= unique_list(TO_LIST(source
))
386 if group
== 'binaries':
387 subsystem_group
= 'main'
389 subsystem_group
= group
391 # only specify PIE flags for binaries
393 pie_ldflags
= TO_LIST(ldflags
)
394 if bld
.env
['ENABLE_PIE'] is True:
395 pie_cflags
+= ' -fPIE'
396 pie_ldflags
.extend(TO_LIST('-pie'))
397 if bld
.env
['ENABLE_RELRO'] is True:
398 pie_ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
400 # first create a target for building the object files for this binary
401 # by separating in this way, we avoid recompiling the C files
402 # separately for the install binary and the build binary
403 bld
.SAMBA_SUBSYSTEM(obj_target
,
408 group
= subsystem_group
,
409 autoproto
= autoproto
,
410 subsystem_name
= subsystem_name
,
411 local_include
= local_include
,
412 global_include
= global_include
,
413 use_hostcc
= use_hostcc
,
415 use_global_deps
= use_global_deps
)
417 bld
.SET_BUILD_GROUP(group
)
419 # the binary itself will depend on that object target
421 deps
.append(obj_target
)
428 samba_includes
= includes
,
429 local_include
= local_include
,
430 global_include
= global_include
,
431 samba_modules
= modules
,
433 samba_subsystem
= subsystem_name
,
435 samba_inst_path
= install_path
,
436 samba_install
= install
,
437 samba_ldflags
= pie_ldflags
440 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
441 bld
.MANPAGES(manpages
, install
)
443 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
446 #################################################################
447 def SAMBA_MODULE(bld
, modname
, source
,
452 module_init_name
='samba_init_module',
454 autoproto_extra_source
='',
456 internal_module
=True,
464 allow_undefined_symbols
=False,
467 '''define a Samba module.'''
469 bld
.ASSERT(subsystem
, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname
)
471 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
473 source
= bld
.SUBDIR(subdir
, source
)
475 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
476 # Do not create modules for disabled subsystems
477 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
479 bld
.SAMBA_SUBSYSTEM(modname
, source
,
483 autoproto_extra_source
=autoproto_extra_source
,
485 local_include
=local_include
,
486 global_include
=global_include
,
487 allow_warnings
=allow_warnings
,
490 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
494 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
497 # Do not create modules for disabled subsystems
498 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
502 deps
+= ' ' + subsystem
503 while realname
.startswith("lib"+subsystem
+"_"):
504 realname
= realname
[len("lib"+subsystem
+"_"):]
505 while realname
.startswith(subsystem
+"_"):
506 realname
= realname
[len(subsystem
+"_"):]
508 build_name
= "%s_module_%s" % (subsystem
, realname
)
510 realname
= bld
.make_libname(realname
)
511 while realname
.startswith("lib"):
512 realname
= realname
[len("lib"):]
514 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
517 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
519 bld
.SAMBA_LIBRARY(modname
,
525 autoproto
= autoproto
,
526 local_include
=local_include
,
527 global_include
=global_include
,
529 bundled_name
=build_name
,
530 link_name
=build_link_name
,
531 install_path
="${MODULESDIR}/%s" % subsystem
,
534 allow_undefined_symbols
=allow_undefined_symbols
,
535 allow_warnings
=allow_warnings
539 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
542 #################################################################
543 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
548 public_headers_install
=True,
549 private_headers
=None,
554 init_function_sentinel
=None,
556 autoproto_extra_source
='',
559 local_include_first
=True,
564 use_global_deps
=True,
568 allow_warnings
=False,
571 '''define a Samba subsystem'''
574 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
577 # remember empty subsystems, so we can strip the dependencies
578 if ((source
== '') or (source
== [])):
579 if deps
== '' and public_deps
== '':
580 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
582 empty_c
= modname
+ '.empty.c'
583 bld
.SAMBA_GENERATOR('%s_empty_c' % modname
,
584 rule
=generate_empty_file
,
588 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
591 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
593 source
= bld
.SUBDIR(subdir
, source
)
594 source
= unique_list(TO_LIST(source
))
596 deps
+= ' ' + public_deps
598 bld
.SET_BUILD_GROUP(group
)
604 features
+= ' pyembed'
610 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
,
611 allow_warnings
=allow_warnings
,
612 hide_symbols
=hide_symbols
),
613 depends_on
= depends_on
,
614 samba_deps
= TO_LIST(deps
),
615 samba_includes
= includes
,
616 local_include
= local_include
,
617 local_include_first
= local_include_first
,
618 global_include
= global_include
,
619 samba_subsystem
= subsystem_name
,
620 samba_use_hostcc
= use_hostcc
,
621 samba_use_global_deps
= use_global_deps
,
624 if cflags_end
is not None:
625 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
627 if autoproto
is not None:
628 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
629 if public_headers
is not None:
630 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
631 public_headers_install
=public_headers_install
)
635 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
638 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
639 group
='generators', enabled
=True,
641 public_headers_install
=True,
642 private_headers
=None,
647 '''A generic source generator target'''
649 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
655 dep_vars
.append('ruledeps')
656 dep_vars
.append('SAMBA_GENERATOR_VARS')
658 bld
.SET_BUILD_GROUP(group
)
661 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
663 shell
=isinstance(rule
, str),
667 samba_type
='GENERATOR',
673 t
.env
.SAMBA_GENERATOR_VARS
= vars
678 if public_headers
is not None:
679 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
680 public_headers_install
=public_headers_install
)
682 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
687 def SETUP_BUILD_GROUPS(bld
):
688 '''setup build groups used to ensure that the different build
689 phases happen consecutively'''
690 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
691 bld
.env
['USING_BUILD_GROUPS'] = True
692 bld
.add_group('setup')
693 bld
.add_group('build_compiler_source')
694 bld
.add_group('vscripts')
695 bld
.add_group('base_libraries')
696 bld
.add_group('generators')
697 bld
.add_group('compiler_prototypes')
698 bld
.add_group('compiler_libraries')
699 bld
.add_group('build_compilers')
700 bld
.add_group('build_source')
701 bld
.add_group('prototypes')
702 bld
.add_group('headers')
703 bld
.add_group('main')
704 bld
.add_group('symbolcheck')
705 bld
.add_group('syslibcheck')
706 bld
.add_group('final')
707 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
710 def SET_BUILD_GROUP(bld
, group
):
711 '''set the current build group'''
712 if not 'USING_BUILD_GROUPS' in bld
.env
:
715 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
720 def ENABLE_TIMESTAMP_DEPENDENCIES(conf
):
721 """use timestamps instead of file contents for deps
722 this currently doesn't work"""
723 def h_file(filename
):
725 st
= os
.stat(filename
)
726 if stat
.S_ISDIR(st
[stat
.ST_MODE
]): raise IOError('not a file')
728 m
.update(str(st
.st_mtime
))
729 m
.update(str(st
.st_size
))
732 Utils
.h_file
= h_file
735 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
736 '''used to copy scripts from the source tree into the build directory
737 for use by selftest'''
739 source
= bld
.path
.ant_glob(pattern
, flat
=True)
741 bld
.SET_BUILD_GROUP('build_source')
742 for s
in TO_LIST(source
):
744 if installname
is not None:
746 target
= os
.path
.join(installdir
, iname
)
747 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
749 link_src
= os
.path
.normpath(os
.path
.join(bld
.curdir
, s
))
750 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
751 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
753 if os
.path
.exists(link_dst
):
755 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
756 os
.symlink(link_src
, link_dst
)
757 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
760 def copy_and_fix_python_path(task
):
761 pattern
='sys.path.insert(0, "bin/python")'
762 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
764 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
765 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
767 replacement
="""sys.path.insert(0, "%s")
768 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
770 if task
.env
["PYTHON"][0] == "/":
771 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"]
773 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"]
775 installed_location
=task
.outputs
[0].bldpath(task
.env
)
776 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
777 installed_file
= open(installed_location
, 'w')
779 for line
in source_file
:
781 if (lineno
== 0 and task
.env
["PYTHON_SPECIFIED"] is True and
783 newline
= replacement_shebang
784 elif pattern
in line
:
785 newline
= line
.replace(pattern
, replacement
)
786 installed_file
.write(newline
)
788 installed_file
.close()
789 os
.chmod(installed_location
, 0755)
792 def copy_and_fix_perl_path(task
):
793 pattern
='use lib "$RealBin/lib";'
796 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
797 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
799 if task
.env
["PERL"][0] == "/":
800 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
802 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
804 installed_location
=task
.outputs
[0].bldpath(task
.env
)
805 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
806 installed_file
= open(installed_location
, 'w')
808 for line
in source_file
:
810 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
811 newline
= replacement_shebang
812 elif pattern
in line
:
813 newline
= line
.replace(pattern
, replacement
)
814 installed_file
.write(newline
)
816 installed_file
.close()
817 os
.chmod(installed_location
, 0755)
821 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
822 python_fixup
=False, perl_fixup
=False,
823 destname
=None, base_name
=None):
825 destdir
= bld
.EXPAND_VARIABLES(destdir
)
829 destname
= os
.path
.basename(destname
)
830 dest
= os
.path
.join(destdir
, destname
)
832 # fix the path python will use to find Samba modules
833 inst_file
= file + '.inst'
834 bld
.SAMBA_GENERATOR('python_%s' % destname
,
835 rule
=copy_and_fix_python_path
,
836 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
841 # fix the path perl will use to find Samba modules
842 inst_file
= file + '.inst'
843 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
844 rule
=copy_and_fix_perl_path
,
845 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
850 file = os
.path
.join(base_name
, file)
851 bld
.install_as(dest
, file, chmod
=chmod
)
854 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
855 python_fixup
=False, perl_fixup
=False,
856 destname
=None, base_name
=None):
857 '''install a set of files'''
858 for f
in TO_LIST(files
):
859 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
860 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
861 destname
=destname
, base_name
=base_name
)
862 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
865 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
866 python_fixup
=False, exclude
=None, trim_path
=None):
867 '''install a set of files matching a wildcard pattern'''
868 files
=TO_LIST(bld
.path
.ant_glob(pattern
, flat
=True))
872 files2
.append(os_path_relpath(f
, trim_path
))
877 if fnmatch
.fnmatch(f
, exclude
):
879 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
880 python_fixup
=python_fixup
, base_name
=trim_path
)
881 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
884 def INSTALL_DIRS(bld
, destdir
, dirs
):
885 '''install a set of directories'''
886 destdir
= bld
.EXPAND_VARIABLES(destdir
)
887 dirs
= bld
.EXPAND_VARIABLES(dirs
)
888 for d
in TO_LIST(dirs
):
889 bld
.install_dir(os
.path
.join(destdir
, d
))
890 Build
.BuildContext
.INSTALL_DIRS
= INSTALL_DIRS
893 def MANPAGES(bld
, manpages
, install
):
894 '''build and install manual pages'''
895 bld
.env
.MAN_XSL
= 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
896 for m
in manpages
.split():
898 bld
.SAMBA_GENERATOR(m
,
902 rule
='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
905 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
906 Build
.BuildContext
.MANPAGES
= MANPAGES
908 def SAMBAMANPAGES(bld
, manpages
, extra_source
=None):
909 '''build and install manual pages'''
910 bld
.env
.SAMBA_EXPAND_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
911 bld
.env
.SAMBA_MAN_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/man.xsl'
912 bld
.env
.SAMBA_CATALOG
= bld
.srcnode
.abspath() + '/bin/default/docs-xml/build/catalog.xml'
913 bld
.env
.SAMBA_CATALOGS
= 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld
.env
.SAMBA_CATALOG
915 for m
in manpages
.split():
917 if extra_source
is not None:
918 source
= [source
, extra_source
]
919 bld
.SAMBA_GENERATOR(m
,
923 dep_vars
=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
924 rule
='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
925 export XML_CATALOG_FILES
926 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
927 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
929 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
930 Build
.BuildContext
.SAMBAMANPAGES
= SAMBAMANPAGES
932 #############################################################
933 # give a nicer display when building different types of files
934 def progress_display(self
, msg
, fname
):
935 col1
= Logs
.colors(self
.color
)
936 col2
= Logs
.colors
.NORMAL
937 total
= self
.position
[1]
939 fs
= '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n
, n
, msg
)
940 return fs
% (self
.position
[0], self
.position
[1], col1
, fname
, col2
)
942 def link_display(self
):
943 if Options
.options
.progress_bar
!= 0:
944 return Task
.Task
.old_display(self
)
945 fname
= self
.outputs
[0].bldpath(self
.env
)
946 return progress_display(self
, 'Linking', fname
)
947 Task
.TaskBase
.classes
['cc_link'].display
= link_display
949 def samba_display(self
):
950 if Options
.options
.progress_bar
!= 0:
951 return Task
.Task
.old_display(self
)
953 targets
= LOCAL_CACHE(self
, 'TARGET_TYPE')
954 if self
.name
in targets
:
955 target_type
= targets
[self
.name
]
956 type_map
= { 'GENERATOR' : 'Generating',
957 'PROTOTYPE' : 'Generating'
959 if target_type
in type_map
:
960 return progress_display(self
, type_map
[target_type
], self
.name
)
962 if len(self
.inputs
) == 0:
963 return Task
.Task
.old_display(self
)
965 fname
= self
.inputs
[0].bldpath(self
.env
)
966 if fname
[0:3] == '../':
968 ext_loc
= fname
.rfind('.')
970 return Task
.Task
.old_display(self
)
971 ext
= fname
[ext_loc
:]
973 ext_map
= { '.idl' : 'Compiling IDL',
974 '.et' : 'Compiling ERRTABLE',
975 '.asn1': 'Compiling ASN1',
978 return progress_display(self
, ext_map
[ext
], fname
)
979 return Task
.Task
.old_display(self
)
981 Task
.TaskBase
.classes
['Task'].old_display
= Task
.TaskBase
.classes
['Task'].display
982 Task
.TaskBase
.classes
['Task'].display
= samba_display
987 def apply_bundle_remove_dynamiclib_patch(self
):
988 if self
.env
['MACBUNDLE'] or getattr(self
,'mac_bundle',False):
989 if not getattr(self
,'vnum',None):
991 self
.env
['LINKFLAGS'].remove('-dynamiclib')
992 self
.env
['LINKFLAGS'].remove('-single_module')