2010-04-11 11:35:08 +04:00
# a waf tool to add autoconf-like macros to the configure section
# and for SAMBA_ macros for building libraries, binaries etc
2011-02-17 06:11:33 +03:00
import Options , Build , os
2010-04-11 11:35:08 +04:00
from optparse import SUPPRESS_HELP
2011-02-17 06:11:33 +03:00
from samba_utils import os_path_relpath , TO_LIST
2012-04-11 03:36:12 +04:00
from samba_autoconf import library_flags
2010-04-11 11:35:08 +04:00
2010-04-11 12:34:12 +04:00
def SAMBA3_ADD_OPTION ( opt , option , help = ( ) , dest = None , default = True ,
with_name = " with " , without_name = " without " ) :
2013-03-22 12:37:09 +04:00
if default is None :
default_str = " auto "
2014-06-02 04:36:13 +04:00
elif default is True :
2013-03-22 12:37:09 +04:00
default_str = " yes "
2014-06-02 04:36:13 +04:00
elif default is False :
2013-03-22 12:37:09 +04:00
default_str = " no "
else :
default_str = str ( default )
2010-04-11 11:35:08 +04:00
if help == ( ) :
2013-03-22 12:37:09 +04:00
help = ( " Build with %s support (default= %s ) " % ( option , default_str ) )
2010-04-11 11:35:08 +04:00
if dest is None :
2010-04-30 16:21:28 +04:00
dest = " with_ %s " % option . replace ( ' - ' , ' _ ' )
2010-04-11 11:35:08 +04:00
2010-04-11 12:34:12 +04:00
with_val = " -- %s - %s " % ( with_name , option )
without_val = " -- %s - %s " % ( without_name , option )
2010-04-11 11:35:08 +04:00
2010-04-30 16:22:06 +04:00
#FIXME: This is broken and will always default to "default" no matter if
# --with or --without is chosen.
2010-04-11 11:35:08 +04:00
opt . add_option ( with_val , help = help , action = " store_true " , dest = dest ,
default = default )
opt . add_option ( without_val , help = SUPPRESS_HELP , action = " store_false " ,
dest = dest )
Options . Handler . SAMBA3_ADD_OPTION = SAMBA3_ADD_OPTION
2010-09-26 12:44:27 +04:00
def SAMBA3_IS_STATIC_MODULE ( bld , module ) :
''' Check whether module is in static list '''
2010-12-01 14:10:03 +03:00
if module in bld . env [ ' static_modules ' ] :
2010-09-26 12:44:27 +04: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 14:10:03 +03:00
if module in bld . env [ ' shared_modules ' ] :
2010-09-26 12:44:27 +04: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 06:11:33 +03:00
def s3_fix_kwargs ( bld , kwargs ) :
''' fix the build arguments for s3 build rules to include the
2012-02-09 16:08:31 +04:00
necessary includes , subdir and cflags options '''
2011-02-17 06:11:33 +03:00
s3dir = os . path . join ( bld . env . srcdir , ' source3 ' )
s3reldir = os_path_relpath ( s3dir , bld . curdir )
# the extra_includes list is relative to the source3 directory
2011-06-20 13:10:25 +04:00
extra_includes = [ ' . ' , ' include ' , ' lib ' , ' ../lib/tdb_compat ' ]
2012-03-30 17:19:14 +04:00
# local heimdal paths only included when USING_SYSTEM_KRB5 is not set
2011-09-01 06:45:38 +04:00
if not bld . CONFIG_SET ( " USING_SYSTEM_KRB5 " ) :
2011-02-17 06:11:33 +03:00
extra_includes + = [ ' ../source4/heimdal/lib/com_err ' ,
2012-04-24 20:37:13 +04:00
' ../source4/heimdal/lib/krb5 ' ,
2011-02-17 06:11:33 +03:00
' ../source4/heimdal/lib/gssapi ' ,
2012-04-24 20:37:13 +04:00
' ../source4/heimdal_build ' ,
' ../bin/default/source4/heimdal/lib/asn1 ' ]
2011-02-17 06:11:33 +03:00
2012-06-18 17:00:04 +04:00
if bld . CONFIG_SET ( ' USING_SYSTEM_TDB ' ) :
( tdb_includes , tdb_ldflags , tdb_cpppath ) = library_flags ( bld , ' tdb ' )
extra_includes + = tdb_cpppath
2011-06-20 13:10:34 +04:00
else :
2012-06-18 17:00:04 +04:00
extra_includes + = [ ' ../lib/tdb/include ' ]
2011-02-17 06:11:33 +03:00
2012-04-11 09:16:05 +04:00
if bld . CONFIG_SET ( ' USING_SYSTEM_TEVENT ' ) :
2012-04-11 12:40:27 +04:00
( tevent_includes , tevent_ldflags , tevent_cpppath ) = library_flags ( bld , ' tevent ' )
extra_includes + = tevent_cpppath
2012-04-11 03:36:12 +04:00
else :
2011-02-17 06:11:33 +03:00
extra_includes + = [ ' ../lib/tevent ' ]
2012-04-11 03:36:12 +04:00
if bld . CONFIG_SET ( ' USING_SYSTEM_TALLOC ' ) :
2012-04-11 12:40:27 +04:00
( talloc_includes , talloc_ldflags , talloc_cpppath ) = library_flags ( bld , ' talloc ' )
extra_includes + = talloc_cpppath
2012-04-11 03:36:12 +04:00
else :
2011-02-17 06:11:33 +03:00
extra_includes + = [ ' ../lib/talloc ' ]
2012-04-11 03:36:12 +04:00
if bld . CONFIG_SET ( ' USING_SYSTEM_POPT ' ) :
2012-04-11 12:40:27 +04:00
( popt_includes , popt_ldflags , popt_cpppath ) = library_flags ( bld , ' popt ' )
extra_includes + = popt_cpppath
2012-04-11 03:36:12 +04:00
else :
2011-02-18 17:33:25 +03:00
extra_includes + = [ ' ../lib/popt ' ]
2011-02-17 06:11:33 +03: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 16:08:31 +04:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_LIBRARY ( name , * args , * * kwargs )
2011-02-17 06:11:33 +03:00
Build . BuildContext . SAMBA3_LIBRARY = SAMBA3_LIBRARY
def SAMBA3_MODULE ( bld , name , * args , * * kwargs ) :
2012-02-09 16:08:31 +04:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_MODULE ( name , * args , * * kwargs )
2011-02-17 06:11:33 +03:00
Build . BuildContext . SAMBA3_MODULE = SAMBA3_MODULE
def SAMBA3_SUBSYSTEM ( bld , name , * args , * * kwargs ) :
2012-02-09 16:08:31 +04:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_SUBSYSTEM ( name , * args , * * kwargs )
2011-02-17 06:11:33 +03:00
Build . BuildContext . SAMBA3_SUBSYSTEM = SAMBA3_SUBSYSTEM
def SAMBA3_BINARY ( bld , name , * args , * * kwargs ) :
2012-02-09 16:08:31 +04:00
s3_fix_kwargs ( bld , kwargs )
return bld . SAMBA_BINARY ( name , * args , * * kwargs )
2011-02-17 06:11:33 +03:00
Build . BuildContext . SAMBA3_BINARY = SAMBA3_BINARY
2011-08-10 07:43:18 +04: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