s3: Do not free a string where we should not
[Samba/gbeck.git] / buildtools / wafsamba / wafsamba.py
blob59d3a2c02f939a61545116ca6174a9965880d666
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 p in ['python','shared', 'modules']:
68 link_target = os.path.join(conf.blddir, 'default/' + p)
69 if not os.path.lexists(link_target):
70 os.symlink('../' + p, 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='libraries',
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)
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='binaries',
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 # first create a target for building the object files for this binary
346 # by separating in this way, we avoid recompiling the C files
347 # separately for the install binary and the build binary
348 bld.SAMBA_SUBSYSTEM(obj_target,
349 source = source,
350 deps = deps,
351 includes = includes,
352 cflags = cflags,
353 group = subsystem_group,
354 autoproto = autoproto,
355 subsystem_name = subsystem_name,
356 local_include = local_include,
357 global_include = global_include,
358 use_hostcc = use_hostcc,
359 pyext = pyembed,
360 use_global_deps= use_global_deps)
362 bld.SET_BUILD_GROUP(group)
364 # the binary itself will depend on that object target
365 deps = TO_LIST(deps)
366 deps.append(obj_target)
368 t = bld(
369 features = features,
370 source = [],
371 target = binname,
372 samba_deps = deps,
373 samba_includes = includes,
374 local_include = local_include,
375 global_include = global_include,
376 samba_modules = modules,
377 top = True,
378 samba_subsystem= subsystem_name,
379 install_path = None,
380 samba_inst_path= install_path,
381 samba_install = install,
382 samba_ldflags = TO_LIST(ldflags)
385 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
386 bld.MANPAGES(manpages)
388 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
391 #################################################################
392 def SAMBA_MODULE(bld, modname, source,
393 deps='',
394 includes='',
395 subsystem=None,
396 init_function=None,
397 module_init_name='samba_init_module',
398 autoproto=None,
399 autoproto_extra_source='',
400 cflags='',
401 internal_module=True,
402 local_include=True,
403 global_include=True,
404 vars=None,
405 subdir=None,
406 enabled=True,
407 pyembed=False,
408 manpages=None,
409 allow_undefined_symbols=False
411 '''define a Samba module.'''
413 source = bld.EXPAND_VARIABLES(source, vars=vars)
414 if subdir:
415 source = bld.SUBDIR(subdir, source)
417 if internal_module or BUILTIN_LIBRARY(bld, modname):
418 # Do not create modules for disabled subsystems
419 if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
420 return
421 bld.SAMBA_SUBSYSTEM(modname, source,
422 deps=deps,
423 includes=includes,
424 autoproto=autoproto,
425 autoproto_extra_source=autoproto_extra_source,
426 cflags=cflags,
427 local_include=local_include,
428 global_include=global_include,
429 enabled=enabled)
431 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
432 return
434 if not enabled:
435 SET_TARGET_TYPE(bld, modname, 'DISABLED')
436 return
438 # Do not create modules for disabled subsystems
439 if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
440 return
442 obj_target = modname + '.objlist'
444 realname = modname
445 if subsystem is not None:
446 deps += ' ' + subsystem
447 while realname.startswith("lib"+subsystem+"_"):
448 realname = realname[len("lib"+subsystem+"_"):]
449 while realname.startswith(subsystem+"_"):
450 realname = realname[len(subsystem+"_"):]
452 realname = bld.make_libname(realname)
453 while realname.startswith("lib"):
454 realname = realname[len("lib"):]
456 build_link_name = "modules/%s/%s" % (subsystem, realname)
458 if init_function:
459 cflags += " -D%s=%s" % (init_function, module_init_name)
461 bld.SAMBA_LIBRARY(modname,
462 source,
463 deps=deps,
464 includes=includes,
465 cflags=cflags,
466 realname = realname,
467 autoproto = autoproto,
468 local_include=local_include,
469 global_include=global_include,
470 vars=vars,
471 link_name=build_link_name,
472 install_path="${MODULESDIR}/%s" % subsystem,
473 pyembed=pyembed,
474 manpages=manpages,
475 allow_undefined_symbols=allow_undefined_symbols
479 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
482 #################################################################
483 def SAMBA_SUBSYSTEM(bld, modname, source,
484 deps='',
485 public_deps='',
486 includes='',
487 public_headers=None,
488 public_headers_install=True,
489 header_path=None,
490 cflags='',
491 cflags_end=None,
492 group='main',
493 init_function_sentinel=None,
494 autoproto=None,
495 autoproto_extra_source='',
496 depends_on='',
497 local_include=True,
498 local_include_first=True,
499 global_include=True,
500 subsystem_name=None,
501 enabled=True,
502 use_hostcc=False,
503 use_global_deps=True,
504 vars=None,
505 subdir=None,
506 hide_symbols=False,
507 pyext=False,
508 pyembed=False):
509 '''define a Samba subsystem'''
511 if not enabled:
512 SET_TARGET_TYPE(bld, modname, 'DISABLED')
513 return
515 # remember empty subsystems, so we can strip the dependencies
516 if ((source == '') or (source == [])) and deps == '' and public_deps == '':
517 SET_TARGET_TYPE(bld, modname, 'EMPTY')
518 return
520 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
521 return
523 source = bld.EXPAND_VARIABLES(source, vars=vars)
524 if subdir:
525 source = bld.SUBDIR(subdir, source)
526 source = unique_list(TO_LIST(source))
528 deps += ' ' + public_deps
530 bld.SET_BUILD_GROUP(group)
532 features = 'cc'
533 if pyext:
534 features += ' pyext'
535 if pyembed:
536 features += ' pyembed'
538 t = bld(
539 features = features,
540 source = source,
541 target = modname,
542 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols),
543 depends_on = depends_on,
544 samba_deps = TO_LIST(deps),
545 samba_includes = includes,
546 local_include = local_include,
547 local_include_first = local_include_first,
548 global_include = global_include,
549 samba_subsystem= subsystem_name,
550 samba_use_hostcc = use_hostcc,
551 samba_use_global_deps = use_global_deps,
554 if cflags_end is not None:
555 t.samba_cflags.extend(TO_LIST(cflags_end))
557 if autoproto is not None:
558 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
559 if public_headers is not None:
560 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
561 public_headers_install=public_headers_install)
562 return t
565 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
568 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
569 group='generators', enabled=True,
570 public_headers=None,
571 public_headers_install=True,
572 header_path=None,
573 vars=None,
574 always=False):
575 '''A generic source generator target'''
577 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
578 return
580 if not enabled:
581 return
583 dep_vars = []
584 if isinstance(vars, dict):
585 dep_vars = vars.keys()
586 elif isinstance(vars, list):
587 dep_vars = vars
589 bld.SET_BUILD_GROUP(group)
590 t = bld(
591 rule=rule,
592 source=bld.EXPAND_VARIABLES(source, vars=vars),
593 target=target,
594 shell=isinstance(rule, str),
595 on_results=True,
596 before='cc',
597 ext_out='.c',
598 samba_type='GENERATOR',
599 dep_vars = [rule] + dep_vars,
600 name=name)
602 if always:
603 t.always = True
605 if public_headers is not None:
606 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
607 public_headers_install=public_headers_install)
608 return t
609 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
613 @runonce
614 def SETUP_BUILD_GROUPS(bld):
615 '''setup build groups used to ensure that the different build
616 phases happen consecutively'''
617 bld.p_ln = bld.srcnode # we do want to see all targets!
618 bld.env['USING_BUILD_GROUPS'] = True
619 bld.add_group('setup')
620 bld.add_group('build_compiler_source')
621 bld.add_group('vscripts')
622 bld.add_group('base_libraries')
623 bld.add_group('generators')
624 bld.add_group('compiler_prototypes')
625 bld.add_group('compiler_libraries')
626 bld.add_group('build_compilers')
627 bld.add_group('build_source')
628 bld.add_group('prototypes')
629 bld.add_group('headers')
630 bld.add_group('main')
631 bld.add_group('symbolcheck')
632 bld.add_group('libraries')
633 bld.add_group('binaries')
634 bld.add_group('syslibcheck')
635 bld.add_group('final')
636 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
639 def SET_BUILD_GROUP(bld, group):
640 '''set the current build group'''
641 if not 'USING_BUILD_GROUPS' in bld.env:
642 return
643 bld.set_group(group)
644 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
648 @conf
649 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
650 """use timestamps instead of file contents for deps
651 this currently doesn't work"""
652 def h_file(filename):
653 import stat
654 st = os.stat(filename)
655 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
656 m = Utils.md5()
657 m.update(str(st.st_mtime))
658 m.update(str(st.st_size))
659 m.update(filename)
660 return m.digest()
661 Utils.h_file = h_file
664 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
665 '''used to copy scripts from the source tree into the build directory
666 for use by selftest'''
668 source = bld.path.ant_glob(pattern)
670 bld.SET_BUILD_GROUP('build_source')
671 for s in TO_LIST(source):
672 iname = s
673 if installname is not None:
674 iname = installname
675 target = os.path.join(installdir, iname)
676 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
677 mkdir_p(tgtdir)
678 link_src = os.path.normpath(os.path.join(bld.curdir, s))
679 link_dst = os.path.join(tgtdir, os.path.basename(iname))
680 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
681 continue
682 if os.path.exists(link_dst):
683 os.unlink(link_dst)
684 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
685 os.symlink(link_src, link_dst)
686 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
689 def copy_and_fix_python_path(task):
690 pattern='sys.path.insert(0, "bin/python")'
691 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
692 replacement = ""
693 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
694 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
695 else:
696 replacement="""sys.path.insert(0, "%s")
697 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
699 installed_location=task.outputs[0].bldpath(task.env)
700 source_file = open(task.inputs[0].srcpath(task.env))
701 installed_file = open(installed_location, 'w')
702 for line in source_file:
703 newline = line
704 if pattern in line:
705 newline = line.replace(pattern, replacement)
706 installed_file.write(newline)
707 installed_file.close()
708 os.chmod(installed_location, 0755)
709 return 0
712 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
713 python_fixup=False, destname=None, base_name=None):
714 '''install a file'''
715 destdir = bld.EXPAND_VARIABLES(destdir)
716 if not destname:
717 destname = file
718 if flat:
719 destname = os.path.basename(destname)
720 dest = os.path.join(destdir, destname)
721 if python_fixup:
722 # fixup the python path it will use to find Samba modules
723 inst_file = file + '.inst'
724 bld.SAMBA_GENERATOR('python_%s' % destname,
725 rule=copy_and_fix_python_path,
726 source=file,
727 target=inst_file)
728 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONARCHDIR"])
729 bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONDIR"])
730 file = inst_file
731 if base_name:
732 file = os.path.join(base_name, file)
733 bld.install_as(dest, file, chmod=chmod)
736 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
737 python_fixup=False, destname=None, base_name=None):
738 '''install a set of files'''
739 for f in TO_LIST(files):
740 install_file(bld, destdir, f, chmod=chmod, flat=flat,
741 python_fixup=python_fixup, destname=destname,
742 base_name=base_name)
743 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
746 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
747 python_fixup=False, exclude=None, trim_path=None):
748 '''install a set of files matching a wildcard pattern'''
749 files=TO_LIST(bld.path.ant_glob(pattern))
750 if trim_path:
751 files2 = []
752 for f in files:
753 files2.append(os_path_relpath(f, trim_path))
754 files = files2
756 if exclude:
757 for f in files[:]:
758 if fnmatch.fnmatch(f, exclude):
759 files.remove(f)
760 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
761 python_fixup=python_fixup, base_name=trim_path)
762 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
765 def INSTALL_DIRS(bld, destdir, dirs):
766 '''install a set of directories'''
767 destdir = bld.EXPAND_VARIABLES(destdir)
768 dirs = bld.EXPAND_VARIABLES(dirs)
769 for d in TO_LIST(dirs):
770 bld.install_dir(os.path.join(destdir, d))
771 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
774 def MANPAGES(bld, manpages):
775 '''build and install manual pages'''
776 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
777 for m in manpages.split():
778 source = m + '.xml'
779 bld.SAMBA_GENERATOR(m,
780 source=source,
781 target=m,
782 group='final',
783 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
785 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
786 Build.BuildContext.MANPAGES = MANPAGES
788 def SAMBAMANPAGES(bld, manpages):
789 '''build and install manual pages'''
790 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
791 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
792 bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file://' + bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
793 for m in manpages.split():
794 source = m + '.xml'
795 bld.SAMBA_GENERATOR(m,
796 source=source,
797 target=m,
798 group='final',
799 rule='''export XML_CATALOG_FILES="${SAMBA_CATALOGS}"
800 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC}
801 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
803 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
804 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
806 #############################################################
807 # give a nicer display when building different types of files
808 def progress_display(self, msg, fname):
809 col1 = Logs.colors(self.color)
810 col2 = Logs.colors.NORMAL
811 total = self.position[1]
812 n = len(str(total))
813 fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
814 return fs % (self.position[0], self.position[1], col1, fname, col2)
816 def link_display(self):
817 if Options.options.progress_bar != 0:
818 return Task.Task.old_display(self)
819 fname = self.outputs[0].bldpath(self.env)
820 return progress_display(self, 'Linking', fname)
821 Task.TaskBase.classes['cc_link'].display = link_display
823 def samba_display(self):
824 if Options.options.progress_bar != 0:
825 return Task.Task.old_display(self)
827 targets = LOCAL_CACHE(self, 'TARGET_TYPE')
828 if self.name in targets:
829 target_type = targets[self.name]
830 type_map = { 'GENERATOR' : 'Generating',
831 'PROTOTYPE' : 'Generating'
833 if target_type in type_map:
834 return progress_display(self, type_map[target_type], self.name)
836 if len(self.inputs) == 0:
837 return Task.Task.old_display(self)
839 fname = self.inputs[0].bldpath(self.env)
840 if fname[0:3] == '../':
841 fname = fname[3:]
842 ext_loc = fname.rfind('.')
843 if ext_loc == -1:
844 return Task.Task.old_display(self)
845 ext = fname[ext_loc:]
847 ext_map = { '.idl' : 'Compiling IDL',
848 '.et' : 'Compiling ERRTABLE',
849 '.asn1': 'Compiling ASN1',
850 '.c' : 'Compiling' }
851 if ext in ext_map:
852 return progress_display(self, ext_map[ext], fname)
853 return Task.Task.old_display(self)
855 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
856 Task.TaskBase.classes['Task'].display = samba_display
859 @after('apply_link')
860 @feature('cshlib')
861 def apply_bundle_remove_dynamiclib_patch(self):
862 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
863 if not getattr(self,'vnum',None):
864 try:
865 self.env['LINKFLAGS'].remove('-dynamiclib')
866 self.env['LINKFLAGS'].remove('-single_module')
867 except ValueError:
868 pass