waf: build substituted public headers in build tree
[kai/samba.git] / buildtools / wafsamba / wafsamba.py
1 # a waf tool to add autoconf-like macros to the configure section
2 # and for SAMBA_ macros for building libraries, binaries etc
3
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
9
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
35 # some systems have broken threading in python
36 if os.environ.get('WAF_NOTHREADS') == '1':
37     import nothreads
38
39 LIB_PATH="shared"
40
41 os.environ['PYTHONUNBUFFERED'] = '1'
42
43
44 if Constants.HEXVERSION < 0x105019:
45     Logs.error('''
46 Please use the version of waf that comes with Samba, not
47 a system installed version. See http://wiki.samba.org/index.php/Waf
48 for details.
49
50 Alternatively, please run ./configure and make as usual. That will
51 call the right version of waf.''')
52     sys.exit(1)
53
54
55 @conf
56 def SAMBA_BUILD_ENV(conf):
57     '''create the samba build environment'''
58     conf.env.BUILD_DIRECTORY = conf.blddir
59     mkdir_p(os.path.join(conf.blddir, LIB_PATH))
60     mkdir_p(os.path.join(conf.blddir, LIB_PATH, "private"))
61     mkdir_p(os.path.join(conf.blddir, "modules"))
62     mkdir_p(os.path.join(conf.blddir, 'python/samba/dcerpc'))
63     # this allows all of the bin/shared and bin/python targets
64     # to be expressed in terms of build directory paths
65     mkdir_p(os.path.join(conf.blddir, 'default'))
66     for p in ['python','shared', 'modules']:
67         link_target = os.path.join(conf.blddir, 'default/' + p)
68         if not os.path.lexists(link_target):
69             os.symlink('../' + p, link_target)
70
71     # get perl to put the blib files in the build directory
72     blib_bld = os.path.join(conf.blddir, 'default/pidl/blib')
73     blib_src = os.path.join(conf.srcdir, 'pidl/blib')
74     mkdir_p(blib_bld + '/man1')
75     mkdir_p(blib_bld + '/man3')
76     if os.path.islink(blib_src):
77         os.unlink(blib_src)
78     elif os.path.exists(blib_src):
79         shutil.rmtree(blib_src)
80
81
82 def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
83     '''add an init_function to the list for a subsystem'''
84     if init_function is None:
85         return
86     bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
87     cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
88     if not subsystem in cache:
89         cache[subsystem] = []
90     cache[subsystem].append( { 'TARGET':target, 'INIT_FUNCTION':init_function } )
91 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
92
93
94
95 #################################################################
96 def SAMBA_LIBRARY(bld, libname, source,
97                   deps='',
98                   public_deps='',
99                   includes='',
100                   public_headers=None,
101                   header_path=None,
102                   pc_files=None,
103                   vnum=None,
104                   soname=None,
105                   cflags='',
106                   ldflags='',
107                   external_library=False,
108                   realname=None,
109                   autoproto=None,
110                   group='libraries',
111                   depends_on='',
112                   local_include=True,
113                   global_include=True,
114                   vars=None,
115                   subdir=None,
116                   install_path=None,
117                   install=True,
118                   pyembed=False,
119                   pyext=False,
120                   target_type='LIBRARY',
121                   bundled_extension=True,
122                   link_name=None,
123                   abi_directory=None,
124                   abi_match=None,
125                   hide_symbols=False,
126                   manpages=None,
127                   private_library=False,
128                   grouping_library=False,
129                   allow_undefined_symbols=False,
130                   enabled=True):
131     '''define a Samba library'''
132
133     if not enabled:
134         SET_TARGET_TYPE(bld, libname, 'DISABLED')
135         return
136
137     source = bld.EXPAND_VARIABLES(source, vars=vars)
138     if subdir:
139         source = bld.SUBDIR(subdir, source)
140
141     # remember empty libraries, so we can strip the dependencies
142     if ((source == '') or (source == [])) and deps == '' and public_deps == '':
143         SET_TARGET_TYPE(bld, libname, 'EMPTY')
144         return
145
146     if BUILTIN_LIBRARY(bld, libname):
147         obj_target = libname
148     else:
149         obj_target = libname + '.objlist'
150
151     if group == 'libraries':
152         subsystem_group = 'main'
153     else:
154         subsystem_group = group
155
156     # first create a target for building the object files for this library
157     # by separating in this way, we avoid recompiling the C files
158     # separately for the install library and the build library
159     bld.SAMBA_SUBSYSTEM(obj_target,
160                         source         = source,
161                         deps           = deps,
162                         public_deps    = public_deps,
163                         includes       = includes,
164                         public_headers = public_headers,
165                         header_path    = header_path,
166                         cflags         = cflags,
167                         group          = subsystem_group,
168                         autoproto      = autoproto,
169                         depends_on     = depends_on,
170                         hide_symbols   = hide_symbols,
171                         pyext          = pyext or (target_type == "PYTHON"),
172                         local_include  = local_include,
173                         global_include = global_include)
174
175     if BUILTIN_LIBRARY(bld, libname):
176         return
177
178     if not SET_TARGET_TYPE(bld, libname, target_type):
179         return
180
181     # the library itself will depend on that object target
182     deps += ' ' + public_deps
183     deps = TO_LIST(deps)
184     deps.append(obj_target)
185
186     realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
187     link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
188
189     # we don't want any public libraries without version numbers
190     if not private_library and vnum is None and soname is None and target_type != 'PYTHON' and not realname:
191         raise Utils.WafError("public library '%s' must have a vnum" % libname)
192
193     if target_type == 'PYTHON' or realname or not private_library:
194         bundled_name = libname.replace('_', '-')
195     else:
196         bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library)
197
198     ldflags = TO_LIST(ldflags)
199
200     features = 'cc cshlib symlink_lib install_lib'
201     if target_type == 'PYTHON':
202         features += ' pyext'
203     if pyext or pyembed:
204         # this is quite strange. we should add pyext feature for pyext
205         # but that breaks the build. This may be a bug in the waf python tool
206         features += ' pyembed'
207
208     if abi_directory:
209         features += ' abi_check'
210
211     vscript = None
212     if bld.env.HAVE_LD_VERSION_SCRIPT:
213         if private_library:
214             version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
215         elif vnum:
216             version = "%s_%s" % (libname, vnum)
217         else:
218             version = None
219         if version:
220             vscript = "%s.vscript" % libname
221             bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
222                             abi_match)
223             fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
224             fullpath = bld.path.find_or_declare(fullname)
225             vscriptpath = bld.path.find_or_declare(vscript)
226             if not fullpath:
227                 raise Utils.WafError("unable to find fullpath for %s" % fullname)
228             if not vscriptpath:
229                 raise Utils.WafError("unable to find vscript path for %s" % vscript)
230             bld.add_manual_dependency(fullpath, vscriptpath)
231             if Options.is_install:
232                 # also make the .inst file depend on the vscript
233                 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
234                 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
235             vscript = os.path.join(bld.path.abspath(bld.env), vscript)
236
237     bld.SET_BUILD_GROUP(group)
238     t = bld(
239         features        = features,
240         source          = [],
241         target          = bundled_name,
242         depends_on      = depends_on,
243         samba_ldflags   = ldflags,
244         samba_deps      = deps,
245         samba_includes  = includes,
246         version_script  = vscript,
247         local_include   = local_include,
248         global_include  = global_include,
249         vnum            = vnum,
250         soname          = soname,
251         install_path    = None,
252         samba_inst_path = install_path,
253         name            = libname,
254         samba_realname  = realname,
255         samba_install   = install,
256         abi_directory   = "%s/%s" % (bld.path.abspath(), abi_directory),
257         abi_match       = abi_match,
258         private_library = private_library,
259         grouping_library=grouping_library,
260         allow_undefined_symbols=allow_undefined_symbols
261         )
262
263     if realname and not link_name:
264         link_name = 'shared/%s' % realname
265
266     if link_name:
267         t.link_name = link_name
268
269     if pc_files is not None:
270         bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
271
272     if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
273         bld.MANPAGES(manpages)
274
275
276 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
277
278
279 #################################################################
280 def SAMBA_BINARY(bld, binname, source,
281                  deps='',
282                  includes='',
283                  public_headers=None,
284                  header_path=None,
285                  modules=None,
286                  ldflags=None,
287                  cflags='',
288                  autoproto=None,
289                  use_hostcc=False,
290                  use_global_deps=True,
291                  compiler=None,
292                  group='binaries',
293                  manpages=None,
294                  local_include=True,
295                  global_include=True,
296                  subsystem_name=None,
297                  pyembed=False,
298                  vars=None,
299                  subdir=None,
300                  install=True,
301                  install_path=None,
302                  enabled=True):
303     '''define a Samba binary'''
304
305     if not enabled:
306         SET_TARGET_TYPE(bld, binname, 'DISABLED')
307         return
308
309     if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
310         return
311
312     features = 'cc cprogram symlink_bin install_bin'
313     if pyembed:
314         features += ' pyembed'
315
316     obj_target = binname + '.objlist'
317
318     source = bld.EXPAND_VARIABLES(source, vars=vars)
319     if subdir:
320         source = bld.SUBDIR(subdir, source)
321     source = unique_list(TO_LIST(source))
322
323     if group == 'binaries':
324         subsystem_group = 'main'
325     else:
326         subsystem_group = group
327
328     # first create a target for building the object files for this binary
329     # by separating in this way, we avoid recompiling the C files
330     # separately for the install binary and the build binary
331     bld.SAMBA_SUBSYSTEM(obj_target,
332                         source         = source,
333                         deps           = deps,
334                         includes       = includes,
335                         cflags         = cflags,
336                         group          = subsystem_group,
337                         autoproto      = autoproto,
338                         subsystem_name = subsystem_name,
339                         local_include  = local_include,
340                         global_include = global_include,
341                         use_hostcc     = use_hostcc,
342                         pyext          = pyembed,
343                         use_global_deps= use_global_deps)
344
345     bld.SET_BUILD_GROUP(group)
346
347     # the binary itself will depend on that object target
348     deps = TO_LIST(deps)
349     deps.append(obj_target)
350
351     t = bld(
352         features       = features,
353         source         = [],
354         target         = binname,
355         samba_deps     = deps,
356         samba_includes = includes,
357         local_include  = local_include,
358         global_include = global_include,
359         samba_modules  = modules,
360         top            = True,
361         samba_subsystem= subsystem_name,
362         install_path   = None,
363         samba_inst_path= install_path,
364         samba_install  = install,
365         samba_ldflags  = TO_LIST(ldflags)
366         )
367
368     if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
369         bld.MANPAGES(manpages)
370
371 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
372
373
374 #################################################################
375 def SAMBA_MODULE(bld, modname, source,
376                  deps='',
377                  includes='',
378                  subsystem=None,
379                  init_function=None,
380                  module_init_name='samba_init_module',
381                  autoproto=None,
382                  autoproto_extra_source='',
383                  cflags='',
384                  internal_module=True,
385                  local_include=True,
386                  global_include=True,
387                  vars=None,
388                  subdir=None,
389                  enabled=True,
390                  pyembed=False,
391                  allow_undefined_symbols=False
392                  ):
393     '''define a Samba module.'''
394
395     source = bld.EXPAND_VARIABLES(source, vars=vars)
396     if subdir:
397         source = bld.SUBDIR(subdir, source)
398
399     if internal_module or BUILTIN_LIBRARY(bld, modname):
400         bld.SAMBA_SUBSYSTEM(modname, source,
401                     deps=deps,
402                     includes=includes,
403                     autoproto=autoproto,
404                     autoproto_extra_source=autoproto_extra_source,
405                     cflags=cflags,
406                     local_include=local_include,
407                     global_include=global_include,
408                     enabled=enabled)
409
410         bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
411         return
412
413     if not enabled:
414         SET_TARGET_TYPE(bld, modname, 'DISABLED')
415         return
416
417     obj_target = modname + '.objlist'
418
419     realname = modname
420     if subsystem is not None:
421         deps += ' ' + subsystem
422         while realname.startswith("lib"+subsystem+"_"):
423             realname = realname[len("lib"+subsystem+"_"):]
424         while realname.startswith(subsystem+"_"):
425             realname = realname[len(subsystem+"_"):]
426
427     realname = bld.make_libname(realname)
428     while realname.startswith("lib"):
429         realname = realname[len("lib"):]
430
431     build_link_name = "modules/%s/%s" % (subsystem, realname)
432
433     if init_function:
434         cflags += " -D%s=%s" % (init_function, module_init_name)
435
436     bld.SAMBA_LIBRARY(modname,
437                       source,
438                       deps=deps,
439                       includes=includes,
440                       cflags=cflags,
441                       realname = realname,
442                       autoproto = autoproto,
443                       local_include=local_include,
444                       global_include=global_include,
445                       vars=vars,
446                       link_name=build_link_name,
447                       install_path="${MODULESDIR}/%s" % subsystem,
448                       pyembed=pyembed,
449                       allow_undefined_symbols=allow_undefined_symbols
450                       )
451
452
453 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
454
455
456 #################################################################
457 def SAMBA_SUBSYSTEM(bld, modname, source,
458                     deps='',
459                     public_deps='',
460                     includes='',
461                     public_headers=None,
462                     header_path=None,
463                     cflags='',
464                     cflags_end=None,
465                     group='main',
466                     init_function_sentinal=None,
467                     autoproto=None,
468                     autoproto_extra_source='',
469                     depends_on='',
470                     local_include=True,
471                     local_include_first=True,
472                     global_include=True,
473                     subsystem_name=None,
474                     enabled=True,
475                     use_hostcc=False,
476                     use_global_deps=True,
477                     vars=None,
478                     subdir=None,
479                     hide_symbols=False,
480                     pyext=False):
481     '''define a Samba subsystem'''
482
483     if not enabled:
484         SET_TARGET_TYPE(bld, modname, 'DISABLED')
485         return
486
487     # remember empty subsystems, so we can strip the dependencies
488     if ((source == '') or (source == [])) and deps == '' and public_deps == '':
489         SET_TARGET_TYPE(bld, modname, 'EMPTY')
490         return
491
492     if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
493         return
494
495     source = bld.EXPAND_VARIABLES(source, vars=vars)
496     if subdir:
497         source = bld.SUBDIR(subdir, source)
498     source = unique_list(TO_LIST(source))
499
500     deps += ' ' + public_deps
501
502     bld.SET_BUILD_GROUP(group)
503
504     features = 'cc'
505     if pyext:
506         features += ' pyext'
507
508     t = bld(
509         features       = features,
510         source         = source,
511         target         = modname,
512         samba_cflags   = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols),
513         depends_on     = depends_on,
514         samba_deps     = TO_LIST(deps),
515         samba_includes = includes,
516         local_include  = local_include,
517         local_include_first  = local_include_first,
518         global_include = global_include,
519         samba_subsystem= subsystem_name,
520         samba_use_hostcc = use_hostcc,
521         samba_use_global_deps = use_global_deps
522         )
523
524     if cflags_end is not None:
525         t.samba_cflags.extend(TO_LIST(cflags_end))
526
527     if autoproto is not None:
528         bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
529     if public_headers is not None:
530         bld.PUBLIC_HEADERS(public_headers, header_path=header_path)
531     return t
532
533
534 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
535
536
537 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
538                     group='generators', enabled=True,
539                     public_headers=None,
540                     public_headers_install=True,
541                     header_path=None,
542                     vars=None,
543                     always=False):
544     '''A generic source generator target'''
545
546     if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
547         return
548
549     if not enabled:
550         return
551
552     bld.SET_BUILD_GROUP(group)
553     t = bld(
554         rule=rule,
555         source=bld.EXPAND_VARIABLES(source, vars=vars),
556         target=target,
557         shell=isinstance(rule, str),
558         on_results=True,
559         before='cc',
560         ext_out='.c',
561         samba_type='GENERATOR',
562         dep_vars = [rule] + (vars or []),
563         name=name)
564
565     if always:
566         t.always = True
567
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
572 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
573
574
575
576 @runonce
577 def SETUP_BUILD_GROUPS(bld):
578     '''setup build groups used to ensure that the different build
579     phases happen consecutively'''
580     bld.p_ln = bld.srcnode # we do want to see all targets!
581     bld.env['USING_BUILD_GROUPS'] = True
582     bld.add_group('setup')
583     bld.add_group('build_compiler_source')
584     bld.add_group('vscripts')
585     bld.add_group('base_libraries')
586     bld.add_group('generators')
587     bld.add_group('compiler_prototypes')
588     bld.add_group('compiler_libraries')
589     bld.add_group('build_compilers')
590     bld.add_group('build_source')
591     bld.add_group('prototypes')
592     bld.add_group('main')
593     bld.add_group('symbolcheck')
594     bld.add_group('libraries')
595     bld.add_group('binaries')
596     bld.add_group('syslibcheck')
597     bld.add_group('final')
598 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
599
600
601 def SET_BUILD_GROUP(bld, group):
602     '''set the current build group'''
603     if not 'USING_BUILD_GROUPS' in bld.env:
604         return
605     bld.set_group(group)
606 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
607
608
609
610 @conf
611 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
612     """use timestamps instead of file contents for deps
613     this currently doesn't work"""
614     def h_file(filename):
615         import stat
616         st = os.stat(filename)
617         if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
618         m = Utils.md5()
619         m.update(str(st.st_mtime))
620         m.update(str(st.st_size))
621         m.update(filename)
622         return m.digest()
623     Utils.h_file = h_file
624
625
626
627 t = Task.simple_task_type('copy_script', 'rm -f "${LINK_TARGET}" && ln -s "${SRC[0].abspath(env)}" ${LINK_TARGET}',
628                           shell=True, color='PINK', ext_in='.bin')
629 t.quiet = True
630
631 @feature('copy_script')
632 @before('apply_link')
633 def copy_script(self):
634     tsk = self.create_task('copy_script', self.allnodes[0])
635     tsk.env.TARGET = self.target
636
637 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
638     '''used to copy scripts from the source tree into the build directory
639        for use by selftest'''
640
641     source = bld.path.ant_glob(pattern)
642
643     bld.SET_BUILD_GROUP('build_source')
644     for s in TO_LIST(source):
645         iname = s
646         if installname != None:
647             iname = installname
648         target = os.path.join(installdir, iname)
649         tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
650         mkdir_p(tgtdir)
651         t = bld(features='copy_script',
652                 source       = s,
653                 target       = target,
654                 always       = True,
655                 install_path = None)
656         t.env.LINK_TARGET = target
657
658 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
659
660 def copy_and_fix_python_path(task):
661     pattern='sys.path.insert(0, "bin/python")'
662     if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
663         replacement = ""
664     elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
665         replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
666     else:
667         replacement="""sys.path.insert(0, "%s")
668 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
669
670     installed_location=task.outputs[0].bldpath(task.env)
671     source_file = open(task.inputs[0].srcpath(task.env))
672     installed_file = open(installed_location, 'w')
673     for line in source_file:
674         newline = line
675         if pattern in line:
676             newline = line.replace(pattern, replacement)
677         installed_file.write(newline)
678     installed_file.close()
679     os.chmod(installed_location, 0755)
680     return 0
681
682
683 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
684                  python_fixup=False, destname=None, base_name=None):
685     '''install a file'''
686     destdir = bld.EXPAND_VARIABLES(destdir)
687     if not destname:
688         destname = file
689         if flat:
690             destname = os.path.basename(destname)
691     dest = os.path.join(destdir, destname)
692     if python_fixup:
693         # fixup the python path it will use to find Samba modules
694         inst_file = file + '.inst'
695         bld.SAMBA_GENERATOR('python_%s' % destname,
696                             rule=copy_and_fix_python_path,
697                             source=file,
698                             target=inst_file)
699         file = inst_file
700     if base_name:
701         file = os.path.join(base_name, file)
702     bld.install_as(dest, file, chmod=chmod)
703
704
705 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
706                   python_fixup=False, destname=None, base_name=None):
707     '''install a set of files'''
708     for f in TO_LIST(files):
709         install_file(bld, destdir, f, chmod=chmod, flat=flat,
710                      python_fixup=python_fixup, destname=destname,
711                      base_name=base_name)
712 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
713
714
715 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
716                      python_fixup=False, exclude=None, trim_path=None):
717     '''install a set of files matching a wildcard pattern'''
718     files=TO_LIST(bld.path.ant_glob(pattern))
719     if trim_path:
720         files2 = []
721         for f in files:
722             files2.append(os_path_relpath(f, trim_path))
723         files = files2
724
725     if exclude:
726         for f in files[:]:
727             if fnmatch.fnmatch(f, exclude):
728                 files.remove(f)
729     INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
730                   python_fixup=python_fixup, base_name=trim_path)
731 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
732
733
734 def INSTALL_DIRS(bld, destdir, dirs):
735     '''install a set of directories'''
736     destdir = bld.EXPAND_VARIABLES(destdir)
737     dirs = bld.EXPAND_VARIABLES(dirs)
738     for d in TO_LIST(dirs):
739         bld.install_dir(os.path.join(destdir, d))
740 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
741
742
743 def MANPAGES(bld, manpages):
744     '''build and install manual pages'''
745     bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
746     for m in manpages.split():
747         source = m + '.xml'
748         bld.SAMBA_GENERATOR(m,
749                             source=source,
750                             target=m,
751                             group='final',
752                             rule='${XSLTPROC} -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
753                             )
754         bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
755 Build.BuildContext.MANPAGES = MANPAGES
756
757
758 #############################################################
759 # give a nicer display when building different types of files
760 def progress_display(self, msg, fname):
761     col1 = Logs.colors(self.color)
762     col2 = Logs.colors.NORMAL
763     total = self.position[1]
764     n = len(str(total))
765     fs = '[%%%dd/%%%dd] %s %%s%%s%%s\n' % (n, n, msg)
766     return fs % (self.position[0], self.position[1], col1, fname, col2)
767
768 def link_display(self):
769     if Options.options.progress_bar != 0:
770         return Task.Task.old_display(self)
771     fname = self.outputs[0].bldpath(self.env)
772     return progress_display(self, 'Linking', fname)
773 Task.TaskBase.classes['cc_link'].display = link_display
774
775 def samba_display(self):
776     if Options.options.progress_bar != 0:
777         return Task.Task.old_display(self)
778
779     targets    = LOCAL_CACHE(self, 'TARGET_TYPE')
780     if self.name in targets:
781         target_type = targets[self.name]
782         type_map = { 'GENERATOR' : 'Generating',
783                      'PROTOTYPE' : 'Generating'
784                      }
785         if target_type in type_map:
786             return progress_display(self, type_map[target_type], self.name)
787
788     if len(self.inputs) == 0:
789         return Task.Task.old_display(self)
790
791     fname = self.inputs[0].bldpath(self.env)
792     if fname[0:3] == '../':
793         fname = fname[3:]
794     ext_loc = fname.rfind('.')
795     if ext_loc == -1:
796         return Task.Task.old_display(self)
797     ext = fname[ext_loc:]
798
799     ext_map = { '.idl' : 'Compiling IDL',
800                 '.et'  : 'Compiling ERRTABLE',
801                 '.asn1': 'Compiling ASN1',
802                 '.c'   : 'Compiling' }
803     if ext in ext_map:
804         return progress_display(self, ext_map[ext], fname)
805     return Task.Task.old_display(self)
806
807 Task.TaskBase.classes['Task'].old_display = Task.TaskBase.classes['Task'].display
808 Task.TaskBase.classes['Task'].display = samba_display
809
810
811 @after('apply_link')
812 @feature('cshlib')
813 def apply_bundle_remove_dynamiclib_patch(self):
814     if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
815         if not getattr(self,'vnum',None):
816             try:
817                 self.env['LINKFLAGS'].remove('-dynamiclib')
818                 self.env['LINKFLAGS'].remove('-single_module')
819             except ValueError:
820                 pass