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 (0x2001500,):
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'''
370 if not bld
.CONFIG_GET('ENABLE_SELFTEST'):
374 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
377 # Fuzzing builds do not build normal binaries
378 # however we must build asn1compile etc
380 if not use_hostcc
and bld
.env
.enable_fuzzing
!= fuzzer
:
381 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
387 ldflags
= bld
.env
['FUZZ_TARGET_LDFLAGS']
389 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
392 features
= 'c cprogram symlink_bin install_bin'
394 features
+= ' pyembed'
396 obj_target
= binname
+ '.objlist'
398 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
400 source
= bld
.SUBDIR(subdir
, source
)
401 source
= unique_list(TO_LIST(source
))
403 if group
== 'binaries':
404 subsystem_group
= 'main'
405 elif group
== 'build_compilers':
406 subsystem_group
= 'compiler_libraries'
408 subsystem_group
= group
410 # only specify PIE flags for binaries
411 pie_cflags
= TO_LIST(cflags
)
412 pie_ldflags
= TO_LIST(ldflags
)
413 if bld
.env
['ENABLE_PIE'] is True:
414 pie_cflags
.extend(TO_LIST('-fPIE'))
415 pie_ldflags
.extend(TO_LIST('-pie'))
416 if bld
.env
['ENABLE_RELRO'] is True:
417 pie_ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
419 # first create a target for building the object files for this binary
420 # by separating in this way, we avoid recompiling the C files
421 # separately for the install binary and the build binary
422 bld
.SAMBA_SUBSYSTEM(obj_target
,
427 cflags_end
= cflags_end
,
428 group
= subsystem_group
,
429 autoproto
= autoproto
,
430 subsystem_name
= subsystem_name
,
431 local_include
= local_include
,
432 global_include
= global_include
,
433 use_hostcc
= use_hostcc
,
435 allow_warnings
= allow_warnings
,
436 use_global_deps
= use_global_deps
)
438 bld
.SET_BUILD_GROUP(group
)
440 # the binary itself will depend on that object target
442 deps
.append(obj_target
)
449 samba_includes
= includes
,
450 local_include
= local_include
,
451 global_include
= global_include
,
452 samba_modules
= modules
,
454 samba_subsystem
= subsystem_name
,
456 samba_inst_path
= install_path
,
457 samba_install
= install
,
458 samba_ldflags
= pie_ldflags
461 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
462 bld
.MANPAGES(manpages
, install
)
464 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
467 #################################################################
468 def SAMBA_MODULE(bld
, modname
, source
,
473 module_init_name
='samba_init_module',
475 autoproto_extra_source
='',
478 internal_module
=True,
486 allow_undefined_symbols
=False,
487 allow_warnings
=False,
490 '''define a Samba module.'''
492 bld
.ASSERT(subsystem
, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname
)
494 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
496 source
= bld
.SUBDIR(subdir
, source
)
498 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
499 # Do not create modules for disabled subsystems
500 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
502 bld
.SAMBA_SUBSYSTEM(modname
, source
,
506 autoproto_extra_source
=autoproto_extra_source
,
508 cflags_end
=cflags_end
,
509 local_include
=local_include
,
510 global_include
=global_include
,
511 allow_warnings
=allow_warnings
,
514 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
518 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
521 # Do not create modules for disabled subsystems
522 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
526 deps
+= ' ' + subsystem
527 while realname
.startswith("lib"+subsystem
+"_"):
528 realname
= realname
[len("lib"+subsystem
+"_"):]
529 while realname
.startswith(subsystem
+"_"):
530 realname
= realname
[len(subsystem
+"_"):]
532 build_name
= "%s_module_%s" % (subsystem
, realname
)
534 realname
= bld
.make_libname(realname
)
535 while realname
.startswith("lib"):
536 realname
= realname
[len("lib"):]
538 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
541 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
543 bld
.SAMBA_LIBRARY(modname
,
548 cflags_end
=cflags_end
,
550 autoproto
= autoproto
,
551 local_include
=local_include
,
552 global_include
=global_include
,
554 bundled_name
=build_name
,
555 link_name
=build_link_name
,
556 install_path
="${MODULESDIR}/%s" % subsystem
,
559 allow_undefined_symbols
=allow_undefined_symbols
,
560 allow_warnings
=allow_warnings
,
565 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
568 #################################################################
569 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
574 public_headers_install
=True,
575 private_headers
=None,
580 init_function_sentinel
=None,
582 autoproto_extra_source
='',
585 local_include_first
=True,
590 use_global_deps
=True,
594 allow_warnings
=False,
597 '''define a Samba subsystem'''
600 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
603 # remember empty subsystems, so we can strip the dependencies
604 if ((source
== '') or (source
== [])):
605 if deps
== '' and public_deps
== '':
606 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
608 empty_c
= modname
+ '.empty.c'
609 bld
.SAMBA_GENERATOR('%s_empty_c' % modname
,
610 rule
=generate_empty_file
,
614 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
617 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
619 source
= bld
.SUBDIR(subdir
, source
)
620 source
= unique_list(TO_LIST(source
))
622 deps
+= ' ' + public_deps
624 bld
.SET_BUILD_GROUP(group
)
630 features
+= ' pyembed'
636 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
,
637 allow_warnings
=allow_warnings
,
638 use_hostcc
=use_hostcc
,
639 hide_symbols
=hide_symbols
),
640 depends_on
= depends_on
,
641 samba_deps
= TO_LIST(deps
),
642 samba_includes
= includes
,
643 local_include
= local_include
,
644 local_include_first
= local_include_first
,
645 global_include
= global_include
,
646 samba_subsystem
= subsystem_name
,
647 samba_use_hostcc
= use_hostcc
,
648 samba_use_global_deps
= use_global_deps
,
651 if cflags_end
is not None:
652 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
654 if autoproto
is not None:
655 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
656 if public_headers
is not None:
657 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
658 public_headers_install
=public_headers_install
)
662 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
665 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
666 group
='generators', enabled
=True,
668 public_headers_install
=True,
669 private_headers
=None,
674 '''A generic source generator target'''
676 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
682 dep_vars
.append('ruledeps')
683 dep_vars
.append('SAMBA_GENERATOR_VARS')
685 bld
.SET_BUILD_GROUP(group
)
688 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
690 shell
=isinstance(rule
, str),
694 samba_type
='GENERATOR',
700 t
.env
.SAMBA_GENERATOR_VARS
= vars
705 if public_headers
is not None:
706 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
707 public_headers_install
=public_headers_install
)
709 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
714 def SETUP_BUILD_GROUPS(bld
):
715 '''setup build groups used to ensure that the different build
716 phases happen consecutively'''
717 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
718 bld
.env
['USING_BUILD_GROUPS'] = True
719 bld
.add_group('setup')
720 bld
.add_group('generators')
721 bld
.add_group('hostcc_base_build_source')
722 bld
.add_group('hostcc_base_build_main')
723 bld
.add_group('hostcc_build_source')
724 bld
.add_group('hostcc_build_main')
725 bld
.add_group('vscripts')
726 bld
.add_group('base_libraries')
727 bld
.add_group('build_source')
728 bld
.add_group('prototypes')
729 bld
.add_group('headers')
730 bld
.add_group('main')
731 bld
.add_group('symbolcheck')
732 bld
.add_group('syslibcheck')
733 bld
.add_group('final')
734 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
737 def SET_BUILD_GROUP(bld
, group
):
738 '''set the current build group'''
739 if not 'USING_BUILD_GROUPS' in bld
.env
:
742 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
746 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
747 '''used to copy scripts from the source tree into the build directory
748 for use by selftest'''
750 source
= bld
.path
.ant_glob(pattern
, flat
=True)
752 bld
.SET_BUILD_GROUP('build_source')
753 for s
in TO_LIST(source
):
755 if installname
is not None:
757 target
= os
.path
.join(installdir
, iname
)
758 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
760 link_src
= os
.path
.normpath(os
.path
.join(bld
.path
.abspath(), s
))
761 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
762 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
764 if os
.path
.islink(link_dst
):
766 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
767 symlink(link_src
, link_dst
)
768 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
771 def copy_and_fix_python_path(task
):
772 pattern
='sys.path.insert(0, "bin/python")'
773 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
775 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
776 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
778 replacement
="""sys.path.insert(0, "%s")
779 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
781 if task
.env
["PYTHON"][0].startswith("/"):
782 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"][0]
784 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"][0]
786 installed_location
=task
.outputs
[0].bldpath(task
.env
)
787 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
788 installed_file
= open(installed_location
, 'w')
790 for line
in source_file
:
794 newline
= replacement_shebang
795 elif pattern
in line
:
796 newline
= line
.replace(pattern
, replacement
)
797 installed_file
.write(newline
)
799 installed_file
.close()
800 os
.chmod(installed_location
, 0o755)
803 def copy_and_fix_perl_path(task
):
804 pattern
='use lib "$RealBin/lib";'
807 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
808 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
810 if task
.env
["PERL"][0] == "/":
811 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
813 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
815 installed_location
=task
.outputs
[0].bldpath(task
.env
)
816 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
817 installed_file
= open(installed_location
, 'w')
819 for line
in source_file
:
821 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
822 newline
= replacement_shebang
823 elif pattern
in line
:
824 newline
= line
.replace(pattern
, replacement
)
825 installed_file
.write(newline
)
827 installed_file
.close()
828 os
.chmod(installed_location
, 0o755)
832 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
833 python_fixup
=False, perl_fixup
=False,
834 destname
=None, base_name
=None):
836 if not isinstance(file, str):
837 file = file.abspath()
838 destdir
= bld
.EXPAND_VARIABLES(destdir
)
842 destname
= os
.path
.basename(destname
)
843 dest
= os
.path
.join(destdir
, destname
)
845 # fix the path python will use to find Samba modules
846 inst_file
= file + '.inst'
847 bld
.SAMBA_GENERATOR('python_%s' % destname
,
848 rule
=copy_and_fix_python_path
,
849 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
854 # fix the path perl will use to find Samba modules
855 inst_file
= file + '.inst'
856 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
857 rule
=copy_and_fix_perl_path
,
858 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
863 file = os
.path
.join(base_name
, file)
864 bld
.install_as(dest
, file, chmod
=chmod
)
867 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
868 python_fixup
=False, perl_fixup
=False,
869 destname
=None, base_name
=None):
870 '''install a set of files'''
871 for f
in TO_LIST(files
):
872 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
873 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
874 destname
=destname
, base_name
=base_name
)
875 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
878 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
879 python_fixup
=False, exclude
=None, trim_path
=None):
880 '''install a set of files matching a wildcard pattern'''
881 files
=TO_LIST(bld
.path
.ant_glob(pattern
, flat
=True))
885 files2
.append(os
.path
.relpath(f
, trim_path
))
890 if fnmatch
.fnmatch(f
, exclude
):
892 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
893 python_fixup
=python_fixup
, base_name
=trim_path
)
894 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
896 def INSTALL_DIR(bld
, path
, chmod
=0o755, env
=None):
897 """Install a directory if it doesn't exist, always set permissions."""
902 destpath
= bld
.EXPAND_VARIABLES(path
)
903 if Options
.options
.destdir
:
904 destpath
= os
.path
.join(Options
.options
.destdir
, destpath
.lstrip(os
.sep
))
906 if bld
.is_install
> 0:
907 if not os
.path
.isdir(destpath
):
909 Logs
.info('* create %s', destpath
)
910 os
.makedirs(destpath
)
911 os
.chmod(destpath
, chmod
)
913 if not os
.path
.isdir(destpath
):
914 raise Errors
.WafError("Cannot create the folder '%s' (error: %s)" % (path
, e
))
915 Build
.BuildContext
.INSTALL_DIR
= INSTALL_DIR
917 def INSTALL_DIRS(bld
, destdir
, dirs
, chmod
=0o755, env
=None):
918 '''install a set of directories'''
919 destdir
= bld
.EXPAND_VARIABLES(destdir
)
920 dirs
= bld
.EXPAND_VARIABLES(dirs
)
921 for d
in TO_LIST(dirs
):
922 INSTALL_DIR(bld
, os
.path
.join(destdir
, d
), chmod
, env
)
923 Build
.BuildContext
.INSTALL_DIRS
= INSTALL_DIRS
926 def MANPAGES(bld
, manpages
, install
):
927 '''build and install manual pages'''
928 bld
.env
.MAN_XSL
= 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
929 for m
in manpages
.split():
931 bld
.SAMBA_GENERATOR(m
,
935 rule
='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
938 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
939 Build
.BuildContext
.MANPAGES
= MANPAGES
941 def SAMBAMANPAGES(bld
, manpages
, extra_source
=None):
942 '''build and install manual pages'''
943 bld
.env
.SAMBA_EXPAND_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
944 bld
.env
.SAMBA_MAN_XSL
= bld
.srcnode
.abspath() + '/docs-xml/xslt/man.xsl'
945 bld
.env
.SAMBA_CATALOG
= bld
.bldnode
.abspath() + '/docs-xml/build/catalog.xml'
946 bld
.env
.SAMBA_CATALOGS
= 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld
.env
.SAMBA_CATALOG
948 for m
in manpages
.split():
949 source
= [m
+ '.xml']
950 if extra_source
is not None:
951 source
= [source
, extra_source
]
952 # ${SRC[1]} and ${SRC[2]} are not referenced in the
953 # SAMBA_GENERATOR but trigger the dependency calculation so
954 # ensures that manpages are rebuilt when these change.
955 source
+= ['build/DTD/samba.entities', 'build/DTD/samba.build.version']
956 bld
.SAMBA_GENERATOR(m
,
960 dep_vars
=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'],
961 rule
='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
962 export XML_CATALOG_FILES
963 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
964 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
966 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
, flat
=True)
967 Build
.BuildContext
.SAMBAMANPAGES
= SAMBAMANPAGES
971 def apply_bundle_remove_dynamiclib_patch(self
):
972 if self
.env
['MACBUNDLE'] or getattr(self
,'mac_bundle',False):
973 if not getattr(self
,'vnum',None):
975 self
.env
['LINKFLAGS'].remove('-dynamiclib')
976 self
.env
['LINKFLAGS'].remove('-single_module')