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_utils
import symlink
14 from samba_version
import *
15 from samba_autoconf
import *
16 from samba_patterns
import *
17 from samba_pidl
import *
18 from samba_autoproto
import *
19 from samba_python
import *
20 from samba_perl
import *
21 from samba_deps
import *
22 from samba_bundled
import *
23 from samba_third_party
import *
26 import samba_conftests
39 os
.environ
['PYTHONUNBUFFERED'] = '1'
41 if Context
.HEXVERSION
not in (0x2001200,):
43 Please use the version of waf that comes with Samba, not
44 a system installed version. See http://wiki.samba.org/index.php/Waf
47 Alternatively, please run ./configure and make as usual. That will
48 call the right version of waf.''')
52 def SAMBA_BUILD_ENV(conf
):
53 '''create the samba build environment'''
54 conf
.env
.BUILD_DIRECTORY
= conf
.bldnode
.abspath()
55 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, LIB_PATH
))
56 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, LIB_PATH
, "private"))
57 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, "modules"))
58 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'python/samba/dcerpc'))
59 # this allows all of the bin/shared and bin/python targets
60 # to be expressed in terms of build directory paths
61 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'default'))
62 for (source
, target
) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python')]:
63 link_target
= os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'default/' + target
)
64 if not os
.path
.lexists(link_target
):
65 symlink('../' + source
, link_target
)
67 # get perl to put the blib files in the build directory
68 blib_bld
= os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'default/pidl/blib')
69 blib_src
= os
.path
.join(conf
.srcnode
.abspath(), 'pidl/blib')
70 mkdir_p(blib_bld
+ '/man1')
71 mkdir_p(blib_bld
+ '/man3')
72 if os
.path
.islink(blib_src
):
74 elif os
.path
.exists(blib_src
):
75 shutil
.rmtree(blib_src
)
78 def ADD_INIT_FUNCTION(bld
, subsystem
, target
, init_function
):
79 '''add an init_function to the list for a subsystem'''
80 if init_function
is None:
82 bld
.ASSERT(subsystem
is not None, "You must specify a subsystem for init_function '%s'" % init_function
)
83 cache
= LOCAL_CACHE(bld
, 'INIT_FUNCTIONS')
84 if not subsystem
in cache
:
86 cache
[subsystem
].append( { 'TARGET':target
, 'INIT_FUNCTION':init_function
} )
87 Build
.BuildContext
.ADD_INIT_FUNCTION
= ADD_INIT_FUNCTION
90 def generate_empty_file(task
):
91 task
.outputs
[0].write('')
94 #################################################################
95 def SAMBA_LIBRARY(bld
, libname
, source
,
100 public_headers_install
=True,
101 private_headers
=None,
109 external_library
=False,
111 keep_underscore
=False,
113 autoproto_extra_source
='',
124 target_type
='LIBRARY',
125 bundled_extension
=False,
132 private_library
=False,
133 grouping_library
=False,
134 allow_undefined_symbols
=False,
135 allow_warnings
=False,
137 '''define a Samba library'''
139 if private_library
and public_headers
:
140 raise Errors
.WafError("private library '%s' must not have public header files" %
143 if LIB_MUST_BE_PRIVATE(bld
, libname
):
144 private_library
= True
147 SET_TARGET_TYPE(bld
, libname
, 'DISABLED')
150 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
152 source
= bld
.SUBDIR(subdir
, source
)
154 # remember empty libraries, so we can strip the dependencies
155 if ((source
== '') or (source
== [])):
156 if deps
== '' and public_deps
== '':
157 SET_TARGET_TYPE(bld
, libname
, 'EMPTY')
159 empty_c
= libname
+ '.empty.c'
160 bld
.SAMBA_GENERATOR('%s_empty_c' % libname
,
161 rule
=generate_empty_file
,
165 if BUILTIN_LIBRARY(bld
, libname
):
168 obj_target
= libname
+ '.objlist'
170 if group
== 'libraries':
171 subsystem_group
= 'main'
173 subsystem_group
= group
175 # first create a target for building the object files for this library
176 # by separating in this way, we avoid recompiling the C files
177 # separately for the install library and the build library
178 bld
.SAMBA_SUBSYSTEM(obj_target
,
181 public_deps
= public_deps
,
183 public_headers
= public_headers
,
184 public_headers_install
= public_headers_install
,
185 private_headers
= private_headers
,
186 header_path
= header_path
,
188 cflags_end
= cflags_end
,
189 group
= subsystem_group
,
190 autoproto
= autoproto
,
191 autoproto_extra_source
=autoproto_extra_source
,
192 depends_on
= depends_on
,
193 hide_symbols
= hide_symbols
,
194 allow_warnings
= allow_warnings
,
197 local_include
= local_include
,
198 global_include
= global_include
)
200 if BUILTIN_LIBRARY(bld
, libname
):
203 if not SET_TARGET_TYPE(bld
, libname
, target_type
):
206 # the library itself will depend on that object target
207 deps
+= ' ' + public_deps
209 deps
.append(obj_target
)
211 realname
= bld
.map_shlib_extension(realname
, python
=(target_type
=='PYTHON'))
212 link_name
= bld
.map_shlib_extension(link_name
, python
=(target_type
=='PYTHON'))
214 # we don't want any public libraries without version numbers
215 if (not private_library
and target_type
!= 'PYTHON' and not realname
):
216 if vnum
is None and soname
is None:
217 raise Errors
.WafError("public library '%s' must have a vnum" %
220 raise Errors
.WafError("public library '%s' must have pkg-config file" %
222 if public_headers
is None:
223 raise Errors
.WafError("public library '%s' must have header files" %
226 if bundled_name
is not None:
228 elif target_type
== 'PYTHON' or realname
or not private_library
:
230 bundled_name
= libname
232 bundled_name
= libname
.replace('_', '-')
234 assert (private_library
== True and realname
is None)
235 if abi_directory
or vnum
or soname
:
236 bundled_extension
=True
237 bundled_name
= PRIVATE_NAME(bld
, libname
.replace('_', '-'),
238 bundled_extension
, private_library
)
240 ldflags
= TO_LIST(ldflags
)
241 if bld
.env
['ENABLE_RELRO'] is True:
242 ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
244 features
= 'c cshlib symlink_lib install_lib'
248 features
+= ' pyembed'
251 features
+= ' abi_check'
253 if pyembed
and bld
.env
['PYTHON_SO_ABI_FLAG']:
254 # For ABI checking, we don't care about the Python version.
255 # Remove the Python ABI tag (e.g. ".cpython-35m")
256 abi_flag
= bld
.env
['PYTHON_SO_ABI_FLAG']
258 version_libname
= libname
.replace(abi_flag
, replacement
)
260 version_libname
= libname
263 if bld
.env
.HAVE_LD_VERSION_SCRIPT
:
265 version
= "%s_%s" % (Context
.g_module
.APPNAME
, Context
.g_module
.VERSION
)
267 version
= "%s_%s" % (libname
, vnum
)
271 vscript
= "%s.vscript" % libname
272 bld
.ABI_VSCRIPT(version_libname
, abi_directory
, version
, vscript
,
274 fullname
= apply_pattern(bundled_name
, bld
.env
.cshlib_PATTERN
)
275 fullpath
= bld
.path
.find_or_declare(fullname
)
276 vscriptpath
= bld
.path
.find_or_declare(vscript
)
278 raise Errors
.WafError("unable to find fullpath for %s" % fullname
)
280 raise Errors
.WafError("unable to find vscript path for %s" % vscript
)
281 bld
.add_manual_dependency(fullpath
, vscriptpath
)
283 # also make the .inst file depend on the vscript
284 instname
= apply_pattern(bundled_name
+ '.inst', bld
.env
.cshlib_PATTERN
)
285 bld
.add_manual_dependency(bld
.path
.find_or_declare(instname
), bld
.path
.find_or_declare(vscript
))
286 vscript
= os
.path
.join(bld
.path
.abspath(bld
.env
), vscript
)
288 bld
.SET_BUILD_GROUP(group
)
292 target
= bundled_name
,
293 depends_on
= depends_on
,
294 samba_ldflags
= ldflags
,
296 samba_includes
= includes
,
297 version_script
= vscript
,
298 version_libname
= version_libname
,
299 local_include
= local_include
,
300 global_include
= global_include
,
304 samba_inst_path
= install_path
,
306 samba_realname
= realname
,
307 samba_install
= install
,
308 abi_directory
= "%s/%s" % (bld
.path
.abspath(), abi_directory
),
309 abi_match
= abi_match
,
310 private_library
= private_library
,
311 grouping_library
=grouping_library
,
312 allow_undefined_symbols
=allow_undefined_symbols
315 if realname
and not link_name
:
316 link_name
= 'shared/%s' % realname
319 if 'waflib.extras.compat15' in sys
.modules
:
320 link_name
= 'default/' + link_name
321 t
.link_name
= link_name
323 if pc_files
is not None and not private_library
:
325 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
, extra_name
=bld
.env
['PYTHON_SO_ABI_FLAG'])
327 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
)
329 if (manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and
330 bld
.env
['XSLTPROC_MANPAGES']):
331 bld
.MANPAGES(manpages
, install
)
334 Build
.BuildContext
.SAMBA_LIBRARY
= SAMBA_LIBRARY
337 #################################################################
338 def SAMBA_BINARY(bld
, binname
, source
,
342 private_headers
=None,
350 use_global_deps
=True,
357 allow_warnings
=False,
366 '''define a Samba binary'''
368 if for_selftest
and not bld
.CONFIG_GET('ENABLE_SELFTEST'):
372 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
375 # Fuzzing builds do not build normal binaries
376 # however we must build asn1compile etc
378 if not use_hostcc
and bld
.env
.enable_fuzzing
!= fuzzer
:
379 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
385 ldflags
= bld
.env
['FUZZ_TARGET_LDFLAGS']
387 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
390 features
= 'c cprogram symlink_bin install_bin'
392 features
+= ' pyembed'
394 obj_target
= binname
+ '.objlist'
396 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
398 source
= bld
.SUBDIR(subdir
, source
)
399 source
= unique_list(TO_LIST(source
))
401 if group
== 'binaries':
402 subsystem_group
= 'main'
403 elif group
== 'build_compilers':
404 subsystem_group
= 'compiler_libraries'
406 subsystem_group
= group
408 # only specify PIE flags for binaries
410 pie_ldflags
= TO_LIST(ldflags
)
411 if bld
.env
['ENABLE_PIE'] is True:
412 pie_cflags
+= ' -fPIE'
413 pie_ldflags
.extend(TO_LIST('-pie'))
414 if bld
.env
['ENABLE_RELRO'] is True:
415 pie_ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
417 # first create a target for building the object files for this binary
418 # by separating in this way, we avoid recompiling the C files
419 # separately for the install binary and the build binary
420 bld
.SAMBA_SUBSYSTEM(obj_target
,
425 cflags_end
= cflags_end
,
426 group
= subsystem_group
,
427 autoproto
= autoproto
,
428 subsystem_name
= subsystem_name
,
429 local_include
= local_include
,
430 global_include
= global_include
,
431 use_hostcc
= use_hostcc
,
433 allow_warnings
= allow_warnings
,
434 use_global_deps
= use_global_deps
)
436 bld
.SET_BUILD_GROUP(group
)
438 # the binary itself will depend on that object target
440 deps
.append(obj_target
)
447 samba_includes
= includes
,
448 local_include
= local_include
,
449 global_include
= global_include
,
450 samba_modules
= modules
,
452 samba_subsystem
= subsystem_name
,
454 samba_inst_path
= install_path
,
455 samba_install
= install
,
456 samba_ldflags
= pie_ldflags
459 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
460 bld
.MANPAGES(manpages
, install
)
462 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
465 #################################################################
466 def SAMBA_MODULE(bld
, modname
, source
,
471 module_init_name
='samba_init_module',
473 autoproto_extra_source
='',
476 internal_module
=True,
484 allow_undefined_symbols
=False,
485 allow_warnings
=False,
488 '''define a Samba module.'''
490 bld
.ASSERT(subsystem
, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname
)
492 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
494 source
= bld
.SUBDIR(subdir
, source
)
496 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
497 # Do not create modules for disabled subsystems
498 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
500 bld
.SAMBA_SUBSYSTEM(modname
, source
,
504 autoproto_extra_source
=autoproto_extra_source
,
506 cflags_end
=cflags_end
,
507 local_include
=local_include
,
508 global_include
=global_include
,
509 allow_warnings
=allow_warnings
,
512 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
516 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
519 # Do not create modules for disabled subsystems
520 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
524 deps
+= ' ' + subsystem
525 while realname
.startswith("lib"+subsystem
+"_"):
526 realname
= realname
[len("lib"+subsystem
+"_"):]
527 while realname
.startswith(subsystem
+"_"):
528 realname
= realname
[len(subsystem
+"_"):]
530 build_name
= "%s_module_%s" % (subsystem
, realname
)
532 realname
= bld
.make_libname(realname
)
533 while realname
.startswith("lib"):
534 realname
= realname
[len("lib"):]
536 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
539 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
541 bld
.SAMBA_LIBRARY(modname
,
546 cflags_end
=cflags_end
,
548 autoproto
= autoproto
,
549 local_include
=local_include
,
550 global_include
=global_include
,
552 bundled_name
=build_name
,
553 link_name
=build_link_name
,
554 install_path
="${MODULESDIR}/%s" % subsystem
,
557 allow_undefined_symbols
=allow_undefined_symbols
,
558 allow_warnings
=allow_warnings
,
563 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
566 #################################################################
567 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
572 public_headers_install
=True,
573 private_headers
=None,
578 init_function_sentinel
=None,
580 autoproto_extra_source
='',
583 local_include_first
=True,
588 use_global_deps
=True,
592 allow_warnings
=False,
595 '''define a Samba subsystem'''
598 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
601 # remember empty subsystems, so we can strip the dependencies
602 if ((source
== '') or (source
== [])):
603 if deps
== '' and public_deps
== '':
604 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
606 empty_c
= modname
+ '.empty.c'
607 bld
.SAMBA_GENERATOR('%s_empty_c' % modname
,
608 rule
=generate_empty_file
,
612 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
615 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
617 source
= bld
.SUBDIR(subdir
, source
)
618 source
= unique_list(TO_LIST(source
))
620 deps
+= ' ' + public_deps
622 bld
.SET_BUILD_GROUP(group
)
628 features
+= ' pyembed'
634 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
,
635 allow_warnings
=allow_warnings
,
636 hide_symbols
=hide_symbols
),
637 depends_on
= depends_on
,
638 samba_deps
= TO_LIST(deps
),
639 samba_includes
= includes
,
640 local_include
= local_include
,
641 local_include_first
= local_include_first
,
642 global_include
= global_include
,
643 samba_subsystem
= subsystem_name
,
644 samba_use_hostcc
= use_hostcc
,
645 samba_use_global_deps
= use_global_deps
,
648 if cflags_end
is not None:
649 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
651 if autoproto
is not None:
652 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
653 if public_headers
is not None:
654 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
655 public_headers_install
=public_headers_install
)
659 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
662 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
663 group
='generators', enabled
=True,
665 public_headers_install
=True,
666 private_headers
=None,
671 '''A generic source generator target'''
673 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
679 dep_vars
.append('ruledeps')
680 dep_vars
.append('SAMBA_GENERATOR_VARS')
682 bld
.SET_BUILD_GROUP(group
)
685 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
687 shell
=isinstance(rule
, str),
691 samba_type
='GENERATOR',
697 t
.env
.SAMBA_GENERATOR_VARS
= vars
702 if public_headers
is not None:
703 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
704 public_headers_install
=public_headers_install
)
706 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
711 def SETUP_BUILD_GROUPS(bld
):
712 '''setup build groups used to ensure that the different build
713 phases happen consecutively'''
714 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
715 bld
.env
['USING_BUILD_GROUPS'] = True
716 bld
.add_group('setup')
717 bld
.add_group('build_compiler_source')
718 bld
.add_group('vscripts')
719 bld
.add_group('base_libraries')
720 bld
.add_group('generators')
721 bld
.add_group('compiler_prototypes')
722 bld
.add_group('compiler_libraries')
723 bld
.add_group('build_compilers')
724 bld
.add_group('build_source')
725 bld
.add_group('prototypes')
726 bld
.add_group('headers')
727 bld
.add_group('main')
728 bld
.add_group('symbolcheck')
729 bld
.add_group('syslibcheck')
730 bld
.add_group('final')
731 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
734 def SET_BUILD_GROUP(bld
, group
):
735 '''set the current build group'''
736 if not 'USING_BUILD_GROUPS' in bld
.env
:
739 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
743 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
744 '''used to copy scripts from the source tree into the build directory
745 for use by selftest'''
747 source
= bld
.path
.ant_glob(pattern
, flat
=True)
749 bld
.SET_BUILD_GROUP('build_source')
750 for s
in TO_LIST(source
):
752 if installname
is not None:
754 target
= os
.path
.join(installdir
, iname
)
755 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
757 link_src
= os
.path
.normpath(os
.path
.join(bld
.path
.abspath(), s
))
758 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
759 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
761 if os
.path
.islink(link_dst
):
763 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
764 symlink(link_src
, link_dst
)
765 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
768 def copy_and_fix_python_path(task
):
769 pattern
='sys.path.insert(0, "bin/python")'
770 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
772 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
773 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
775 replacement
="""sys.path.insert(0, "%s")
776 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
778 if task
.env
["PYTHON"][0].startswith("/"):
779 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"][0]
781 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"][0]
783 installed_location
=task
.outputs
[0].bldpath(task
.env
)
784 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
785 installed_file
= open(installed_location
, 'w')
787 for line
in source_file
:
791 newline
= replacement_shebang
792 elif pattern
in line
:
793 newline
= line
.replace(pattern
, replacement
)
794 installed_file
.write(newline
)
796 installed_file
.close()
797 os
.chmod(installed_location
, 0o755)
800 def copy_and_fix_perl_path(task
):
801 pattern
='use lib "$RealBin/lib";'
804 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
805 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
807 if task
.env
["PERL"][0] == "/":
808 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
810 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
812 installed_location
=task
.outputs
[0].bldpath(task
.env
)
813 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
814 installed_file
= open(installed_location
, 'w')
816 for line
in source_file
:
818 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
819 newline
= replacement_shebang
820 elif pattern
in line
:
821 newline
= line
.replace(pattern
, replacement
)
822 installed_file
.write(newline
)
824 installed_file
.close()
825 os
.chmod(installed_location
, 0o755)
829 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
830 python_fixup
=False, perl_fixup
=False,
831 destname
=None, base_name
=None):
833 if not isinstance(file, str):
834 file = file.abspath()
835 destdir
= bld
.EXPAND_VARIABLES(destdir
)
839 destname
= os
.path
.basename(destname
)
840 dest
= os
.path
.join(destdir
, destname
)
842 # fix the path python will use to find Samba modules
843 inst_file
= file + '.inst'
844 bld
.SAMBA_GENERATOR('python_%s' % destname
,
845 rule
=copy_and_fix_python_path
,
846 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
851 # fix the path perl will use to find Samba modules
852 inst_file
= file + '.inst'
853 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
854 rule
=copy_and_fix_perl_path
,
855 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
860 file = os
.path
.join(base_name
, file)
861 bld
.install_as(dest
, file, chmod
=chmod
)
864 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
865 python_fixup
=False, perl_fixup
=False,
866 destname
=None, base_name
=None):
867 '''install a set of files'''
868 for f
in TO_LIST(files
):
869 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
870 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
871 destname
=destname
, base_name
=base_name
)
872 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
875 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
876 python_fixup
=False, exclude
=None, trim_path
=None):
877 '''install a set of files matching a wildcard pattern'''
878 files
=TO_LIST(bld
.path
.ant_glob(pattern
, flat
=True))
882 files2
.append(os
.path
.relpath(f
, trim_path
))
887 if fnmatch
.fnmatch(f
, exclude
):
889 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
890 python_fixup
=python_fixup
, base_name
=trim_path
)
891 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
893 def INSTALL_DIR(bld
, path
, chmod
=0o755, env
=None):
894 """Install a directory if it doesn't exist, always set permissions."""
899 destpath
= bld
.EXPAND_VARIABLES(path
)
900 if Options
.options
.destdir
:
901 destpath
= os
.path
.join(Options
.options
.destdir
, destpath
.lstrip(os
.sep
))
903 if bld
.is_install
> 0:
904 if not os
.path
.isdir(destpath
):
906 Logs
.info('* create %s', destpath
)
907 os
.makedirs(destpath
)
908 os
.chmod(destpath
, chmod
)
910 if not os
.path
.isdir(destpath
):
911 raise Errors
.WafError("Cannot create the folder '%s' (error: %s)" % (path
, e
))
912 Build
.BuildContext
.INSTALL_DIR
= INSTALL_DIR
914 def INSTALL_DIRS(bld
, destdir
, dirs
, chmod
=0o755, env
=None):
915 '''install a set of directories'''
916 destdir
= bld
.EXPAND_VARIABLES(destdir
)
917 dirs
= bld
.EXPAND_VARIABLES(dirs
)
918 for d
in TO_LIST(dirs
):
919 INSTALL_DIR(bld
, os
.path
.join(destdir
, d
), chmod
, env
)
920 Build
.BuildContext
.INSTALL_DIRS
= INSTALL_DIRS
923 def MANPAGES(bld
, manpages
, install
):
924 '''build and install manual pages'''
925 bld
.env
.MAN_XSL
= 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
926 for m
in manpages
.split():
928 bld
.SAMBA_GENERATOR(m
,
932 rule
='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
935 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
936 Build
.BuildContext
.MANPAGES
= MANPAGES
938 def SAMBAMANPAGES(bld
, manpages
, extra_source
=None):
939 '''build and install manual pages'''
940 bld
.env
.SAMBA_EXPAND_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
941 bld
.env
.SAMBA_MAN_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/man.xsl'
942 bld
.env
.SAMBA_CATALOG
= bld
.bldnode
.abspath() + '/docs-xml/build/catalog.xml'
943 bld
.env
.SAMBA_CATALOGS
= 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld
.env
.SAMBA_CATALOG
945 for m
in manpages
.split():
947 if extra_source
is not None:
948 source
= [source
, extra_source
]
949 bld
.SAMBA_GENERATOR(m
,
953 dep_vars
=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
954 rule
='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
955 export XML_CATALOG_FILES
956 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
957 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
959 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
960 Build
.BuildContext
.SAMBAMANPAGES
= SAMBAMANPAGES
964 def apply_bundle_remove_dynamiclib_patch(self
):
965 if self
.env
['MACBUNDLE'] or getattr(self
,'mac_bundle',False):
966 if not getattr(self
,'vnum',None):
968 self
.env
['LINKFLAGS'].remove('-dynamiclib')
969 self
.env
['LINKFLAGS'].remove('-single_module')