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