Fix some typos.
[Samba.git] / buildtools / wafsamba / wafsamba.py
blob8ec4cb808632eaa97e75ba7a2ab2f4902e5d14e5
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 allow_warnings=True,
134 enabled=True):
135 '''define a Samba library'''
137 if LIB_MUST_BE_PRIVATE(bld, libname):
138 private_library=True
140 if not enabled:
141 SET_TARGET_TYPE(bld, libname, 'DISABLED')
142 return
144 source = bld.EXPAND_VARIABLES(source, vars=vars)
145 if subdir:
146 source = bld.SUBDIR(subdir, source)
148 # remember empty libraries, so we can strip the dependencies
149 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
150 SET_TARGET_TYPE(bld, libname, 'EMPTY')
151 return
153 if BUILTIN_LIBRARY(bld, libname):
154 obj_target = libname
155 else:
156 obj_target = libname + '.objlist'
158 if group == 'libraries':
159 subsystem_group = 'main'
160 else:
161 subsystem_group = group
163 # first create a target for building the object files for this library
164 # by separating in this way, we avoid recompiling the C files
165 # separately for the install library and the build library
166 bld.SAMBA_SUBSYSTEM(obj_target,
167 source = source,
168 deps = deps,
169 public_deps = public_deps,
170 includes = includes,
171 public_headers = public_headers,
172 public_headers_install = public_headers_install,
173 header_path = header_path,
174 cflags = cflags,
175 group = subsystem_group,
176 autoproto = autoproto,
177 autoproto_extra_source=autoproto_extra_source,
178 depends_on = depends_on,
179 hide_symbols = hide_symbols,
180 allow_warnings = allow_warnings,
181 pyembed = pyembed,
182 pyext = pyext,
183 local_include = local_include,
184 global_include = global_include)
186 if BUILTIN_LIBRARY(bld, libname):
187 return
189 if not SET_TARGET_TYPE(bld, libname, target_type):
190 return
192 # the library itself will depend on that object target
193 deps += ' ' + public_deps
194 deps = TO_LIST(deps)
195 deps.append(obj_target)
197 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
198 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
200 # we don't want any public libraries without version numbers
201 if (not private_library and target_type != 'PYTHON' and not realname):
202 if vnum is None and soname is None:
203 raise Utils.WafError("public library '%s' must have a vnum" %
204 libname)
205 if pc_files is None:
206 raise Utils.WafError("public library '%s' must have pkg-config file" %
207 libname)
208 if public_headers is None:
209 raise Utils.WafError("public library '%s' must have header files" %
210 libname)
212 if target_type == 'PYTHON' or realname or not private_library:
213 bundled_name = libname.replace('_', '-')
214 else:
215 bundled_name = PRIVATE_NAME(bld, libname, bundled_extension,
216 private_library)
218 ldflags = TO_LIST(ldflags)
220 features = 'cc cshlib symlink_lib install_lib'
221 if pyext:
222 features += ' pyext'
223 if pyembed:
224 features += ' pyembed'
226 if abi_directory:
227 features += ' abi_check'
229 vscript = None
230 if bld.env.HAVE_LD_VERSION_SCRIPT:
231 if private_library:
232 version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
233 elif vnum:
234 version = "%s_%s" % (libname, vnum)
235 else:
236 version = None
237 if version:
238 vscript = "%s.vscript" % libname
239 bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
240 abi_match)
241 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
242 fullpath = bld.path.find_or_declare(fullname)
243 vscriptpath = bld.path.find_or_declare(vscript)
244 if not fullpath:
245 raise Utils.WafError("unable to find fullpath for %s" % fullname)
246 if not vscriptpath:
247 raise Utils.WafError("unable to find vscript path for %s" % vscript)
248 bld.add_manual_dependency(fullpath, vscriptpath)
249 if Options.is_install:
250 # also make the .inst file depend on the vscript
251 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
252 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
253 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
255 bld.SET_BUILD_GROUP(group)
256 t = bld(
257 features = features,
258 source = [],
259 target = bundled_name,
260 depends_on = depends_on,
261 samba_ldflags = ldflags,
262 samba_deps = deps,
263 samba_includes = includes,
264 version_script = vscript,
265 local_include = local_include,
266 global_include = global_include,
267 vnum = vnum,
268 soname = soname,
269 install_path = None,
270 samba_inst_path = install_path,
271 name = libname,
272 samba_realname = realname,
273 samba_install = install,
274 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
275 abi_match = abi_match,
276 private_library = private_library,
277 grouping_library=grouping_library,
278 allow_undefined_symbols=allow_undefined_symbols
281 if realname and not link_name:
282 link_name = 'shared/%s' % realname
284 if link_name:
285 t.link_name = link_name
287 if pc_files is not None and not private_library:
288 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
290 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
291 bld.env['XSLTPROC_MANPAGES']):
292 bld.MANPAGES(manpages, install)
295 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
298 #################################################################
299 def SAMBA_BINARY(bld, binname, source,
300 deps='',
301 includes='',
302 public_headers=None,
303 header_path=None,
304 modules=None,
305 ldflags=None,
306 cflags='',
307 autoproto=None,
308 use_hostcc=False,
309 use_global_deps=True,
310 compiler=None,
311 group='main',
312 manpages=None,
313 local_include=True,
314 global_include=True,
315 subsystem_name=None,
316 pyembed=False,
317 vars=None,
318 subdir=None,
319 install=True,
320 install_path=None,
321 enabled=True):
322 '''define a Samba binary'''
324 if not enabled:
325 SET_TARGET_TYPE(bld, binname, 'DISABLED')
326 return
328 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
329 return
331 features = 'cc cprogram symlink_bin install_bin'
332 if pyembed:
333 features += ' pyembed'
335 obj_target = binname + '.objlist'
337 source = bld.EXPAND_VARIABLES(source, vars=vars)
338 if subdir:
339 source = bld.SUBDIR(subdir, source)
340 source = unique_list(TO_LIST(source))
342 if group == 'binaries':
343 subsystem_group = 'main'
344 else:
345 subsystem_group = group
347 # only specify PIE flags for binaries
348 pie_cflags = cflags
349 pie_ldflags = TO_LIST(ldflags)
350 if bld.env['ENABLE_PIE'] == True:
351 pie_cflags += ' -fPIE'
352 pie_ldflags.extend(TO_LIST('-pie'))
353 if bld.env['ENABLE_RELRO'] == True:
354 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
356 # first create a target for building the object files for this binary
357 # by separating in this way, we avoid recompiling the C files
358 # separately for the install binary and the build binary
359 bld.SAMBA_SUBSYSTEM(obj_target,
360 source = source,
361 deps = deps,
362 includes = includes,
363 cflags = pie_cflags,
364 group = subsystem_group,
365 autoproto = autoproto,
366 subsystem_name = subsystem_name,
367 local_include = local_include,
368 global_include = global_include,
369 use_hostcc = use_hostcc,
370 pyext = pyembed,
371 use_global_deps= use_global_deps)
373 bld.SET_BUILD_GROUP(group)
375 # the binary itself will depend on that object target
376 deps = TO_LIST(deps)
377 deps.append(obj_target)
379 t = bld(
380 features = features,
381 source = [],
382 target = binname,
383 samba_deps = deps,
384 samba_includes = includes,
385 local_include = local_include,
386 global_include = global_include,
387 samba_modules = modules,
388 top = True,
389 samba_subsystem= subsystem_name,
390 install_path = None,
391 samba_inst_path= install_path,
392 samba_install = install,
393 samba_ldflags = pie_ldflags
396 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
397 bld.MANPAGES(manpages, install)
399 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
402 #################################################################
403 def SAMBA_MODULE(bld, modname, source,
404 deps='',
405 includes='',
406 subsystem=None,
407 init_function=None,
408 module_init_name='samba_init_module',
409 autoproto=None,
410 autoproto_extra_source='',
411 cflags='',
412 internal_module=True,
413 local_include=True,
414 global_include=True,
415 vars=None,
416 subdir=None,
417 enabled=True,
418 pyembed=False,
419 manpages=None,
420 allow_undefined_symbols=False,
421 allow_warnings=True
423 '''define a Samba module.'''
425 source = bld.EXPAND_VARIABLES(source, vars=vars)
426 if subdir:
427 source = bld.SUBDIR(subdir, source)
429 if internal_module or BUILTIN_LIBRARY(bld, modname):
430 # Do not create modules for disabled subsystems
431 if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
432 return
433 bld.SAMBA_SUBSYSTEM(modname, source,
434 deps=deps,
435 includes=includes,
436 autoproto=autoproto,
437 autoproto_extra_source=autoproto_extra_source,
438 cflags=cflags,
439 local_include=local_include,
440 global_include=global_include,
441 allow_warnings=allow_warnings,
442 enabled=enabled)
444 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
445 return
447 if not enabled:
448 SET_TARGET_TYPE(bld, modname, 'DISABLED')
449 return
451 # Do not create modules for disabled subsystems
452 if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
453 return
455 obj_target = modname + '.objlist'
457 realname = modname
458 if subsystem is not None:
459 deps += ' ' + subsystem
460 while realname.startswith("lib"+subsystem+"_"):
461 realname = realname[len("lib"+subsystem+"_"):]
462 while realname.startswith(subsystem+"_"):
463 realname = realname[len(subsystem+"_"):]
465 realname = bld.make_libname(realname)
466 while realname.startswith("lib"):
467 realname = realname[len("lib"):]
469 build_link_name = "modules/%s/%s" % (subsystem, realname)
471 if init_function:
472 cflags += " -D%s=%s" % (init_function, module_init_name)
474 bld.SAMBA_LIBRARY(modname,
475 source,
476 deps=deps,
477 includes=includes,
478 cflags=cflags,
479 realname = realname,
480 autoproto = autoproto,
481 local_include=local_include,
482 global_include=global_include,
483 vars=vars,
484 link_name=build_link_name,
485 install_path="${MODULESDIR}/%s" % subsystem,
486 pyembed=pyembed,
487 manpages=manpages,
488 allow_undefined_symbols=allow_undefined_symbols,
489 allow_warnings=allow_warnings
493 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
496 #################################################################
497 def SAMBA_SUBSYSTEM(bld, modname, source,
498 deps='',
499 public_deps='',
500 includes='',
501 public_headers=None,
502 public_headers_install=True,
503 header_path=None,
504 cflags='',
505 cflags_end=None,
506 group='main',
507 init_function_sentinel=None,
508 autoproto=None,
509 autoproto_extra_source='',
510 depends_on='',
511 local_include=True,
512 local_include_first=True,
513 global_include=True,
514 subsystem_name=None,
515 enabled=True,
516 use_hostcc=False,
517 use_global_deps=True,
518 vars=None,
519 subdir=None,
520 hide_symbols=False,
521 allow_warnings=True,
522 pyext=False,
523 pyembed=False):
524 '''define a Samba subsystem'''
526 if not enabled:
527 SET_TARGET_TYPE(bld, modname, 'DISABLED')
528 return
530 # remember empty subsystems, so we can strip the dependencies
531 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
532 SET_TARGET_TYPE(bld, modname, 'EMPTY')
533 return
535 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
536 return
538 source = bld.EXPAND_VARIABLES(source, vars=vars)
539 if subdir:
540 source = bld.SUBDIR(subdir, source)
541 source = unique_list(TO_LIST(source))
543 deps += ' ' + public_deps
545 bld.SET_BUILD_GROUP(group)
547 features = 'cc'
548 if pyext:
549 features += ' pyext'
550 if pyembed:
551 features += ' pyembed'
553 t = bld(
554 features = features,
555 source = source,
556 target = modname,
557 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags,
558 allow_warnings=allow_warnings,
559 hide_symbols=hide_symbols),
560 depends_on = depends_on,
561 samba_deps = TO_LIST(deps),
562 samba_includes = includes,
563 local_include = local_include,
564 local_include_first = local_include_first,
565 global_include = global_include,
566 samba_subsystem= subsystem_name,
567 samba_use_hostcc = use_hostcc,
568 samba_use_global_deps = use_global_deps,
571 if cflags_end is not None:
572 t.samba_cflags.extend(TO_LIST(cflags_end))
574 if autoproto is not None:
575 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
576 if public_headers is not None:
577 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
578 public_headers_install=public_headers_install)
579 return t
582 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
585 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
586 group='generators', enabled=True,
587 public_headers=None,
588 public_headers_install=True,
589 header_path=None,
590 vars=None,
591 always=False):
592 '''A generic source generator target'''
594 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
595 return
597 if not enabled:
598 return
600 dep_vars = []
601 if isinstance(vars, dict):
602 dep_vars = vars.keys()
603 elif isinstance(vars, list):
604 dep_vars = vars
606 bld.SET_BUILD_GROUP(group)
607 t = bld(
608 rule=rule,
609 source=bld.EXPAND_VARIABLES(source, vars=vars),
610 target=target,
611 shell=isinstance(rule, str),
612 on_results=True,
613 before='cc',
614 ext_out='.c',
615 samba_type='GENERATOR',
616 dep_vars = [rule] + dep_vars,
617 name=name)
619 if always:
620 t.always = True
622 if public_headers is not None:
623 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
624 public_headers_install=public_headers_install)
625 return t
626 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
630 @runonce
631 def SETUP_BUILD_GROUPS(bld):
632 '''setup build groups used to ensure that the different build
633 phases happen consecutively'''
634 bld.p_ln = bld.srcnode # we do want to see all targets!
635 bld.env['USING_BUILD_GROUPS'] = True
636 bld.add_group('setup')
637 bld.add_group('build_compiler_source')
638 bld.add_group('vscripts')
639 bld.add_group('base_libraries')
640 bld.add_group('generators')
641 bld.add_group('compiler_prototypes')
642 bld.add_group('compiler_libraries')
643 bld.add_group('build_compilers')
644 bld.add_group('build_source')
645 bld.add_group('prototypes')
646 bld.add_group('headers')
647 bld.add_group('main')
648 bld.add_group('symbolcheck')
649 bld.add_group('syslibcheck')
650 bld.add_group('final')
651 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
654 def SET_BUILD_GROUP(bld, group):
655 '''set the current build group'''
656 if not 'USING_BUILD_GROUPS' in bld.env:
657 return
658 bld.set_group(group)
659 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
663 @conf
664 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
665 """use timestamps instead of file contents for deps
666 this currently doesn't work"""
667 def h_file(filename):
668 import stat
669 st = os.stat(filename)
670 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
671 m = Utils.md5()
672 m.update(str(st.st_mtime))
673 m.update(str(st.st_size))
674 m.update(filename)
675 return m.digest()
676 Utils.h_file = h_file
679 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
680 '''used to copy scripts from the source tree into the build directory
681 for use by selftest'''
683 source = bld.path.ant_glob(pattern)
685 bld.SET_BUILD_GROUP('build_source')
686 for s in TO_LIST(source):
687 iname = s
688 if installname is not None:
689 iname = installname
690 target = os.path.join(installdir, iname)
691 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
692 mkdir_p(tgtdir)
693 link_src = os.path.normpath(os.path.join(bld.curdir, s))
694 link_dst = os.path.join(tgtdir, os.path.basename(iname))
695 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
696 continue
697 if os.path.exists(link_dst):
698 os.unlink(link_dst)
699 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
700 os.symlink(link_src, link_dst)
701 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
704 def copy_and_fix_python_path(task):
705 pattern='sys.path.insert(0, "bin/python")'
706 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
707 replacement = ""
708 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
709 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
710 else:
711 replacement="""sys.path.insert(0, "%s")
712 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
714 shebang = None
716 if task.env["PYTHON"][0] == "/":
717 replacement_shebang = "#!%s\n" % task.env["PYTHON"]
718 else:
719 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"]
721 installed_location=task.outputs[0].bldpath(task.env)
722 source_file = open(task.inputs[0].srcpath(task.env))
723 installed_file = open(installed_location, 'w')
724 lineno = 0
725 for line in source_file:
726 newline = line
727 if lineno == 0 and task.env["PYTHON_SPECIFIED"] == True and line[:2] == "#!":
728 newline = replacement_shebang
729 elif pattern in line:
730 newline = line.replace(pattern, replacement)
731 installed_file.write(newline)
732 lineno = lineno + 1
733 installed_file.close()
734 os.chmod(installed_location, 0755)
735 return 0
738 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
739 python_fixup=False, destname=None, base_name=None):
740 '''install a file'''
741 destdir = bld.EXPAND_VARIABLES(destdir)
742 if not destname:
743 destname = file
744 if flat:
745 destname = os.path.basename(destname)
746 dest = os.path.join(destdir, destname)
747 if python_fixup:
748 # fixup the python path it will use to find Samba modules
749 inst_file = file + '.inst'
750 bld.SAMBA_GENERATOR('python_%s' % destname,
751 rule=copy_and_fix_python_path,
752 source=file,
753 target=inst_file)
754 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONARCHDIR"])
755 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONDIR"])
756 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), str(bld.env["PYTHON_SPECIFIED"]))
757 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHON"])
758 file = inst_file
759 if base_name:
760 file = os.path.join(base_name, file)
761 bld.install_as(dest, file, chmod=chmod)
764 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
765 python_fixup=False, destname=None, base_name=None):
766 '''install a set of files'''
767 for f in TO_LIST(files):
768 install_file(bld, destdir, f, chmod=chmod, flat=flat,
769 python_fixup=python_fixup, destname=destname,
770 base_name=base_name)
771 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
774 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
775 python_fixup=False, exclude=None, trim_path=None):
776 '''install a set of files matching a wildcard pattern'''
777 files=TO_LIST(bld.path.ant_glob(pattern))
778 if trim_path:
779 files2 = []
780 for f in files:
781 files2.append(os_path_relpath(f, trim_path))
782 files = files2
784 if exclude:
785 for f in files[:]:
786 if fnmatch.fnmatch(f, exclude):
787 files.remove(f)
788 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
789 python_fixup=python_fixup, base_name=trim_path)
790 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
793 def INSTALL_DIRS(bld, destdir, dirs):
794 '''install a set of directories'''
795 destdir = bld.EXPAND_VARIABLES(destdir)
796 dirs = bld.EXPAND_VARIABLES(dirs)
797 for d in TO_LIST(dirs):
798 bld.install_dir(os.path.join(destdir, d))
799 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
802 def MANPAGES(bld, manpages, install):
803 '''build and install manual pages'''
804 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
805 for m in manpages.split():
806 source = m + '.xml'
807 bld.SAMBA_GENERATOR(m,
808 source=source,
809 target=m,
810 group='final',
811 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
813 if install:
814 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
815 Build.BuildContext.MANPAGES = MANPAGES
817 def SAMBAMANPAGES(bld, manpages, extra_source=None):
818 '''build and install manual pages'''
819 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
820 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
821 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'
823 for m in manpages.split():
824 source = m + '.xml'
825 if extra_source is not None:
826 source = [source, extra_source]
827 bld.SAMBA_GENERATOR(m,
828 source=source,
829 target=m,
830 group='final',
831 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
832 export XML_CATALOG_FILES
833 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
834 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
836 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
837 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
839 #############################################################
840 # give a nicer display when building different types of files
841 def progress_display(self, msg, fname):
842 col1 = Logs.colors(self.color)
843 col2 = Logs.colors.NORMAL
844 total = self.position[1]
845 n = len(str(total))
846 fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
847 return fs % (self.position[0], self.position[1], col1, fname, col2)
849 def link_display(self):
850 if Options.options.progress_bar != 0:
851 return Task.Task.old_display(self)
852 fname = self.outputs[0].bldpath(self.env)
853 return progress_display(self, 'Linking', fname)
854 Task.TaskBase.classes['cc_link'].display = link_display
856 def samba_display(self):
857 if Options.options.progress_bar != 0:
858 return Task.Task.old_display(self)
860 targets = LOCAL_CACHE(self, 'TARGET_TYPE')
861 if self.name in targets:
862 target_type = targets[self.name]
863 type_map = { 'GENERATOR' : 'Generating',
864 'PROTOTYPE' : 'Generating'
866 if target_type in type_map:
867 return progress_display(self, type_map[target_type], self.name)
869 if len(self.inputs) == 0:
870 return Task.Task.old_display(self)
872 fname = self.inputs[0].bldpath(self.env)
873 if fname[0:3] == '../':
874 fname = fname[3:]
875 ext_loc = fname.rfind('.')
876 if ext_loc == -1:
877 return Task.Task.old_display(self)
878 ext = fname[ext_loc:]
880 ext_map = { '.idl' : 'Compiling IDL',
881 '.et' : 'Compiling ERRTABLE',
882 '.asn1': 'Compiling ASN1',
883 '.c' : 'Compiling' }
884 if ext in ext_map:
885 return progress_display(self, ext_map[ext], fname)
886 return Task.Task.old_display(self)
888 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
889 Task.TaskBase.classes['Task'].display = samba_display
892 @after('apply_link')
893 @feature('cshlib')
894 def apply_bundle_remove_dynamiclib_patch(self):
895 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
896 if not getattr(self,'vnum',None):
897 try:
898 self.env['LINKFLAGS'].remove('-dynamiclib')
899 self.env['LINKFLAGS'].remove('-single_module')
900 except ValueError:
901 pass