docs: mention --update and --encrypt in smbget manpage.
[Samba.git] / buildtools / wafsamba / wafsamba.py
blobcaa6fb128d6dfb3ae4e49f9f6d58c389af3f116a
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
6 from Logs import debug
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_deps import *
20 from samba_bundled import *
21 import samba_install
22 import samba_conftests
23 import samba_abi
24 import samba_headers
25 import tru64cc
26 import irixcc
27 import hpuxcc
28 import generic_cc
29 import samba_dist
30 import samba_wildcard
31 import stale_files
32 import symbols
33 import pkgconfig
34 import configure_file
36 # some systems have broken threading in python
37 if os.environ.get('WAF_NOTHREADS') == '1':
38 import nothreads
40 LIB_PATH="shared"
42 os.environ['PYTHONUNBUFFERED'] = '1'
45 if Constants.HEXVERSION < 0x105019:
46 Logs.error('''
47 Please use the version of waf that comes with Samba, not
48 a system installed version. See http://wiki.samba.org/index.php/Waf
49 for details.
51 Alternatively, please run ./configure and make as usual. That will
52 call the right version of waf.''')
53 sys.exit(1)
56 @conf
57 def SAMBA_BUILD_ENV(conf):
58 '''create the samba build environment'''
59 conf.env.BUILD_DIRECTORY = conf.blddir
60 mkdir_p(os.path.join(conf.blddir, LIB_PATH))
61 mkdir_p(os.path.join(conf.blddir, LIB_PATH, "private"))
62 mkdir_p(os.path.join(conf.blddir, "modules"))
63 mkdir_p(os.path.join(conf.blddir, 'python/samba/dcerpc'))
64 # this allows all of the bin/shared and bin/python targets
65 # to be expressed in terms of build directory paths
66 mkdir_p(os.path.join(conf.blddir, 'default'))
67 for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
68 link_target = os.path.join(conf.blddir, 'default/' + target)
69 if not os.path.lexists(link_target):
70 os.symlink('../' + source, link_target)
72 # get perl to put the blib files in the build directory
73 blib_bld = os.path.join(conf.blddir, 'default/pidl/blib')
74 blib_src = os.path.join(conf.srcdir, 'pidl/blib')
75 mkdir_p(blib_bld + '/man1')
76 mkdir_p(blib_bld + '/man3')
77 if os.path.islink(blib_src):
78 os.unlink(blib_src)
79 elif os.path.exists(blib_src):
80 shutil.rmtree(blib_src)
83 def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
84 '''add an init_function to the list for a subsystem'''
85 if init_function is None:
86 return
87 bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
88 cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
89 if not subsystem in cache:
90 cache[subsystem] = []
91 cache[subsystem].append( { 'TARGET':target, 'INIT_FUNCTION':init_function } )
92 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
96 #################################################################
97 def SAMBA_LIBRARY(bld, libname, source,
98 deps='',
99 public_deps='',
100 includes='',
101 public_headers=None,
102 public_headers_install=True,
103 header_path=None,
104 pc_files=None,
105 vnum=None,
106 soname=None,
107 cflags='',
108 ldflags='',
109 external_library=False,
110 realname=None,
111 autoproto=None,
112 autoproto_extra_source='',
113 group='main',
114 depends_on='',
115 local_include=True,
116 global_include=True,
117 vars=None,
118 subdir=None,
119 install_path=None,
120 install=True,
121 pyembed=False,
122 pyext=False,
123 target_type='LIBRARY',
124 bundled_extension=True,
125 link_name=None,
126 abi_directory=None,
127 abi_match=None,
128 hide_symbols=False,
129 manpages=None,
130 private_library=False,
131 grouping_library=False,
132 allow_undefined_symbols=False,
133 enabled=True):
134 '''define a Samba library'''
136 if LIB_MUST_BE_PRIVATE(bld, libname):
137 private_library=True
139 if not enabled:
140 SET_TARGET_TYPE(bld, libname, 'DISABLED')
141 return
143 source = bld.EXPAND_VARIABLES(source, vars=vars)
144 if subdir:
145 source = bld.SUBDIR(subdir, source)
147 # remember empty libraries, so we can strip the dependencies
148 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
149 SET_TARGET_TYPE(bld, libname, 'EMPTY')
150 return
152 if BUILTIN_LIBRARY(bld, libname):
153 obj_target = libname
154 else:
155 obj_target = libname + '.objlist'
157 if group == 'libraries':
158 subsystem_group = 'main'
159 else:
160 subsystem_group = group
162 # first create a target for building the object files for this library
163 # by separating in this way, we avoid recompiling the C files
164 # separately for the install library and the build library
165 bld.SAMBA_SUBSYSTEM(obj_target,
166 source = source,
167 deps = deps,
168 public_deps = public_deps,
169 includes = includes,
170 public_headers = public_headers,
171 public_headers_install = public_headers_install,
172 header_path = header_path,
173 cflags = cflags,
174 group = subsystem_group,
175 autoproto = autoproto,
176 autoproto_extra_source=autoproto_extra_source,
177 depends_on = depends_on,
178 hide_symbols = hide_symbols,
179 pyembed = pyembed,
180 pyext = pyext,
181 local_include = local_include,
182 global_include = global_include)
184 if BUILTIN_LIBRARY(bld, libname):
185 return
187 if not SET_TARGET_TYPE(bld, libname, target_type):
188 return
190 # the library itself will depend on that object target
191 deps += ' ' + public_deps
192 deps = TO_LIST(deps)
193 deps.append(obj_target)
195 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
196 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
198 # we don't want any public libraries without version numbers
199 if (not private_library and target_type != 'PYTHON' and not realname):
200 if vnum is None and soname is None:
201 raise Utils.WafError("public library '%s' must have a vnum" %
202 libname)
203 if pc_files is None:
204 raise Utils.WafError("public library '%s' must have pkg-config file" %
205 libname)
206 if public_headers is None:
207 raise Utils.WafError("public library '%s' must have header files" %
208 libname)
210 if target_type == 'PYTHON' or realname or not private_library:
211 bundled_name = libname.replace('_', '-')
212 else:
213 bundled_name = PRIVATE_NAME(bld, libname, bundled_extension,
214 private_library)
216 ldflags = TO_LIST(ldflags)
218 features = 'cc cshlib symlink_lib install_lib'
219 if pyext:
220 features += ' pyext'
221 if pyembed:
222 features += ' pyembed'
224 if abi_directory:
225 features += ' abi_check'
227 vscript = None
228 if bld.env.HAVE_LD_VERSION_SCRIPT:
229 if private_library:
230 version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
231 elif vnum:
232 version = "%s_%s" % (libname, vnum)
233 else:
234 version = None
235 if version:
236 vscript = "%s.vscript" % libname
237 bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
238 abi_match)
239 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
240 fullpath = bld.path.find_or_declare(fullname)
241 vscriptpath = bld.path.find_or_declare(vscript)
242 if not fullpath:
243 raise Utils.WafError("unable to find fullpath for %s" % fullname)
244 if not vscriptpath:
245 raise Utils.WafError("unable to find vscript path for %s" % vscript)
246 bld.add_manual_dependency(fullpath, vscriptpath)
247 if Options.is_install:
248 # also make the .inst file depend on the vscript
249 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
250 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
251 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
253 bld.SET_BUILD_GROUP(group)
254 t = bld(
255 features = features,
256 source = [],
257 target = bundled_name,
258 depends_on = depends_on,
259 samba_ldflags = ldflags,
260 samba_deps = deps,
261 samba_includes = includes,
262 version_script = vscript,
263 local_include = local_include,
264 global_include = global_include,
265 vnum = vnum,
266 soname = soname,
267 install_path = None,
268 samba_inst_path = install_path,
269 name = libname,
270 samba_realname = realname,
271 samba_install = install,
272 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
273 abi_match = abi_match,
274 private_library = private_library,
275 grouping_library=grouping_library,
276 allow_undefined_symbols=allow_undefined_symbols
279 if realname and not link_name:
280 link_name = 'shared/%s' % realname
282 if link_name:
283 t.link_name = link_name
285 if pc_files is not None and not private_library:
286 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
288 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
289 bld.env['XSLTPROC_MANPAGES']):
290 bld.MANPAGES(manpages, install)
293 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
296 #################################################################
297 def SAMBA_BINARY(bld, binname, source,
298 deps='',
299 includes='',
300 public_headers=None,
301 header_path=None,
302 modules=None,
303 ldflags=None,
304 cflags='',
305 autoproto=None,
306 use_hostcc=False,
307 use_global_deps=True,
308 compiler=None,
309 group='main',
310 manpages=None,
311 local_include=True,
312 global_include=True,
313 subsystem_name=None,
314 pyembed=False,
315 vars=None,
316 subdir=None,
317 install=True,
318 install_path=None,
319 enabled=True):
320 '''define a Samba binary'''
322 if not enabled:
323 SET_TARGET_TYPE(bld, binname, 'DISABLED')
324 return
326 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
327 return
329 features = 'cc cprogram symlink_bin install_bin'
330 if pyembed:
331 features += ' pyembed'
333 obj_target = binname + '.objlist'
335 source = bld.EXPAND_VARIABLES(source, vars=vars)
336 if subdir:
337 source = bld.SUBDIR(subdir, source)
338 source = unique_list(TO_LIST(source))
340 if group == 'binaries':
341 subsystem_group = 'main'
342 else:
343 subsystem_group = group
345 # only specify PIE flags for binaries
346 pie_cflags = cflags
347 pie_ldflags = TO_LIST(ldflags)
348 if bld.env['ENABLE_PIE'] == True:
349 pie_cflags += ' -fPIE'
350 pie_ldflags.extend(TO_LIST('-pie'))
351 if bld.env['ENABLE_RELRO'] == True:
352 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
354 # first create a target for building the object files for this binary
355 # by separating in this way, we avoid recompiling the C files
356 # separately for the install binary and the build binary
357 bld.SAMBA_SUBSYSTEM(obj_target,
358 source = source,
359 deps = deps,
360 includes = includes,
361 cflags = pie_cflags,
362 group = subsystem_group,
363 autoproto = autoproto,
364 subsystem_name = subsystem_name,
365 local_include = local_include,
366 global_include = global_include,
367 use_hostcc = use_hostcc,
368 pyext = pyembed,
369 use_global_deps= use_global_deps)
371 bld.SET_BUILD_GROUP(group)
373 # the binary itself will depend on that object target
374 deps = TO_LIST(deps)
375 deps.append(obj_target)
377 t = bld(
378 features = features,
379 source = [],
380 target = binname,
381 samba_deps = deps,
382 samba_includes = includes,
383 local_include = local_include,
384 global_include = global_include,
385 samba_modules = modules,
386 top = True,
387 samba_subsystem= subsystem_name,
388 install_path = None,
389 samba_inst_path= install_path,
390 samba_install = install,
391 samba_ldflags = pie_ldflags
394 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
395 bld.MANPAGES(manpages, install)
397 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
400 #################################################################
401 def SAMBA_MODULE(bld, modname, source,
402 deps='',
403 includes='',
404 subsystem=None,
405 init_function=None,
406 module_init_name='samba_init_module',
407 autoproto=None,
408 autoproto_extra_source='',
409 cflags='',
410 internal_module=True,
411 local_include=True,
412 global_include=True,
413 vars=None,
414 subdir=None,
415 enabled=True,
416 pyembed=False,
417 manpages=None,
418 allow_undefined_symbols=False
420 '''define a Samba module.'''
422 source = bld.EXPAND_VARIABLES(source, vars=vars)
423 if subdir:
424 source = bld.SUBDIR(subdir, source)
426 if internal_module or BUILTIN_LIBRARY(bld, modname):
427 # Do not create modules for disabled subsystems
428 if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
429 return
430 bld.SAMBA_SUBSYSTEM(modname, source,
431 deps=deps,
432 includes=includes,
433 autoproto=autoproto,
434 autoproto_extra_source=autoproto_extra_source,
435 cflags=cflags,
436 local_include=local_include,
437 global_include=global_include,
438 enabled=enabled)
440 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
441 return
443 if not enabled:
444 SET_TARGET_TYPE(bld, modname, 'DISABLED')
445 return
447 # Do not create modules for disabled subsystems
448 if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
449 return
451 obj_target = modname + '.objlist'
453 realname = modname
454 if subsystem is not None:
455 deps += ' ' + subsystem
456 while realname.startswith("lib"+subsystem+"_"):
457 realname = realname[len("lib"+subsystem+"_"):]
458 while realname.startswith(subsystem+"_"):
459 realname = realname[len(subsystem+"_"):]
461 realname = bld.make_libname(realname)
462 while realname.startswith("lib"):
463 realname = realname[len("lib"):]
465 build_link_name = "modules/%s/%s" % (subsystem, realname)
467 if init_function:
468 cflags += " -D%s=%s" % (init_function, module_init_name)
470 bld.SAMBA_LIBRARY(modname,
471 source,
472 deps=deps,
473 includes=includes,
474 cflags=cflags,
475 realname = realname,
476 autoproto = autoproto,
477 local_include=local_include,
478 global_include=global_include,
479 vars=vars,
480 link_name=build_link_name,
481 install_path="${MODULESDIR}/%s" % subsystem,
482 pyembed=pyembed,
483 manpages=manpages,
484 allow_undefined_symbols=allow_undefined_symbols
488 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
491 #################################################################
492 def SAMBA_SUBSYSTEM(bld, modname, source,
493 deps='',
494 public_deps='',
495 includes='',
496 public_headers=None,
497 public_headers_install=True,
498 header_path=None,
499 cflags='',
500 cflags_end=None,
501 group='main',
502 init_function_sentinel=None,
503 autoproto=None,
504 autoproto_extra_source='',
505 depends_on='',
506 local_include=True,
507 local_include_first=True,
508 global_include=True,
509 subsystem_name=None,
510 enabled=True,
511 use_hostcc=False,
512 use_global_deps=True,
513 vars=None,
514 subdir=None,
515 hide_symbols=False,
516 pyext=False,
517 pyembed=False):
518 '''define a Samba subsystem'''
520 if not enabled:
521 SET_TARGET_TYPE(bld, modname, 'DISABLED')
522 return
524 # remember empty subsystems, so we can strip the dependencies
525 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
526 SET_TARGET_TYPE(bld, modname, 'EMPTY')
527 return
529 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
530 return
532 source = bld.EXPAND_VARIABLES(source, vars=vars)
533 if subdir:
534 source = bld.SUBDIR(subdir, source)
535 source = unique_list(TO_LIST(source))
537 deps += ' ' + public_deps
539 bld.SET_BUILD_GROUP(group)
541 features = 'cc'
542 if pyext:
543 features += ' pyext'
544 if pyembed:
545 features += ' pyembed'
547 t = bld(
548 features = features,
549 source = source,
550 target = modname,
551 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols),
552 depends_on = depends_on,
553 samba_deps = TO_LIST(deps),
554 samba_includes = includes,
555 local_include = local_include,
556 local_include_first = local_include_first,
557 global_include = global_include,
558 samba_subsystem= subsystem_name,
559 samba_use_hostcc = use_hostcc,
560 samba_use_global_deps = use_global_deps,
563 if cflags_end is not None:
564 t.samba_cflags.extend(TO_LIST(cflags_end))
566 if autoproto is not None:
567 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
568 if public_headers is not None:
569 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
570 public_headers_install=public_headers_install)
571 return t
574 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
577 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
578 group='generators', enabled=True,
579 public_headers=None,
580 public_headers_install=True,
581 header_path=None,
582 vars=None,
583 always=False):
584 '''A generic source generator target'''
586 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
587 return
589 if not enabled:
590 return
592 dep_vars = []
593 if isinstance(vars, dict):
594 dep_vars = vars.keys()
595 elif isinstance(vars, list):
596 dep_vars = vars
598 bld.SET_BUILD_GROUP(group)
599 t = bld(
600 rule=rule,
601 source=bld.EXPAND_VARIABLES(source, vars=vars),
602 target=target,
603 shell=isinstance(rule, str),
604 on_results=True,
605 before='cc',
606 ext_out='.c',
607 samba_type='GENERATOR',
608 dep_vars = [rule] + dep_vars,
609 name=name)
611 if always:
612 t.always = True
614 if public_headers is not None:
615 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
616 public_headers_install=public_headers_install)
617 return t
618 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
622 @runonce
623 def SETUP_BUILD_GROUPS(bld):
624 '''setup build groups used to ensure that the different build
625 phases happen consecutively'''
626 bld.p_ln = bld.srcnode # we do want to see all targets!
627 bld.env['USING_BUILD_GROUPS'] = True
628 bld.add_group('setup')
629 bld.add_group('build_compiler_source')
630 bld.add_group('vscripts')
631 bld.add_group('base_libraries')
632 bld.add_group('generators')
633 bld.add_group('compiler_prototypes')
634 bld.add_group('compiler_libraries')
635 bld.add_group('build_compilers')
636 bld.add_group('build_source')
637 bld.add_group('prototypes')
638 bld.add_group('headers')
639 bld.add_group('main')
640 bld.add_group('symbolcheck')
641 bld.add_group('syslibcheck')
642 bld.add_group('final')
643 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
646 def SET_BUILD_GROUP(bld, group):
647 '''set the current build group'''
648 if not 'USING_BUILD_GROUPS' in bld.env:
649 return
650 bld.set_group(group)
651 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
655 @conf
656 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
657 """use timestamps instead of file contents for deps
658 this currently doesn't work"""
659 def h_file(filename):
660 import stat
661 st = os.stat(filename)
662 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
663 m = Utils.md5()
664 m.update(str(st.st_mtime))
665 m.update(str(st.st_size))
666 m.update(filename)
667 return m.digest()
668 Utils.h_file = h_file
671 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
672 '''used to copy scripts from the source tree into the build directory
673 for use by selftest'''
675 source = bld.path.ant_glob(pattern)
677 bld.SET_BUILD_GROUP('build_source')
678 for s in TO_LIST(source):
679 iname = s
680 if installname is not None:
681 iname = installname
682 target = os.path.join(installdir, iname)
683 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
684 mkdir_p(tgtdir)
685 link_src = os.path.normpath(os.path.join(bld.curdir, s))
686 link_dst = os.path.join(tgtdir, os.path.basename(iname))
687 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
688 continue
689 if os.path.exists(link_dst):
690 os.unlink(link_dst)
691 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
692 os.symlink(link_src, link_dst)
693 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
696 def copy_and_fix_python_path(task):
697 pattern='sys.path.insert(0, "bin/python")'
698 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
699 replacement = ""
700 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
701 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
702 else:
703 replacement="""sys.path.insert(0, "%s")
704 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
706 shebang = None
708 if task.env["PYTHON"][0] == "/":
709 replacement_shebang = "#!%s\n" % task.env["PYTHON"]
710 else:
711 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"]
713 installed_location=task.outputs[0].bldpath(task.env)
714 source_file = open(task.inputs[0].srcpath(task.env))
715 installed_file = open(installed_location, 'w')
716 lineno = 0
717 for line in source_file:
718 newline = line
719 if lineno == 0 and task.env["PYTHON_SPECIFIED"] == True and line[:2] == "#!":
720 newline = replacement_shebang
721 elif pattern in line:
722 newline = line.replace(pattern, replacement)
723 installed_file.write(newline)
724 lineno = lineno + 1
725 installed_file.close()
726 os.chmod(installed_location, 0755)
727 return 0
730 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
731 python_fixup=False, destname=None, base_name=None):
732 '''install a file'''
733 destdir = bld.EXPAND_VARIABLES(destdir)
734 if not destname:
735 destname = file
736 if flat:
737 destname = os.path.basename(destname)
738 dest = os.path.join(destdir, destname)
739 if python_fixup:
740 # fixup the python path it will use to find Samba modules
741 inst_file = file + '.inst'
742 bld.SAMBA_GENERATOR('python_%s' % destname,
743 rule=copy_and_fix_python_path,
744 source=file,
745 target=inst_file)
746 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONARCHDIR"])
747 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONDIR"])
748 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), str(bld.env["PYTHON_SPECIFIED"]))
749 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHON"])
750 file = inst_file
751 if base_name:
752 file = os.path.join(base_name, file)
753 bld.install_as(dest, file, chmod=chmod)
756 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
757 python_fixup=False, destname=None, base_name=None):
758 '''install a set of files'''
759 for f in TO_LIST(files):
760 install_file(bld, destdir, f, chmod=chmod, flat=flat,
761 python_fixup=python_fixup, destname=destname,
762 base_name=base_name)
763 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
766 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
767 python_fixup=False, exclude=None, trim_path=None):
768 '''install a set of files matching a wildcard pattern'''
769 files=TO_LIST(bld.path.ant_glob(pattern))
770 if trim_path:
771 files2 = []
772 for f in files:
773 files2.append(os_path_relpath(f, trim_path))
774 files = files2
776 if exclude:
777 for f in files[:]:
778 if fnmatch.fnmatch(f, exclude):
779 files.remove(f)
780 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
781 python_fixup=python_fixup, base_name=trim_path)
782 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
785 def INSTALL_DIRS(bld, destdir, dirs):
786 '''install a set of directories'''
787 destdir = bld.EXPAND_VARIABLES(destdir)
788 dirs = bld.EXPAND_VARIABLES(dirs)
789 for d in TO_LIST(dirs):
790 bld.install_dir(os.path.join(destdir, d))
791 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
794 def MANPAGES(bld, manpages, install):
795 '''build and install manual pages'''
796 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
797 for m in manpages.split():
798 source = m + '.xml'
799 bld.SAMBA_GENERATOR(m,
800 source=source,
801 target=m,
802 group='final',
803 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
805 if install:
806 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
807 Build.BuildContext.MANPAGES = MANPAGES
809 def SAMBAMANPAGES(bld, manpages):
810 '''build and install manual pages'''
811 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
812 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
813 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'
815 for m in manpages.split():
816 source = m + '.xml'
817 bld.SAMBA_GENERATOR(m,
818 source=source,
819 target=m,
820 group='final',
821 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
822 export XML_CATALOG_FILES
823 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC}
824 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
826 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
827 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
829 #############################################################
830 # give a nicer display when building different types of files
831 def progress_display(self, msg, fname):
832 col1 = Logs.colors(self.color)
833 col2 = Logs.colors.NORMAL
834 total = self.position[1]
835 n = len(str(total))
836 fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
837 return fs % (self.position[0], self.position[1], col1, fname, col2)
839 def link_display(self):
840 if Options.options.progress_bar != 0:
841 return Task.Task.old_display(self)
842 fname = self.outputs[0].bldpath(self.env)
843 return progress_display(self, 'Linking', fname)
844 Task.TaskBase.classes['cc_link'].display = link_display
846 def samba_display(self):
847 if Options.options.progress_bar != 0:
848 return Task.Task.old_display(self)
850 targets = LOCAL_CACHE(self, 'TARGET_TYPE')
851 if self.name in targets:
852 target_type = targets[self.name]
853 type_map = { 'GENERATOR' : 'Generating',
854 'PROTOTYPE' : 'Generating'
856 if target_type in type_map:
857 return progress_display(self, type_map[target_type], self.name)
859 if len(self.inputs) == 0:
860 return Task.Task.old_display(self)
862 fname = self.inputs[0].bldpath(self.env)
863 if fname[0:3] == '../':
864 fname = fname[3:]
865 ext_loc = fname.rfind('.')
866 if ext_loc == -1:
867 return Task.Task.old_display(self)
868 ext = fname[ext_loc:]
870 ext_map = { '.idl' : 'Compiling IDL',
871 '.et' : 'Compiling ERRTABLE',
872 '.asn1': 'Compiling ASN1',
873 '.c' : 'Compiling' }
874 if ext in ext_map:
875 return progress_display(self, ext_map[ext], fname)
876 return Task.Task.old_display(self)
878 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
879 Task.TaskBase.classes['Task'].display = samba_display
882 @after('apply_link')
883 @feature('cshlib')
884 def apply_bundle_remove_dynamiclib_patch(self):
885 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
886 if not getattr(self,'vnum',None):
887 try:
888 self.env['LINKFLAGS'].remove('-dynamiclib')
889 self.env['LINKFLAGS'].remove('-single_module')
890 except ValueError:
891 pass