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
38 os.environ['PYTHONUNBUFFERED'] = '1'
40 if Context.HEXVERSION not in (0x2000800,):
42 Please use the version of waf that comes with Samba, not
43 a system installed version. See http://wiki.samba.org/index.php/Waf
46 Alternatively, please run ./configure and make as usual. That will
47 call the right version of waf.''')
51 def SAMBA_BUILD_ENV(conf):
52 '''create the samba build environment'''
53 conf.env.BUILD_DIRECTORY = conf.bldnode.abspath()
54 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, LIB_PATH))
55 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, LIB_PATH, "private"))
56 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, "modules"))
57 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, 'python/samba/dcerpc'))
58 # this allows all of the bin/shared and bin/python targets
59 # to be expressed in terms of build directory paths
60 mkdir_p(os.path.join(conf.env.BUILD_DIRECTORY, 'default'))
61 for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python')]:
62 link_target = os.path.join(conf.env.BUILD_DIRECTORY, 'default/' + target)
63 if not os.path.lexists(link_target):
64 os.symlink('../' + source, link_target)
66 # get perl to put the blib files in the build directory
67 blib_bld = os.path.join(conf.env.BUILD_DIRECTORY, 'default/pidl/blib')
68 blib_src = os.path.join(conf.srcnode.abspath(), 'pidl/blib')
69 mkdir_p(blib_bld + '/man1')
70 mkdir_p(blib_bld + '/man3')
71 if os.path.islink(blib_src):
73 elif os.path.exists(blib_src):
74 shutil.rmtree(blib_src)
77 def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
78 '''add an init_function to the list for a subsystem'''
79 if init_function is None:
81 bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
82 cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
83 if not subsystem in cache:
85 cache[subsystem].append( { 'TARGET':target, 'INIT_FUNCTION':init_function } )
86 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
89 def generate_empty_file(task):
90 task.outputs[0].write('')
93 #################################################################
94 def SAMBA_LIBRARY(bld, libname, source,
99 public_headers_install=True,
100 private_headers=None,
108 external_library=False,
110 keep_underscore=False,
112 autoproto_extra_source='',
123 target_type='LIBRARY',
124 bundled_extension=False,
131 private_library=False,
132 grouping_library=False,
133 allow_undefined_symbols=False,
134 allow_warnings=False,
136 '''define a Samba library'''
138 if pyembed and bld.env['IS_EXTRA_PYTHON']:
139 public_headers = None
141 if private_library and public_headers:
142 raise Errors.WafError("private library '%s' must not have public header files" %
145 if LIB_MUST_BE_PRIVATE(bld, libname):
146 private_library = True
149 SET_TARGET_TYPE(bld, libname, 'DISABLED')
152 source = bld.EXPAND_VARIABLES(source, vars=vars)
154 source = bld.SUBDIR(subdir, source)
156 # remember empty libraries, so we can strip the dependencies
157 if ((source == '') or (source == [])):
158 if deps == '' and public_deps == '':
159 SET_TARGET_TYPE(bld, libname, 'EMPTY')
161 empty_c = libname + '.empty.c'
162 bld.SAMBA_GENERATOR('%s_empty_c' % libname,
163 rule=generate_empty_file,
167 if BUILTIN_LIBRARY(bld, libname):
170 obj_target = libname + '.objlist'
172 if group == 'libraries':
173 subsystem_group = 'main'
175 subsystem_group = group
177 # first create a target for building the object files for this library
178 # by separating in this way, we avoid recompiling the C files
179 # separately for the install library and the build library
180 bld.SAMBA_SUBSYSTEM(obj_target,
183 public_deps = public_deps,
185 public_headers = public_headers,
186 public_headers_install = public_headers_install,
187 private_headers= private_headers,
188 header_path = header_path,
190 cflags_end = cflags_end,
191 group = subsystem_group,
192 autoproto = autoproto,
193 autoproto_extra_source=autoproto_extra_source,
194 depends_on = depends_on,
195 hide_symbols = hide_symbols,
196 allow_warnings = allow_warnings,
199 local_include = local_include,
200 global_include = global_include)
202 if BUILTIN_LIBRARY(bld, libname):
205 if not SET_TARGET_TYPE(bld, libname, target_type):
208 # the library itself will depend on that object target
209 deps += ' ' + public_deps
211 deps.append(obj_target)
213 realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
214 link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
216 # we don't want any public libraries without version numbers
217 if (not private_library and target_type != 'PYTHON' and not realname):
218 if vnum is None and soname is None:
219 raise Errors.WafError("public library '%s' must have a vnum" %
222 raise Errors.WafError("public library '%s' must have pkg-config file" %
224 if public_headers is None and not bld.env['IS_EXTRA_PYTHON']:
225 raise Errors.WafError("public library '%s' must have header files" %
228 if bundled_name is not None:
230 elif target_type == 'PYTHON' or realname or not private_library:
232 bundled_name = libname
234 bundled_name = libname.replace('_', '-')
236 assert (private_library == True and realname is None)
237 if abi_directory or vnum or soname:
238 bundled_extension=True
239 bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-'),
240 bundled_extension, private_library)
242 ldflags = TO_LIST(ldflags)
243 if bld.env['ENABLE_RELRO'] is True:
244 ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
246 features = 'c cshlib symlink_lib install_lib'
250 features += ' pyembed'
253 features += ' abi_check'
255 if pyembed and bld.env['PYTHON_SO_ABI_FLAG']:
256 # For ABI checking, we don't care about the exact Python version.
257 # Replace the Python ABI tag (e.g. ".cpython-35m") by a generic ".py3"
258 abi_flag = bld.env['PYTHON_SO_ABI_FLAG']
259 replacement = '.py%s' % bld.env['PYTHON_VERSION'].split('.')[0]
260 version_libname = libname.replace(abi_flag, replacement)
262 version_libname = libname
265 if bld.env.HAVE_LD_VERSION_SCRIPT:
267 version = "%s_%s" % (Context.g_module.APPNAME, Context.g_module.VERSION)
269 version = "%s_%s" % (libname, vnum)
273 vscript = "%s.vscript" % libname
274 bld.ABI_VSCRIPT(version_libname, abi_directory, version, vscript,
276 fullname = apply_pattern(bundled_name, bld.env.cshlib_PATTERN)
277 fullpath = bld.path.find_or_declare(fullname)
278 vscriptpath = bld.path.find_or_declare(vscript)
280 raise Errors.WafError("unable to find fullpath for %s" % fullname)
282 raise Errors.WafError("unable to find vscript path for %s" % vscript)
283 bld.add_manual_dependency(fullpath, vscriptpath)
285 # also make the .inst file depend on the vscript
286 instname = apply_pattern(bundled_name + '.inst', bld.env.cshlib_PATTERN)
287 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
288 vscript = os.path.join(bld.path.abspath(bld.env), vscript)
290 bld.SET_BUILD_GROUP(group)
294 target = bundled_name,
295 depends_on = depends_on,
296 samba_ldflags = ldflags,
298 samba_includes = includes,
299 version_script = vscript,
300 version_libname = version_libname,
301 local_include = local_include,
302 global_include = global_include,
306 samba_inst_path = install_path,
308 samba_realname = realname,
309 samba_install = install,
310 abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory),
311 abi_match = abi_match,
312 private_library = private_library,
313 grouping_library=grouping_library,
314 allow_undefined_symbols=allow_undefined_symbols
317 if realname and not link_name:
318 link_name = 'shared/%s' % realname
321 if 'waflib.extras.compat15' in sys.modules:
322 link_name = 'default/' + link_name
323 t.link_name = link_name
325 if pc_files is not None and not private_library:
327 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum, extra_name=bld.env['PYTHON_SO_ABI_FLAG'])
329 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
331 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
332 bld.env['XSLTPROC_MANPAGES']):
333 bld.MANPAGES(manpages, install)
336 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
339 #################################################################
340 def SAMBA_BINARY(bld, binname, source,
344 private_headers=None,
352 use_global_deps=True,
365 '''define a Samba binary'''
368 SET_TARGET_TYPE(bld, binname, 'DISABLED')
371 if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
374 features = 'c cprogram symlink_bin install_bin'
376 features += ' pyembed'
378 obj_target = binname + '.objlist'
380 source = bld.EXPAND_VARIABLES(source, vars=vars)
382 source = bld.SUBDIR(subdir, source)
383 source = unique_list(TO_LIST(source))
385 if group == 'binaries':
386 subsystem_group = 'main'
388 subsystem_group = group
390 # only specify PIE flags for binaries
392 pie_ldflags = TO_LIST(ldflags)
393 if bld.env['ENABLE_PIE'] is True:
394 pie_cflags += ' -fPIE'
395 pie_ldflags.extend(TO_LIST('-pie'))
396 if bld.env['ENABLE_RELRO'] is True:
397 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
399 # first create a target for building the object files for this binary
400 # by separating in this way, we avoid recompiling the C files
401 # separately for the install binary and the build binary
402 bld.SAMBA_SUBSYSTEM(obj_target,
407 cflags_end = cflags_end,
408 group = subsystem_group,
409 autoproto = autoproto,
410 subsystem_name = subsystem_name,
411 local_include = local_include,
412 global_include = global_include,
413 use_hostcc = use_hostcc,
415 use_global_deps= use_global_deps)
417 bld.SET_BUILD_GROUP(group)
419 # the binary itself will depend on that object target
421 deps.append(obj_target)
428 samba_includes = includes,
429 local_include = local_include,
430 global_include = global_include,
431 samba_modules = modules,
433 samba_subsystem= subsystem_name,
435 samba_inst_path= install_path,
436 samba_install = install,
437 samba_ldflags = pie_ldflags
440 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
441 bld.MANPAGES(manpages, install)
443 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
446 #################################################################
447 def SAMBA_MODULE(bld, modname, source,
452 module_init_name='samba_init_module',
454 autoproto_extra_source='',
457 internal_module=True,
465 allow_undefined_symbols=False,
466 allow_warnings=False,
469 '''define a Samba module.'''
471 bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname)
473 source = bld.EXPAND_VARIABLES(source, vars=vars)
475 source = bld.SUBDIR(subdir, source)
477 if internal_module or BUILTIN_LIBRARY(bld, modname):
478 # Do not create modules for disabled subsystems
479 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
481 bld.SAMBA_SUBSYSTEM(modname, source,
485 autoproto_extra_source=autoproto_extra_source,
487 cflags_end=cflags_end,
488 local_include=local_include,
489 global_include=global_include,
490 allow_warnings=allow_warnings,
493 bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
497 SET_TARGET_TYPE(bld, modname, 'DISABLED')
500 # Do not create modules for disabled subsystems
501 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
505 deps += ' ' + subsystem
506 while realname.startswith("lib"+subsystem+"_"):
507 realname = realname[len("lib"+subsystem+"_"):]
508 while realname.startswith(subsystem+"_"):
509 realname = realname[len(subsystem+"_"):]
511 build_name = "%s_module_%s" % (subsystem, realname)
513 realname = bld.make_libname(realname)
514 while realname.startswith("lib"):
515 realname = realname[len("lib"):]
517 build_link_name = "modules/%s/%s" % (subsystem, realname)
520 cflags += " -D%s=%s" % (init_function, module_init_name)
522 bld.SAMBA_LIBRARY(modname,
527 cflags_end=cflags_end,
529 autoproto = autoproto,
530 local_include=local_include,
531 global_include=global_include,
533 bundled_name=build_name,
534 link_name=build_link_name,
535 install_path="${MODULESDIR}/%s" % subsystem,
538 allow_undefined_symbols=allow_undefined_symbols,
539 allow_warnings=allow_warnings,
544 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
547 #################################################################
548 def SAMBA_SUBSYSTEM(bld, modname, source,
553 public_headers_install=True,
554 private_headers=None,
559 init_function_sentinel=None,
561 autoproto_extra_source='',
564 local_include_first=True,
569 use_global_deps=True,
573 allow_warnings=False,
576 '''define a Samba subsystem'''
579 SET_TARGET_TYPE(bld, modname, 'DISABLED')
582 # remember empty subsystems, so we can strip the dependencies
583 if ((source == '') or (source == [])):
584 if deps == '' and public_deps == '':
585 SET_TARGET_TYPE(bld, modname, 'EMPTY')
587 empty_c = modname + '.empty.c'
588 bld.SAMBA_GENERATOR('%s_empty_c' % modname,
589 rule=generate_empty_file,
593 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
596 source = bld.EXPAND_VARIABLES(source, vars=vars)
598 source = bld.SUBDIR(subdir, source)
599 source = unique_list(TO_LIST(source))
601 deps += ' ' + public_deps
603 bld.SET_BUILD_GROUP(group)
609 features += ' pyembed'
615 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags,
616 allow_warnings=allow_warnings,
617 hide_symbols=hide_symbols),
618 depends_on = depends_on,
619 samba_deps = TO_LIST(deps),
620 samba_includes = includes,
621 local_include = local_include,
622 local_include_first = local_include_first,
623 global_include = global_include,
624 samba_subsystem= subsystem_name,
625 samba_use_hostcc = use_hostcc,
626 samba_use_global_deps = use_global_deps,
629 if cflags_end is not None:
630 t.samba_cflags.extend(TO_LIST(cflags_end))
632 if autoproto is not None:
633 bld.SAMBA_AUTOPROTO(autoproto, source + TO_LIST(autoproto_extra_source))
634 if public_headers is not None:
635 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
636 public_headers_install=public_headers_install)
640 Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
643 def SAMBA_GENERATOR(bld, name, rule, source='', target='',
644 group='generators', enabled=True,
646 public_headers_install=True,
647 private_headers=None,
652 '''A generic source generator target'''
654 if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
660 dep_vars.append('ruledeps')
661 dep_vars.append('SAMBA_GENERATOR_VARS')
663 bld.SET_BUILD_GROUP(group)
666 source=bld.EXPAND_VARIABLES(source, vars=vars),
668 shell=isinstance(rule, str),
672 samba_type='GENERATOR',
678 t.env.SAMBA_GENERATOR_VARS = vars
683 if public_headers is not None:
684 bld.PUBLIC_HEADERS(public_headers, header_path=header_path,
685 public_headers_install=public_headers_install)
687 Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR
692 def SETUP_BUILD_GROUPS(bld):
693 '''setup build groups used to ensure that the different build
694 phases happen consecutively'''
695 bld.p_ln = bld.srcnode # we do want to see all targets!
696 bld.env['USING_BUILD_GROUPS'] = True
697 bld.add_group('setup')
698 bld.add_group('build_compiler_source')
699 bld.add_group('vscripts')
700 bld.add_group('base_libraries')
701 bld.add_group('generators')
702 bld.add_group('compiler_prototypes')
703 bld.add_group('compiler_libraries')
704 bld.add_group('build_compilers')
705 bld.add_group('build_source')
706 bld.add_group('prototypes')
707 bld.add_group('headers')
708 bld.add_group('main')
709 bld.add_group('symbolcheck')
710 bld.add_group('syslibcheck')
711 bld.add_group('final')
712 Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
715 def SET_BUILD_GROUP(bld, group):
716 '''set the current build group'''
717 if not 'USING_BUILD_GROUPS' in bld.env:
720 Build.BuildContext.SET_BUILD_GROUP = SET_BUILD_GROUP
725 def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
726 """use timestamps instead of file contents for deps
727 this currently doesn't work"""
728 def h_file(filename):
730 st = os.stat(filename)
731 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
733 m.update(str(st.st_mtime))
734 m.update(str(st.st_size))
737 Utils.h_file = h_file
740 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
741 '''used to copy scripts from the source tree into the build directory
742 for use by selftest'''
744 source = bld.path.ant_glob(pattern, flat=True)
746 bld.SET_BUILD_GROUP('build_source')
747 for s in TO_LIST(source):
749 if installname is not None:
751 target = os.path.join(installdir, iname)
752 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
754 link_src = os.path.normpath(os.path.join(bld.path.abspath(), s))
755 link_dst = os.path.join(tgtdir, os.path.basename(iname))
756 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src:
758 if os.path.exists(link_dst):
760 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname))
761 os.symlink(link_src, link_dst)
762 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
765 def copy_and_fix_python_path(task):
766 pattern='sys.path.insert(0, "bin/python")'
767 if task.env["PYTHONARCHDIR"] in sys.path and task.env["PYTHONDIR"] in sys.path:
769 elif task.env["PYTHONARCHDIR"] == task.env["PYTHONDIR"]:
770 replacement="""sys.path.insert(0, "%s")""" % task.env["PYTHONDIR"]
772 replacement="""sys.path.insert(0, "%s")
773 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
775 if task.env["PYTHON"][0].startswith("/"):
776 replacement_shebang = "#!%s\n" % task.env["PYTHON"][0]
778 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"][0]
780 installed_location=task.outputs[0].bldpath(task.env)
781 source_file = open(task.inputs[0].srcpath(task.env))
782 installed_file = open(installed_location, 'w')
784 for line in source_file:
788 newline = replacement_shebang
789 elif pattern in line:
790 newline = line.replace(pattern, replacement)
791 installed_file.write(newline)
793 installed_file.close()
794 os.chmod(installed_location, 0o755)
797 def copy_and_fix_perl_path(task):
798 pattern='use lib "$RealBin/lib";'
801 if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]:
802 replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"]
804 if task.env["PERL"][0] == "/":
805 replacement_shebang = "#!%s\n" % task.env["PERL"]
807 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"]
809 installed_location=task.outputs[0].bldpath(task.env)
810 source_file = open(task.inputs[0].srcpath(task.env))
811 installed_file = open(installed_location, 'w')
813 for line in source_file:
815 if lineno == 0 and task.env["PERL_SPECIFIED"] == True and line[:2] == "#!":
816 newline = replacement_shebang
817 elif pattern in line:
818 newline = line.replace(pattern, replacement)
819 installed_file.write(newline)
821 installed_file.close()
822 os.chmod(installed_location, 0o755)
826 def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
827 python_fixup=False, perl_fixup=False,
828 destname=None, base_name=None):
830 if not isinstance(file, str):
831 file = file.abspath()
832 destdir = bld.EXPAND_VARIABLES(destdir)
836 destname = os.path.basename(destname)
837 dest = os.path.join(destdir, destname)
839 # fix the path python will use to find Samba modules
840 inst_file = file + '.inst'
841 bld.SAMBA_GENERATOR('python_%s' % destname,
842 rule=copy_and_fix_python_path,
843 dep_vars=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
848 # fix the path perl will use to find Samba modules
849 inst_file = file + '.inst'
850 bld.SAMBA_GENERATOR('perl_%s' % destname,
851 rule=copy_and_fix_perl_path,
852 dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
857 file = os.path.join(base_name, file)
858 bld.install_as(dest, file, chmod=chmod)
861 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
862 python_fixup=False, perl_fixup=False,
863 destname=None, base_name=None):
864 '''install a set of files'''
865 for f in TO_LIST(files):
866 install_file(bld, destdir, f, chmod=chmod, flat=flat,
867 python_fixup=python_fixup, perl_fixup=perl_fixup,
868 destname=destname, base_name=base_name)
869 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
872 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
873 python_fixup=False, exclude=None, trim_path=None):
874 '''install a set of files matching a wildcard pattern'''
875 files=TO_LIST(bld.path.ant_glob(pattern, flat=True))
879 files2.append(os_path_relpath(f, trim_path))
884 if fnmatch.fnmatch(f, exclude):
886 INSTALL_FILES(bld, destdir, files, chmod=chmod, flat=flat,
887 python_fixup=python_fixup, base_name=trim_path)
888 Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
890 def INSTALL_DIR(bld, path, chmod=0o755, env=None):
891 """Install a directory if it doesn't exist, always set permissions."""
896 destpath = bld.EXPAND_VARIABLES(path)
897 if Options.options.destdir:
898 destpath = os.path.join(Options.options.destdir, destpath.lstrip(os.sep))
900 if bld.is_install > 0:
901 if not os.path.isdir(destpath):
903 Logs.info('* create %s', destpath)
904 os.makedirs(destpath)
905 os.chmod(destpath, chmod)
907 if not os.path.isdir(destpath):
908 raise Errors.WafError("Cannot create the folder '%s' (error: %s)" % (path, e))
909 Build.BuildContext.INSTALL_DIR = INSTALL_DIR
911 def INSTALL_DIRS(bld, destdir, dirs, chmod=0o755, env=None):
912 '''install a set of directories'''
913 destdir = bld.EXPAND_VARIABLES(destdir)
914 dirs = bld.EXPAND_VARIABLES(dirs)
915 for d in TO_LIST(dirs):
916 INSTALL_DIR(bld, os.path.join(destdir, d), chmod, env)
917 Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
920 def MANPAGES(bld, manpages, install):
921 '''build and install manual pages'''
922 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
923 for m in manpages.split():
925 bld.SAMBA_GENERATOR(m,
929 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
932 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
933 Build.BuildContext.MANPAGES = MANPAGES
935 def SAMBAMANPAGES(bld, manpages, extra_source=None):
936 '''build and install manual pages'''
937 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
938 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
939 bld.env.SAMBA_CATALOG = bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
940 bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.env.SAMBA_CATALOG
942 for m in manpages.split():
944 if extra_source is not None:
945 source = [source, extra_source]
946 bld.SAMBA_GENERATOR(m,
950 dep_vars=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
951 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
952 export XML_CATALOG_FILES
953 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
954 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
956 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
957 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
961 def apply_bundle_remove_dynamiclib_patch(self):
962 if self.env['MACBUNDLE'] or getattr(self,'mac_bundle',False):
963 if not getattr(self,'vnum',None):
965 self.env['LINKFLAGS'].remove('-dynamiclib')
966 self.env['LINKFLAGS'].remove('-single_module')