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
39 # some systems have broken threading in python
40 if os
.environ
.get('WAF_NOTHREADS') == '1':
45 os
.environ
['PYTHONUNBUFFERED'] = '1'
47 if Context
.HEXVERSION
not in (0x2000800,):
49 Please use the version of waf that comes with Samba, not
50 a system installed version. See http://wiki.samba.org/index.php/Waf
53 Alternatively, please run ./configure and make as usual. That will
54 call the right version of waf.''')
58 def SAMBA_BUILD_ENV(conf
):
59 '''create the samba build environment'''
60 conf
.env
.BUILD_DIRECTORY
= conf
.bldnode
.abspath()
61 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, LIB_PATH
))
62 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, LIB_PATH
, "private"))
63 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, "modules"))
64 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'python/samba/dcerpc'))
65 # this allows all of the bin/shared and bin/python targets
66 # to be expressed in terms of build directory paths
67 mkdir_p(os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'default'))
68 for (source
, target
) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
69 link_target
= os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'default/' + target
)
70 if not os
.path
.lexists(link_target
):
71 os
.symlink('../' + source
, link_target
)
73 # get perl to put the blib files in the build directory
74 blib_bld
= os
.path
.join(conf
.env
.BUILD_DIRECTORY
, 'default/pidl/blib')
75 blib_src
= os
.path
.join(conf
.srcnode
.abspath(), 'pidl/blib')
76 mkdir_p(blib_bld
+ '/man1')
77 mkdir_p(blib_bld
+ '/man3')
78 if os
.path
.islink(blib_src
):
80 elif os
.path
.exists(blib_src
):
81 shutil
.rmtree(blib_src
)
84 def ADD_INIT_FUNCTION(bld
, subsystem
, target
, init_function
):
85 '''add an init_function to the list for a subsystem'''
86 if init_function
is None:
88 bld
.ASSERT(subsystem
is not None, "You must specify a subsystem for init_function '%s'" % init_function
)
89 cache
= LOCAL_CACHE(bld
, 'INIT_FUNCTIONS')
90 if not subsystem
in cache
:
92 cache
[subsystem
].append( { 'TARGET':target
, 'INIT_FUNCTION':init_function
} )
93 Build
.BuildContext
.ADD_INIT_FUNCTION
= ADD_INIT_FUNCTION
96 def generate_empty_file(task
):
97 task
.outputs
[0].write('')
100 #################################################################
101 def SAMBA_LIBRARY(bld
, libname
, source
,
106 public_headers_install
=True,
107 private_headers
=None,
115 external_library
=False,
117 keep_underscore
=False,
119 autoproto_extra_source
='',
130 target_type
='LIBRARY',
131 bundled_extension
=False,
138 private_library
=False,
139 grouping_library
=False,
140 allow_undefined_symbols
=False,
141 allow_warnings
=False,
143 '''define a Samba library'''
145 if pyembed
and bld
.env
['IS_EXTRA_PYTHON']:
146 public_headers
= None
148 if private_library
and public_headers
:
149 raise Errors
.WafError("private library '%s' must not have public header files" %
152 if LIB_MUST_BE_PRIVATE(bld
, libname
):
153 private_library
= True
156 SET_TARGET_TYPE(bld
, libname
, 'DISABLED')
159 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
161 source
= bld
.SUBDIR(subdir
, source
)
163 # remember empty libraries, so we can strip the dependencies
164 if ((source
== '') or (source
== [])):
165 if deps
== '' and public_deps
== '':
166 SET_TARGET_TYPE(bld
, libname
, 'EMPTY')
168 empty_c
= libname
+ '.empty.c'
169 bld
.SAMBA_GENERATOR('%s_empty_c' % libname
,
170 rule
=generate_empty_file
,
174 if BUILTIN_LIBRARY(bld
, libname
):
177 obj_target
= libname
+ '.objlist'
179 if group
== 'libraries':
180 subsystem_group
= 'main'
182 subsystem_group
= group
184 # first create a target for building the object files for this library
185 # by separating in this way, we avoid recompiling the C files
186 # separately for the install library and the build library
187 bld
.SAMBA_SUBSYSTEM(obj_target
,
190 public_deps
= public_deps
,
192 public_headers
= public_headers
,
193 public_headers_install
= public_headers_install
,
194 private_headers
= private_headers
,
195 header_path
= header_path
,
197 cflags_end
= cflags_end
,
198 group
= subsystem_group
,
199 autoproto
= autoproto
,
200 autoproto_extra_source
=autoproto_extra_source
,
201 depends_on
= depends_on
,
202 hide_symbols
= hide_symbols
,
203 allow_warnings
= allow_warnings
,
206 local_include
= local_include
,
207 global_include
= global_include
)
209 if BUILTIN_LIBRARY(bld
, libname
):
212 if not SET_TARGET_TYPE(bld
, libname
, target_type
):
215 # the library itself will depend on that object target
216 deps
+= ' ' + public_deps
218 deps
.append(obj_target
)
220 realname
= bld
.map_shlib_extension(realname
, python
=(target_type
=='PYTHON'))
221 link_name
= bld
.map_shlib_extension(link_name
, python
=(target_type
=='PYTHON'))
223 # we don't want any public libraries without version numbers
224 if (not private_library
and target_type
!= 'PYTHON' and not realname
):
225 if vnum
is None and soname
is None:
226 raise Errors
.WafError("public library '%s' must have a vnum" %
229 raise Errors
.WafError("public library '%s' must have pkg-config file" %
231 if public_headers
is None and not bld
.env
['IS_EXTRA_PYTHON']:
232 raise Errors
.WafError("public library '%s' must have header files" %
235 if bundled_name
is not None:
237 elif target_type
== 'PYTHON' or realname
or not private_library
:
239 bundled_name
= libname
241 bundled_name
= libname
.replace('_', '-')
243 assert (private_library
== True and realname
is None)
244 if abi_directory
or vnum
or soname
:
245 bundled_extension
=True
246 bundled_name
= PRIVATE_NAME(bld
, libname
.replace('_', '-'),
247 bundled_extension
, private_library
)
249 ldflags
= TO_LIST(ldflags
)
250 if bld
.env
['ENABLE_RELRO'] is True:
251 ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
253 features
= 'c cshlib symlink_lib install_lib'
257 features
+= ' pyembed'
260 features
+= ' abi_check'
262 if pyembed
and bld
.env
['PYTHON_SO_ABI_FLAG']:
263 # For ABI checking, we don't care about the exact Python version.
264 # Replace the Python ABI tag (e.g. ".cpython-35m") by a generic ".py3"
265 abi_flag
= bld
.env
['PYTHON_SO_ABI_FLAG']
266 replacement
= '.py%s' % bld
.env
['PYTHON_VERSION'].split('.')[0]
267 version_libname
= libname
.replace(abi_flag
, replacement
)
269 version_libname
= libname
272 if bld
.env
.HAVE_LD_VERSION_SCRIPT
:
274 version
= "%s_%s" % (Context
.g_module
.APPNAME
, Context
.g_module
.VERSION
)
276 version
= "%s_%s" % (libname
, vnum
)
280 vscript
= "%s.vscript" % libname
281 bld
.ABI_VSCRIPT(version_libname
, abi_directory
, version
, vscript
,
283 fullname
= apply_pattern(bundled_name
, bld
.env
.cshlib_PATTERN
)
284 fullpath
= bld
.path
.find_or_declare(fullname
)
285 vscriptpath
= bld
.path
.find_or_declare(vscript
)
287 raise Errors
.WafError("unable to find fullpath for %s" % fullname
)
289 raise Errors
.WafError("unable to find vscript path for %s" % vscript
)
290 bld
.add_manual_dependency(fullpath
, vscriptpath
)
292 # also make the .inst file depend on the vscript
293 instname
= apply_pattern(bundled_name
+ '.inst', bld
.env
.cshlib_PATTERN
)
294 bld
.add_manual_dependency(bld
.path
.find_or_declare(instname
), bld
.path
.find_or_declare(vscript
))
295 vscript
= os
.path
.join(bld
.path
.abspath(bld
.env
), vscript
)
297 bld
.SET_BUILD_GROUP(group
)
301 target
= bundled_name
,
302 depends_on
= depends_on
,
303 samba_ldflags
= ldflags
,
305 samba_includes
= includes
,
306 version_script
= vscript
,
307 version_libname
= version_libname
,
308 local_include
= local_include
,
309 global_include
= global_include
,
313 samba_inst_path
= install_path
,
315 samba_realname
= realname
,
316 samba_install
= install
,
317 abi_directory
= "%s/%s" % (bld
.path
.abspath(), abi_directory
),
318 abi_match
= abi_match
,
319 private_library
= private_library
,
320 grouping_library
=grouping_library
,
321 allow_undefined_symbols
=allow_undefined_symbols
324 if realname
and not link_name
:
325 link_name
= 'shared/%s' % realname
328 if 'waflib.extras.compat15' in sys
.modules
:
329 link_name
= 'default/' + link_name
330 t
.link_name
= link_name
332 if pc_files
is not None and not private_library
:
333 if pyembed
and bld
.env
['IS_EXTRA_PYTHON']:
334 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
, extra_name
=bld
.env
['PYTHON_SO_ABI_FLAG'])
336 bld
.PKG_CONFIG_FILES(pc_files
, vnum
=vnum
)
338 if (manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and
339 bld
.env
['XSLTPROC_MANPAGES']):
340 bld
.MANPAGES(manpages
, install
)
343 Build
.BuildContext
.SAMBA_LIBRARY
= SAMBA_LIBRARY
346 #################################################################
347 def SAMBA_BINARY(bld
, binname
, source
,
351 private_headers
=None,
359 use_global_deps
=True,
372 '''define a Samba binary'''
375 SET_TARGET_TYPE(bld
, binname
, 'DISABLED')
378 if not SET_TARGET_TYPE(bld
, binname
, 'BINARY'):
381 features
= 'c cprogram symlink_bin install_bin'
383 features
+= ' pyembed'
385 obj_target
= binname
+ '.objlist'
387 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
389 source
= bld
.SUBDIR(subdir
, source
)
390 source
= unique_list(TO_LIST(source
))
392 if group
== 'binaries':
393 subsystem_group
= 'main'
395 subsystem_group
= group
397 # only specify PIE flags for binaries
399 pie_ldflags
= TO_LIST(ldflags
)
400 if bld
.env
['ENABLE_PIE'] is True:
401 pie_cflags
+= ' -fPIE'
402 pie_ldflags
.extend(TO_LIST('-pie'))
403 if bld
.env
['ENABLE_RELRO'] is True:
404 pie_ldflags
.extend(TO_LIST('-Wl,-z,relro,-z,now'))
406 # first create a target for building the object files for this binary
407 # by separating in this way, we avoid recompiling the C files
408 # separately for the install binary and the build binary
409 bld
.SAMBA_SUBSYSTEM(obj_target
,
414 cflags_end
= cflags_end
,
415 group
= subsystem_group
,
416 autoproto
= autoproto
,
417 subsystem_name
= subsystem_name
,
418 local_include
= local_include
,
419 global_include
= global_include
,
420 use_hostcc
= use_hostcc
,
422 use_global_deps
= use_global_deps
)
424 bld
.SET_BUILD_GROUP(group
)
426 # the binary itself will depend on that object target
428 deps
.append(obj_target
)
435 samba_includes
= includes
,
436 local_include
= local_include
,
437 global_include
= global_include
,
438 samba_modules
= modules
,
440 samba_subsystem
= subsystem_name
,
442 samba_inst_path
= install_path
,
443 samba_install
= install
,
444 samba_ldflags
= pie_ldflags
447 if manpages
is not None and 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
448 bld
.MANPAGES(manpages
, install
)
450 Build
.BuildContext
.SAMBA_BINARY
= SAMBA_BINARY
453 #################################################################
454 def SAMBA_MODULE(bld
, modname
, source
,
459 module_init_name
='samba_init_module',
461 autoproto_extra_source
='',
464 internal_module
=True,
472 allow_undefined_symbols
=False,
473 allow_warnings
=False,
476 '''define a Samba module.'''
478 bld
.ASSERT(subsystem
, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname
)
480 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
482 source
= bld
.SUBDIR(subdir
, source
)
484 if internal_module
or BUILTIN_LIBRARY(bld
, modname
):
485 # Do not create modules for disabled subsystems
486 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
488 bld
.SAMBA_SUBSYSTEM(modname
, source
,
492 autoproto_extra_source
=autoproto_extra_source
,
494 cflags_end
=cflags_end
,
495 local_include
=local_include
,
496 global_include
=global_include
,
497 allow_warnings
=allow_warnings
,
500 bld
.ADD_INIT_FUNCTION(subsystem
, modname
, init_function
)
504 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
507 # Do not create modules for disabled subsystems
508 if GET_TARGET_TYPE(bld
, subsystem
) == 'DISABLED':
512 deps
+= ' ' + subsystem
513 while realname
.startswith("lib"+subsystem
+"_"):
514 realname
= realname
[len("lib"+subsystem
+"_"):]
515 while realname
.startswith(subsystem
+"_"):
516 realname
= realname
[len(subsystem
+"_"):]
518 build_name
= "%s_module_%s" % (subsystem
, realname
)
520 realname
= bld
.make_libname(realname
)
521 while realname
.startswith("lib"):
522 realname
= realname
[len("lib"):]
524 build_link_name
= "modules/%s/%s" % (subsystem
, realname
)
527 cflags
+= " -D%s=%s" % (init_function
, module_init_name
)
529 bld
.SAMBA_LIBRARY(modname
,
534 cflags_end
=cflags_end
,
536 autoproto
= autoproto
,
537 local_include
=local_include
,
538 global_include
=global_include
,
540 bundled_name
=build_name
,
541 link_name
=build_link_name
,
542 install_path
="${MODULESDIR}/%s" % subsystem
,
545 allow_undefined_symbols
=allow_undefined_symbols
,
546 allow_warnings
=allow_warnings
,
551 Build
.BuildContext
.SAMBA_MODULE
= SAMBA_MODULE
554 #################################################################
555 def SAMBA_SUBSYSTEM(bld
, modname
, source
,
560 public_headers_install
=True,
561 private_headers
=None,
566 init_function_sentinel
=None,
568 autoproto_extra_source
='',
571 local_include_first
=True,
576 use_global_deps
=True,
580 allow_warnings
=False,
583 '''define a Samba subsystem'''
586 SET_TARGET_TYPE(bld
, modname
, 'DISABLED')
589 # remember empty subsystems, so we can strip the dependencies
590 if ((source
== '') or (source
== [])):
591 if deps
== '' and public_deps
== '':
592 SET_TARGET_TYPE(bld
, modname
, 'EMPTY')
594 empty_c
= modname
+ '.empty.c'
595 bld
.SAMBA_GENERATOR('%s_empty_c' % modname
,
596 rule
=generate_empty_file
,
600 if not SET_TARGET_TYPE(bld
, modname
, 'SUBSYSTEM'):
603 source
= bld
.EXPAND_VARIABLES(source
, vars=vars)
605 source
= bld
.SUBDIR(subdir
, source
)
606 source
= unique_list(TO_LIST(source
))
608 deps
+= ' ' + public_deps
610 bld
.SET_BUILD_GROUP(group
)
616 features
+= ' pyembed'
622 samba_cflags
= CURRENT_CFLAGS(bld
, modname
, cflags
,
623 allow_warnings
=allow_warnings
,
624 hide_symbols
=hide_symbols
),
625 depends_on
= depends_on
,
626 samba_deps
= TO_LIST(deps
),
627 samba_includes
= includes
,
628 local_include
= local_include
,
629 local_include_first
= local_include_first
,
630 global_include
= global_include
,
631 samba_subsystem
= subsystem_name
,
632 samba_use_hostcc
= use_hostcc
,
633 samba_use_global_deps
= use_global_deps
,
636 if cflags_end
is not None:
637 t
.samba_cflags
.extend(TO_LIST(cflags_end
))
639 if autoproto
is not None:
640 bld
.SAMBA_AUTOPROTO(autoproto
, source
+ TO_LIST(autoproto_extra_source
))
641 if public_headers
is not None:
642 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
643 public_headers_install
=public_headers_install
)
647 Build
.BuildContext
.SAMBA_SUBSYSTEM
= SAMBA_SUBSYSTEM
650 def SAMBA_GENERATOR(bld
, name
, rule
, source
='', target
='',
651 group
='generators', enabled
=True,
653 public_headers_install
=True,
654 private_headers
=None,
659 '''A generic source generator target'''
661 if not SET_TARGET_TYPE(bld
, name
, 'GENERATOR'):
667 dep_vars
.append('ruledeps')
668 dep_vars
.append('SAMBA_GENERATOR_VARS')
670 bld
.SET_BUILD_GROUP(group
)
673 source
=bld
.EXPAND_VARIABLES(source
, vars=vars),
675 shell
=isinstance(rule
, str),
679 samba_type
='GENERATOR',
685 t
.env
.SAMBA_GENERATOR_VARS
= vars
690 if public_headers
is not None:
691 bld
.PUBLIC_HEADERS(public_headers
, header_path
=header_path
,
692 public_headers_install
=public_headers_install
)
694 Build
.BuildContext
.SAMBA_GENERATOR
= SAMBA_GENERATOR
699 def SETUP_BUILD_GROUPS(bld
):
700 '''setup build groups used to ensure that the different build
701 phases happen consecutively'''
702 bld
.p_ln
= bld
.srcnode
# we do want to see all targets!
703 bld
.env
['USING_BUILD_GROUPS'] = True
704 bld
.add_group('setup')
705 bld
.add_group('build_compiler_source')
706 bld
.add_group('vscripts')
707 bld
.add_group('base_libraries')
708 bld
.add_group('generators')
709 bld
.add_group('compiler_prototypes')
710 bld
.add_group('compiler_libraries')
711 bld
.add_group('build_compilers')
712 bld
.add_group('build_source')
713 bld
.add_group('prototypes')
714 bld
.add_group('headers')
715 bld
.add_group('main')
716 bld
.add_group('symbolcheck')
717 bld
.add_group('syslibcheck')
718 bld
.add_group('final')
719 Build
.BuildContext
.SETUP_BUILD_GROUPS
= SETUP_BUILD_GROUPS
722 def SET_BUILD_GROUP(bld
, group
):
723 '''set the current build group'''
724 if not 'USING_BUILD_GROUPS' in bld
.env
:
727 Build
.BuildContext
.SET_BUILD_GROUP
= SET_BUILD_GROUP
732 def ENABLE_TIMESTAMP_DEPENDENCIES(conf
):
733 """use timestamps instead of file contents for deps
734 this currently doesn't work"""
735 def h_file(filename
):
737 st
= os
.stat(filename
)
738 if stat
.S_ISDIR(st
[stat
.ST_MODE
]): raise IOError('not a file')
740 m
.update(str(st
.st_mtime
))
741 m
.update(str(st
.st_size
))
744 Utils
.h_file
= h_file
747 def SAMBA_SCRIPT(bld
, name
, pattern
, installdir
, installname
=None):
748 '''used to copy scripts from the source tree into the build directory
749 for use by selftest'''
751 source
= bld
.path
.ant_glob(pattern
, flat
=True)
753 bld
.SET_BUILD_GROUP('build_source')
754 for s
in TO_LIST(source
):
756 if installname
is not None:
758 target
= os
.path
.join(installdir
, iname
)
759 tgtdir
= os
.path
.dirname(os
.path
.join(bld
.srcnode
.abspath(bld
.env
), '..', target
))
761 link_src
= os
.path
.normpath(os
.path
.join(bld
.path
.abspath(), s
))
762 link_dst
= os
.path
.join(tgtdir
, os
.path
.basename(iname
))
763 if os
.path
.islink(link_dst
) and os
.readlink(link_dst
) == link_src
:
765 if os
.path
.exists(link_dst
):
767 Logs
.info("symlink: %s -> %s/%s" % (s
, installdir
, iname
))
768 os
.symlink(link_src
, link_dst
)
769 Build
.BuildContext
.SAMBA_SCRIPT
= SAMBA_SCRIPT
772 def copy_and_fix_python_path(task
):
773 pattern
='sys.path.insert(0, "bin/python")'
774 if task
.env
["PYTHONARCHDIR"] in sys
.path
and task
.env
["PYTHONDIR"] in sys
.path
:
776 elif task
.env
["PYTHONARCHDIR"] == task
.env
["PYTHONDIR"]:
777 replacement
="""sys.path.insert(0, "%s")""" % task
.env
["PYTHONDIR"]
779 replacement
="""sys.path.insert(0, "%s")
780 sys.path.insert(1, "%s")""" % (task
.env
["PYTHONARCHDIR"], task
.env
["PYTHONDIR"])
782 if task
.env
["PYTHON"][0] == "/":
783 replacement_shebang
= "#!%s\n" % task
.env
["PYTHON"]
785 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PYTHON"]
787 installed_location
=task
.outputs
[0].bldpath(task
.env
)
788 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
789 installed_file
= open(installed_location
, 'w')
791 for line
in source_file
:
793 if (lineno
== 0 and task
.env
["PYTHON_SPECIFIED"] is True and
795 newline
= replacement_shebang
796 elif pattern
in line
:
797 newline
= line
.replace(pattern
, replacement
)
798 installed_file
.write(newline
)
800 installed_file
.close()
801 os
.chmod(installed_location
, 0755)
804 def copy_and_fix_perl_path(task
):
805 pattern
='use lib "$RealBin/lib";'
808 if not task
.env
["PERL_LIB_INSTALL_DIR"] in task
.env
["PERL_INC"]:
809 replacement
= 'use lib "%s";' % task
.env
["PERL_LIB_INSTALL_DIR"]
811 if task
.env
["PERL"][0] == "/":
812 replacement_shebang
= "#!%s\n" % task
.env
["PERL"]
814 replacement_shebang
= "#!/usr/bin/env %s\n" % task
.env
["PERL"]
816 installed_location
=task
.outputs
[0].bldpath(task
.env
)
817 source_file
= open(task
.inputs
[0].srcpath(task
.env
))
818 installed_file
= open(installed_location
, 'w')
820 for line
in source_file
:
822 if lineno
== 0 and task
.env
["PERL_SPECIFIED"] == True and line
[:2] == "#!":
823 newline
= replacement_shebang
824 elif pattern
in line
:
825 newline
= line
.replace(pattern
, replacement
)
826 installed_file
.write(newline
)
828 installed_file
.close()
829 os
.chmod(installed_location
, 0755)
833 def install_file(bld
, destdir
, file, chmod
=MODE_644
, flat
=False,
834 python_fixup
=False, perl_fixup
=False,
835 destname
=None, base_name
=None):
837 if not isinstance(file, str):
838 file = file.abspath()
839 destdir
= bld
.EXPAND_VARIABLES(destdir
)
843 destname
= os
.path
.basename(destname
)
844 dest
= os
.path
.join(destdir
, destname
)
846 # fix the path python will use to find Samba modules
847 inst_file
= file + '.inst'
848 bld
.SAMBA_GENERATOR('python_%s' % destname
,
849 rule
=copy_and_fix_python_path
,
850 dep_vars
=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
855 # fix the path perl will use to find Samba modules
856 inst_file
= file + '.inst'
857 bld
.SAMBA_GENERATOR('perl_%s' % destname
,
858 rule
=copy_and_fix_perl_path
,
859 dep_vars
=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
864 file = os
.path
.join(base_name
, file)
865 bld
.install_as(dest
, file, chmod
=chmod
)
868 def INSTALL_FILES(bld
, destdir
, files
, chmod
=MODE_644
, flat
=False,
869 python_fixup
=False, perl_fixup
=False,
870 destname
=None, base_name
=None):
871 '''install a set of files'''
872 for f
in TO_LIST(files
):
873 install_file(bld
, destdir
, f
, chmod
=chmod
, flat
=flat
,
874 python_fixup
=python_fixup
, perl_fixup
=perl_fixup
,
875 destname
=destname
, base_name
=base_name
)
876 Build
.BuildContext
.INSTALL_FILES
= INSTALL_FILES
879 def INSTALL_WILDCARD(bld
, destdir
, pattern
, chmod
=MODE_644
, flat
=False,
880 python_fixup
=False, exclude
=None, trim_path
=None):
881 '''install a set of files matching a wildcard pattern'''
882 files
=TO_LIST(bld
.path
.ant_glob(pattern
, flat
=True))
886 files2
.append(os_path_relpath(f
, trim_path
))
891 if fnmatch
.fnmatch(f
, exclude
):
893 INSTALL_FILES(bld
, destdir
, files
, chmod
=chmod
, flat
=flat
,
894 python_fixup
=python_fixup
, base_name
=trim_path
)
895 Build
.BuildContext
.INSTALL_WILDCARD
= INSTALL_WILDCARD
897 def INSTALL_DIR(bld
, path
, chmod
=0o755, env
=None):
898 """Install a directory if it doesn't exist, always set permissions."""
903 destpath
= bld
.EXPAND_VARIABLES(path
)
905 if bld
.is_install
> 0:
906 if not os
.path
.isdir(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')