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 os, sys, re, shutil, fnmatch
5 from waflib import Build, Options, Task, Utils, TaskGen, Logs, Context, Errors
6 from waflib.Configure import conf
7 from waflib.Logs import debug
8 from samba_utils import SUBST_VARS_RECURSIVE
9 TaskGen.task_gen.apply_verif = Utils.nada
11 # bring in the other samba modules
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_perl import *
20 from samba_deps import *
21 from samba_bundled import *
22 from samba_third_party import *
25 import samba_conftests
36 # some systems have broken threading in python
37 if os.environ.get('WAF_NOTHREADS') == '1':
42 os.environ['PYTHONUNBUFFERED'] = '1'
44 if Context.HEXVERSION not in (0x2000800,):
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
50 Alternatively, please run ./configure and make as usual. That will
51 call the right version of waf.''')
55 def SAMBA_BUILD_ENV(conf):
56 '''create the samba build environment'''
57 conf.env.BUILD_DIRECTORY = conf.bldnode.abspath()
58 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, LIB_PATH))
59 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, LIB_PATH, "private"))
60 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, "modules"))
61 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, 'python/samba/dcerpc'))
62 # this allows all of the bin/shared and bin/python targets
63 # to be expressed in terms of build directory paths
64 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, 'default'))
65 for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python')]:
66 link_target = os.path.join(conf.env.BUILD_DIRECTORY, 'default/' + target)
67 if not os.path.lexists(link_target):
68 os.symlink('../' + source, link_target)
70 # get perl to put the blib files in the build directory
71 blib_bld = os.path.join(conf.env.BUILD_DIRECTORY, 'default/pidl/blib')
72 blib_src = os.path.join(conf.srcnode.abspath(), 'pidl/blib')
73 mkdir_p(blib_bld + '/man1')
74 mkdir_p(blib_bld + '/man3')
75 if os.path.islink(blib_src):
77 elif os.path.exists(blib_src):
78 shutil.rmtree(blib_src)
81 def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
82 '''add an init_function to the list for a subsystem'''
83 if init_function is None:
85 bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
86 cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
87 if not subsystem in cache:
89 cache[subsystem].append( { 'TARGET':target, 'INIT_FUNCTION':init_function } )
90 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
93 def generate_empty_file(task):
94 task.outputs[0].write('')
97 #################################################################
98 def SAMBA_LIBRARY(bld, libname, source,
103 public_headers_install=True,
104 private_headers=None,
112 external_library=False,
114 keep_underscore=False,
116 autoproto_extra_source='',
127 target_type='LIBRARY',
128 bundled_extension=False,
135 private_library=False,
136 grouping_library=False,
137 allow_undefined_symbols=False,
138 allow_warnings=False,
140 '''define a Samba library'''
142 if pyembed and bld.env['IS_EXTRA_PYTHON']:
143 public_headers = None
145 if private_library and public_headers:
146 raise Errors.WafError("private library '%s' must not have public header files" %
149 if LIB_MUST_BE_PRIVATE(bld, libname):
150 private_library = True
153 SET_TARGET_TYPE(bld, libname, 'DISABLED')
156 source = bld.EXPAND_VARIABLES(source, vars=vars)
158 source = bld.SUBDIR(subdir, source)
160 # remember empty libraries, so we can strip the dependencies
161 if ((source == '') or (source == [])):
162 if deps == '' and public_deps == '':
163 SET_TARGET_TYPE(bld, libname, 'EMPTY')
165 empty_c = libname + '.empty.c'
166 bld.SAMBA_GENERATOR('%s_empty_c' % libname,
167 rule=generate_empty_file,
171 if BUILTIN_LIBRARY(bld, libname):
174 obj_target = libname + '.objlist'
176 if group == 'libraries':
177 subsystem_group = 'main'
179 subsystem_group = group
181 # first create a target for building the object files for this library
182 # by separating in this way, we avoid recompiling the C files
183 # separately for the install library and the build library
184 bld.SAMBA_SUBSYSTEM(obj_target,
187 public_deps = public_deps,
189 public_headers = public_headers,
190 public_headers_install = public_headers_install,
191 private_headers= private_headers,
192 header_path = header_path,
194 cflags_end = cflags_end,
195 group = subsystem_group,
196 autoproto = autoproto,
197 autoproto_extra_source=autoproto_extra_source,
198 depends_on = depends_on,
199 hide_symbols = hide_symbols,
200 allow_warnings = allow_warnings,
203 local_include = local_include,
204 global_include = global_include)
206 if BUILTIN_LIBRARY(bld, libname):
209 if not SET_TARGET_TYPE(bld, libname, target_type):
212 # the library itself will depend on that object target
213 deps += ' ' + public_deps
215 deps.append(obj_target)
217 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
218 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
220 # we don't want any public libraries without version numbers
221 if (not private_library and target_type != 'PYTHON' and not realname):
222 if vnum is None and soname is None:
223 raise Errors.WafError("public library '%s' must have a vnum" %
226 raise Errors.WafError("public library '%s' must have pkg-config file" %
228 if public_headers is None and not bld.env['IS_EXTRA_PYTHON']:
229 raise Errors.WafError("public library '%s' must have header files" %
232 if bundled_name is not None:
234 elif target_type == 'PYTHON' or realname or not private_library:
236 bundled_name = libname
238 bundled_name = libname.replace('_', '-')
240 assert (private_library == True and realname is None)
241 if abi_directory or vnum or soname:
242 bundled_extension=True
243 bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-'),
244 bundled_extension, private_library)
246 ldflags = TO_LIST(ldflags)
247 if bld.env['ENABLE_RELRO'] is True:
248 ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
250 features = 'c cshlib symlink_lib install_lib'
254 features += ' pyembed'
257 features += ' abi_check'
259 if pyembed and bld.env['PYTHON_SO_ABI_FLAG']:
260 # For ABI checking, we don't care about the exact Python version.
261 # Replace the Python ABI tag (e.g. ".cpython-35m") by a generic ".py3"
262 abi_flag = bld.env['PYTHON_SO_ABI_FLAG']
263 replacement = '.py%s' % bld.env['PYTHON_VERSION'].split('.')[0]
264 version_libname = libname.replace(abi_flag, replacement)
266 version_libname = libname
269 if bld.env.HAVE_LD_VERSION_SCRIPT:
271 version = "%s_%s" % (Context.g_module.APPNAME, Context.g_module.VERSION)
273 version = "%s_%s" % (libname, vnum)
277 vscript = "%s.vscript" % libname
278 bld.ABI_VSCRIPT(version_libname, abi_directory, version, vscript,
280 fullname = apply_pattern(bundled_name, bld.env.cshlib_PATTERN)
281 fullpath = bld.path.find_or_declare(fullname)
282 vscriptpath = bld.path.find_or_declare(vscript)
284 raise Errors.WafError("unable to find fullpath for %s" % fullname)
286 raise Errors.WafError("unable to find vscript path for %s" % vscript)
287 bld.add_manual_dependency(fullpath, vscriptpath)
289 # also make the .inst file depend on the vscript
290 instname = apply_pattern(bundled_name + '.inst', bld.env.cshlib_PATTERN)
291 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
292 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
294 bld.SET_BUILD_GROUP(group)
298 target = bundled_name,
299 depends_on = depends_on,
300 samba_ldflags = ldflags,
302 samba_includes = includes,
303 version_script = vscript,
304 version_libname = version_libname,
305 local_include = local_include,
306 global_include = global_include,
310 samba_inst_path = install_path,
312 samba_realname = realname,
313 samba_install = install,
314 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
315 abi_match = abi_match,
316 private_library = private_library,
317 grouping_library=grouping_library,
318 allow_undefined_symbols=allow_undefined_symbols
321 if realname and not link_name:
322 link_name = 'shared/%s' % realname
325 if 'waflib.extras.compat15' in sys.modules:
326 link_name = 'default/' + link_name
327 t.link_name = link_name
329 if pc_files is not None and not private_library:
330 if pyembed and bld.env['IS_EXTRA_PYTHON']:
331 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum, extra_name=bld.env['PYTHON_SO_ABI_FLAG'])
333 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
335 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
336 bld.env['XSLTPROC_MANPAGES']):
337 bld.MANPAGES(manpages, install)
340 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
343 #################################################################
344 def SAMBA_BINARY(bld, binname, source,
348 private_headers=None,
356 use_global_deps=True,
369 '''define a Samba binary'''
372 SET_TARGET_TYPE(bld, binname, 'DISABLED')
375 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
378 features = 'c cprogram symlink_bin install_bin'
380 features += ' pyembed'
382 obj_target = binname + '.objlist'
384 source = bld.EXPAND_VARIABLES(source, vars=vars)
386 source = bld.SUBDIR(subdir, source)
387 source = unique_list(TO_LIST(source))
389 if group == 'binaries':
390 subsystem_group = 'main'
392 subsystem_group = group
394 # only specify PIE flags for binaries
396 pie_ldflags = TO_LIST(ldflags)
397 if bld.env['ENABLE_PIE'] is True:
398 pie_cflags += ' -fPIE'
399 pie_ldflags.extend(TO_LIST('-pie'))
400 if bld.env['ENABLE_RELRO'] is True:
401 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
403 # first create a target for building the object files for this binary
404 # by separating in this way, we avoid recompiling the C files
405 # separately for the install binary and the build binary
406 bld.SAMBA_SUBSYSTEM(obj_target,
411 cflags_end = cflags_end,
412 group = subsystem_group,
413 autoproto = autoproto,
414 subsystem_name = subsystem_name,
415 local_include = local_include,
416 global_include = global_include,
417 use_hostcc = use_hostcc,
419 use_global_deps= use_global_deps)
421 bld.SET_BUILD_GROUP(group)
423 # the binary itself will depend on that object target
425 deps.append(obj_target)
432 samba_includes = includes,
433 local_include = local_include,
434 global_include = global_include,
435 samba_modules = modules,
437 samba_subsystem= subsystem_name,
439 samba_inst_path= install_path,
440 samba_install = install,
441 samba_ldflags = pie_ldflags
444 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
445 bld.MANPAGES(manpages, install)
447 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
450 #################################################################
451 def SAMBA_MODULE(bld, modname, source,
456 module_init_name='samba_init_module',
458 autoproto_extra_source='',
461 internal_module=True,
469 allow_undefined_symbols=False,
470 allow_warnings=False,
473 '''define a Samba module.'''
475 bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname)
477 source = bld.EXPAND_VARIABLES(source, vars=vars)
479 source = bld.SUBDIR(subdir, source)
481 if internal_module or BUILTIN_LIBRARY(bld, modname):
482 # Do not create modules for disabled subsystems
483 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
485 bld.SAMBA_SUBSYSTEM(modname, source,
489 autoproto_extra_source=autoproto_extra_source,
491 cflags_end=cflags_end,
492 local_include=local_include,
493 global_include=global_include,
494 allow_warnings=allow_warnings,
497 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
501 SET_TARGET_TYPE(bld, modname, 'DISABLED')
504 # Do not create modules for disabled subsystems
505 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
509 deps += ' ' + subsystem
510 while realname.startswith("lib"+subsystem+"_"):
511 realname = realname[len("lib"+subsystem+"_"):]
512 while realname.startswith(subsystem+"_"):
513 realname = realname[len(subsystem+"_"):]
515 build_name = "%s_module_%s" % (subsystem, realname)
517 realname = bld.make_libname(realname)
518 while realname.startswith("lib"):
519 realname = realname[len("lib"):]
521 build_link_name = "modules/%s/%s" % (subsystem, realname)
524 cflags += " -D%s=%s" % (init_function, module_init_name)
526 bld.SAMBA_LIBRARY(modname,
531 cflags_end=cflags_end,
533 autoproto = autoproto,
534 local_include=local_include,
535 global_include=global_include,
537 bundled_name=build_name,
538 link_name=build_link_name,
539 install_path="${MODULESDIR}/%s" % subsystem,
542 allow_undefined_symbols=allow_undefined_symbols,
543 allow_warnings=allow_warnings,
548 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
551 #################################################################
552 def SAMBA_SUBSYSTEM(bld, modname, source,
557 public_headers_install=True,
558 private_headers=None,
563 init_function_sentinel=None,
565 autoproto_extra_source='',
568 local_include_first=True,
573 use_global_deps=True,
577 allow_warnings=False,
580 '''define a Samba subsystem'''
583 SET_TARGET_TYPE(bld, modname, 'DISABLED')
586 # remember empty subsystems, so we can strip the dependencies
587 if ((source == '') or (source == [])):
588 if deps == '' and public_deps == '':
589 SET_TARGET_TYPE(bld, modname, 'EMPTY')
591 empty_c = modname + '.empty.c'
592 bld.SAMBA_GENERATOR('%s_empty_c' % modname,
593 rule=generate_empty_file,
597 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
600 source = bld.EXPAND_VARIABLES(source, vars=vars)
602 source = bld.SUBDIR(subdir, source)
603 source = unique_list(TO_LIST(source))
605 deps += ' ' + public_deps
607 bld.SET_BUILD_GROUP(group)
613 features += ' pyembed'
619 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags,
620 allow_warnings=allow_warnings,
621 hide_symbols=hide_symbols),
622 depends_on = depends_on,
623 samba_deps = TO_LIST(deps),
624 samba_includes = includes,
625 local_include = local_include,
626 local_include_first = local_include_first,
627 global_include = global_include,
628 samba_subsystem= subsystem_name,
629 samba_use_hostcc = use_hostcc,
630 samba_use_global_deps = use_global_deps,
633 if cflags_end is not None:
634 t.samba_cflags.extend(TO_LIST(cflags_end))
636 if autoproto is not None:
637 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
638 if public_headers is not None:
639 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
640 public_headers_install=public_headers_install)
644 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
647 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
648 group='generators', enabled=True,
650 public_headers_install=True,
651 private_headers=None,
656 '''A generic source generator target'''
658 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
664 dep_vars.append('ruledeps')
665 dep_vars.append('SAMBA_GENERATOR_VARS')
667 bld.SET_BUILD_GROUP(group)
670 source=bld.EXPAND_VARIABLES(source, vars=vars),
672 shell=isinstance(rule, str),
676 samba_type='GENERATOR',
682 t.env.SAMBA_GENERATOR_VARS = vars
687 if public_headers is not None:
688 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
689 public_headers_install=public_headers_install)
691 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
696 def SETUP_BUILD_GROUPS(bld):
697 '''setup build groups used to ensure that the different build
698 phases happen consecutively'''
699 bld.p_ln = bld.srcnode # we do want to see all targets!
700 bld.env['USING_BUILD_GROUPS'] = True
701 bld.add_group('setup')
702 bld.add_group('build_compiler_source')
703 bld.add_group('vscripts')
704 bld.add_group('base_libraries')
705 bld.add_group('generators')
706 bld.add_group('compiler_prototypes')
707 bld.add_group('compiler_libraries')
708 bld.add_group('build_compilers')
709 bld.add_group('build_source')
710 bld.add_group('prototypes')
711 bld.add_group('headers')
712 bld.add_group('main')
713 bld.add_group('symbolcheck')
714 bld.add_group('syslibcheck')
715 bld.add_group('final')
716 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
719 def SET_BUILD_GROUP(bld, group):
720 '''set the current build group'''
721 if not 'USING_BUILD_GROUPS' in bld.env:
724 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
729 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
730 """use timestamps instead of file contents for deps
731 this currently doesn't work"""
732 def h_file(filename):
734 st = os.stat(filename)
735 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
737 m.update(str(st.st_mtime))
738 m.update(str(st.st_size))
741 Utils.h_file = h_file
744 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
745 '''used to copy scripts from the source tree into the build directory
746 for use by selftest'''
748 source = bld.path.ant_glob(pattern, flat=True)
750 bld.SET_BUILD_GROUP('build_source')
751 for s in TO_LIST(source):
753 if installname is not None:
755 target = os.path.join(installdir, iname)
756 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
758 link_src = os.path.normpath(os.path.join(bld.path.abspath(), s))
759 link_dst = os.path.join(tgtdir, os.path.basename(iname))
760 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
762 if os.path.exists(link_dst):
764 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
765 os.symlink(link_src, link_dst)
766 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
769 def copy_and_fix_python_path(task):
770 pattern='sys.path.insert(0, "bin/python")'
771 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
773 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
774 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
776 replacement="""sys.path.insert(0, "%s")
777 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
779 if task.env["PYTHON"][0] == "/":
780 replacement_shebang = "#!%s\n" % task.env["PYTHON"]
782 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"]
784 installed_location=task.outputs[0].bldpath(task.env)
785 source_file = open(task.inputs[0].srcpath(task.env))
786 installed_file = open(installed_location, 'w')
788 for line in source_file:
790 if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and
792 newline = replacement_shebang
793 elif pattern in line:
794 newline = line.replace(pattern, replacement)
795 installed_file.write(newline)
797 installed_file.close()
798 os.chmod(installed_location, 0o755)
801 def copy_and_fix_perl_path(task):
802 pattern='use lib "$RealBin/lib";'
805 if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]:
806 replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"]
808 if task.env["PERL"][0] == "/":
809 replacement_shebang = "#!%s\n" % task.env["PERL"]
811 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"]
813 installed_location=task.outputs[0].bldpath(task.env)
814 source_file = open(task.inputs[0].srcpath(task.env))
815 installed_file = open(installed_location, 'w')
817 for line in source_file:
819 if lineno == 0 and task.env["PERL_SPECIFIED"] == True and line[:2] == "#!":
820 newline = replacement_shebang
821 elif pattern in line:
822 newline = line.replace(pattern, replacement)
823 installed_file.write(newline)
825 installed_file.close()
826 os.chmod(installed_location, 0o755)
830 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
831 python_fixup=False, perl_fixup=False,
832 destname=None, base_name=None):
834 if not isinstance(file, str):
835 file = file.abspath()
836 destdir = bld.EXPAND_VARIABLES(destdir)
840 destname = os.path.basename(destname)
841 dest = os.path.join(destdir, destname)
843 # fix the path python will use to find Samba modules
844 inst_file = file + '.inst'
845 bld.SAMBA_GENERATOR('python_%s' % destname,
846 rule=copy_and_fix_python_path,
847 dep_vars=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
852 # fix the path perl will use to find Samba modules
853 inst_file = file + '.inst'
854 bld.SAMBA_GENERATOR('perl_%s' % destname,
855 rule=copy_and_fix_perl_path,
856 dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
861 file = os.path.join(base_name, file)
862 bld.install_as(dest, file, chmod=chmod)
865 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
866 python_fixup=False, perl_fixup=False,
867 destname=None, base_name=None):
868 '''install a set of files'''
869 for f in TO_LIST(files):
870 install_file(bld, destdir, f, chmod=chmod, flat=flat,
871 python_fixup=python_fixup, perl_fixup=perl_fixup,
872 destname=destname, base_name=base_name)
873 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
876 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
877 python_fixup=False, exclude=None, trim_path=None):
878 '''install a set of files matching a wildcard pattern'''
879 files=TO_LIST(bld.path.ant_glob(pattern, flat=True))
883 files2.append(os_path_relpath(f, trim_path))
888 if fnmatch.fnmatch(f, exclude):
890 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
891 python_fixup=python_fixup, base_name=trim_path)
892 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
894 def INSTALL_DIR(bld, path, chmod=0o755, env=None):
895 """Install a directory if it doesn't exist, always set permissions."""
900 destpath = bld.EXPAND_VARIABLES(path)
901 if Options.options.destdir:
902 destpath = os.path.join(Options.options.destdir, destpath.lstrip(os.sep))
904 if bld.is_install > 0:
905 if not os.path.isdir(destpath):
907 Logs.info('* create %s', destpath)
908 os.makedirs(destpath)
909 os.chmod(destpath, chmod)
911 if not os.path.isdir(destpath):
912 raise Errors.WafError("Cannot create the folder '%s' (error: %s)" % (path, e))
913 Build.BuildContext.INSTALL_DIR = INSTALL_DIR
915 def INSTALL_DIRS(bld, destdir, dirs, chmod=0o755, env=None):
916 '''install a set of directories'''
917 destdir = bld.EXPAND_VARIABLES(destdir)
918 dirs = bld.EXPAND_VARIABLES(dirs)
919 for d in TO_LIST(dirs):
920 INSTALL_DIR(bld, os.path.join(destdir, d), chmod, env)
921 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
924 def MANPAGES(bld, manpages, install):
925 '''build and install manual pages'''
926 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
927 for m in manpages.split():
929 bld.SAMBA_GENERATOR(m,
933 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
936 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
937 Build.BuildContext.MANPAGES = MANPAGES
939 def SAMBAMANPAGES(bld, manpages, extra_source=None):
940 '''build and install manual pages'''
941 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
942 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
943 bld.env.SAMBA_CATALOG = bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
944 bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.env.SAMBA_CATALOG
946 for m in manpages.split():
948 if extra_source is not None:
949 source = [source, extra_source]
950 bld.SAMBA_GENERATOR(m,
954 dep_vars=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
955 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
956 export XML_CATALOG_FILES
957 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
958 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
960 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
961 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
965 def apply_bundle_remove_dynamiclib_patch(self):
966 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
967 if not getattr(self,'vnum',None):
969 self.env['LINKFLAGS'].remove('-dynamiclib')
970 self.env['LINKFLAGS'].remove('-single_module')