2010-04-11 09:35:08 +02:00
# a waf tool to add autoconf-like macros to the configure section
# and for SAMBA_ macros for building libraries, binaries etc
2018-01-31 11:48:43 +02:00
import os
2019-01-30 17:13:47 +01:00
from waflib import Build
2019-11-04 17:07:44 +13:00
from samba_utils import TO_LIST
2012-04-11 09:36:12 +10:00
from samba_autoconf import library_flags
2010-04-11 09:35:08 +02:00
2010-09-26 10:44:27 +02:00
def SAMBA3_IS_STATIC_MODULE ( bld , module ) :
''' Check whether module is in static list '''
2010-12-01 12:10:03 +01:00
if module in bld . env [ ' static_modules ' ] :
2010-09-26 10:44:27 +02:00
return True
return False
Build . BuildContext . SAMBA3_IS_STATIC_MODULE = SAMBA3_IS_STATIC_MODULE
def SAMBA3_IS_SHARED_MODULE ( bld , module ) :
''' Check whether module is in shared list '''
2010-12-01 12:10:03 +01:00
if module in bld . env [ ' shared_modules ' ] :
2010-09-26 10:44:27 +02:00
return True
return False
Build . BuildContext . SAMBA3_IS_SHARED_MODULE = SAMBA3_IS_SHARED_MODULE
def SAMBA3_IS_ENABLED_MODULE ( bld , module ) :
''' Check whether module is in either shared or static list '''
return SAMBA3_IS_STATIC_MODULE ( bld , module ) or SAMBA3_IS_SHARED_MODULE ( bld , module )
Build . BuildContext . SAMBA3_IS_ENABLED_MODULE = SAMBA3_IS_ENABLED_MODULE
2011-02-17 14:11:33 +11:00
def s3_fix_kwargs ( bld , kwargs ) :
''' fix the build arguments for s3 build rules to include the
2012-02-09 13:08:31 +01:00
necessary includes , subdir and cflags options '''
2011-02-17 14:11:33 +11:00
s3dir = os . path . join ( bld . env . srcdir , ' source3 ' )
2019-11-04 17:07:44 +13:00
s3reldir = os . path . relpath ( s3dir , bld . path . abspath ( ) )
2011-02-17 14:11:33 +11:00
# the extra_includes list is relative to the source3 directory
2015-03-12 14:40:16 +00:00
extra_includes = [ ' . ' , ' include ' , ' lib ' ]
2021-12-02 11:33:02 +13:00
# local heimdal paths must only be included when using our embedded Heimdal
if bld . CONFIG_SET ( " USING_EMBEDDED_HEIMDAL " ) :
2022-01-19 13:15:45 +01:00
extra_includes + = [ ' ../third_party/heimdal/lib/com_err ' ,
' ../third_party/heimdal/lib/base ' ,
' ../third_party/heimdal/lib/krb5 ' ,
' ../third_party/heimdal/lib/gssapi/gssapi ' ,
' ../third_party/heimdal_build/include ' ,
' ../bin/default/third_party/heimdal/lib/asn1 ' ]
2011-02-17 14:11:33 +11:00
2012-06-18 22:30:04 +09:30
if bld . CONFIG_SET ( ' USING_SYSTEM_TDB ' ) :
2023-12-17 08:37:33 -08:00
( tdb_includes , tdb_ldflags , tdb_cpppath , tdb_libs ) = library_flags ( bld , ' tdb ' )
2012-06-18 22:30:04 +09:30
extra_includes + = tdb_cpppath
2011-06-20 18:40:34 +09:30
else :
2012-06-18 22:30:04 +09:30
extra_includes + = [ ' ../lib/tdb/include ' ]
2011-02-17 14:11:33 +11:00
2012-04-11 15:16:05 +10:00
if bld . CONFIG_SET ( ' USING_SYSTEM_TEVENT ' ) :
2023-12-17 08:37:33 -08:00
( tevent_includes , tevent_ldflags , tevent_cpppath , tevent_libs ) = library_flags ( bld , ' tevent ' )
2012-04-11 18:40:27 +10:00
extra_includes + = tevent_cpppath
2012-04-11 09:36:12 +10:00
else :
2011-02-17 14:11:33 +11:00
extra_includes + = [ ' ../lib/tevent ' ]
2012-04-11 09:36:12 +10:00
if bld . CONFIG_SET ( ' USING_SYSTEM_TALLOC ' ) :
2023-12-17 08:37:33 -08:00
( talloc_includes , talloc_ldflags , talloc_cpppath , talloc_libs ) = library_flags ( bld , ' talloc ' )
2012-04-11 18:40:27 +10:00
extra_includes + = talloc_cpppath
2012-04-11 09:36:12 +10:00
else :
2011-02-17 14:11:33 +11:00
extra_includes + = [ ' ../lib/talloc ' ]
2012-04-11 09:36:12 +10:00
if bld . CONFIG_SET ( ' USING_SYSTEM_POPT ' ) :
2023-12-17 08:37:33 -08:00
( popt_includes , popt_ldflags , popt_cpppath , popt_libs ) = library_flags ( bld , ' popt ' )
2012-04-11 18:40:27 +10:00
extra_includes + = popt_cpppath
2012-04-11 09:36:12 +10:00
else :
2011-02-18 15:33:25 +01:00
extra_includes + = [ ' ../lib/popt ' ]
2011-02-17 14:11:33 +11:00
# s3 builds assume that they will have a bunch of extra include paths
includes = [ ]
for d in extra_includes :
includes + = [ os . path . join ( s3reldir , d ) ]
# the rule may already have some includes listed
if ' includes ' in kwargs :
includes + = TO_LIST ( kwargs [ ' includes ' ] )
kwargs [ ' includes ' ] = includes
# these wrappers allow for mixing of S3 and S4 build rules in the one build
def SAMBA3_LIBRARY ( bld , name , * args , * * kwargs ) :
2012-02-09 13:08:31 +01:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_LIBRARY ( name , * args , * * kwargs )
2011-02-17 14:11:33 +11:00
Build . BuildContext . SAMBA3_LIBRARY = SAMBA3_LIBRARY
2021-08-20 23:05:57 +02:00
def SAMBA3_PLUGIN ( bld , name , * args , * * kwargs ) :
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_PLUGIN ( name , * args , * * kwargs )
Build . BuildContext . SAMBA3_PLUGIN = SAMBA3_PLUGIN
2011-02-17 14:11:33 +11:00
def SAMBA3_MODULE ( bld , name , * args , * * kwargs ) :
2012-02-09 13:08:31 +01:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_MODULE ( name , * args , * * kwargs )
2011-02-17 14:11:33 +11:00
Build . BuildContext . SAMBA3_MODULE = SAMBA3_MODULE
def SAMBA3_SUBSYSTEM ( bld , name , * args , * * kwargs ) :
2012-02-09 13:08:31 +01:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_SUBSYSTEM ( name , * args , * * kwargs )
2011-02-17 14:11:33 +11:00
Build . BuildContext . SAMBA3_SUBSYSTEM = SAMBA3_SUBSYSTEM
def SAMBA3_BINARY ( bld , name , * args , * * kwargs ) :
2012-02-09 13:08:31 +01:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_BINARY ( name , * args , * * kwargs )
2011-02-17 14:11:33 +11:00
Build . BuildContext . SAMBA3_BINARY = SAMBA3_BINARY
2011-08-10 13:43:18 +10:00
def SAMBA3_PYTHON ( bld , name , * args , * * kwargs ) :
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_PYTHON ( name , * args , * * kwargs )
Build . BuildContext . SAMBA3_PYTHON = SAMBA3_PYTHON