from samba_python import *
from samba_deps import *
from samba_bundled import *
+from samba_third_party import *
import samba_install
import samba_conftests
import samba_abi
# this allows all of the bin/shared and bin/python targets
# to be expressed in terms of build directory paths
mkdir_p(os.path.join(conf.blddir, 'default'))
- for p in ['python','shared', 'modules']:
- link_target = os.path.join(conf.blddir, 'default/' + p)
+ for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
+ link_target = os.path.join(conf.blddir, 'default/' + target)
if not os.path.lexists(link_target):
- os.symlink('../' + p, link_target)
+ os.symlink('../' + source, link_target)
# get perl to put the blib files in the build directory
blib_bld = os.path.join(conf.blddir, 'default/pidl/blib')
realname=None,
autoproto=None,
autoproto_extra_source='',
- group='libraries',
+ group='main',
depends_on='',
local_include=True,
global_include=True,
private_library=False,
grouping_library=False,
allow_undefined_symbols=False,
+ allow_warnings=True,
enabled=True):
'''define a Samba library'''
autoproto_extra_source=autoproto_extra_source,
depends_on = depends_on,
hide_symbols = hide_symbols,
+ allow_warnings = allow_warnings,
pyembed = pyembed,
pyext = pyext,
local_include = local_include,
if pc_files is not None and not private_library:
bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
- if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
+ if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
bld.env['XSLTPROC_MANPAGES']):
- bld.MANPAGES(manpages)
+ bld.MANPAGES(manpages, install)
Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
use_hostcc=False,
use_global_deps=True,
compiler=None,
- group='binaries',
+ group='main',
manpages=None,
local_include=True,
global_include=True,
else:
subsystem_group = group
+ # only specify PIE flags for binaries
+ pie_cflags = cflags
+ pie_ldflags = TO_LIST(ldflags)
+ if bld.env['ENABLE_PIE'] == True:
+ pie_cflags += ' -fPIE'
+ pie_ldflags.extend(TO_LIST('-pie'))
+ if bld.env['ENABLE_RELRO'] == True:
+ pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
+
# first create a target for building the object files for this binary
# by separating in this way, we avoid recompiling the C files
# separately for the install binary and the build binary
source = source,
deps = deps,
includes = includes,
- cflags = cflags,
+ cflags = pie_cflags,
group = subsystem_group,
autoproto = autoproto,
subsystem_name = subsystem_name,
install_path = None,
samba_inst_path= install_path,
samba_install = install,
- samba_ldflags = TO_LIST(ldflags)
+ samba_ldflags = pie_ldflags
)
if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
- bld.MANPAGES(manpages)
+ bld.MANPAGES(manpages, install)
Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
enabled=True,
pyembed=False,
manpages=None,
- allow_undefined_symbols=False
+ allow_undefined_symbols=False,
+ allow_warnings=True
):
'''define a Samba module.'''
cflags=cflags,
local_include=local_include,
global_include=global_include,
+ allow_warnings=allow_warnings,
enabled=enabled)
bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
install_path="${MODULESDIR}/%s" % subsystem,
pyembed=pyembed,
manpages=manpages,
- allow_undefined_symbols=allow_undefined_symbols
+ allow_undefined_symbols=allow_undefined_symbols,
+ allow_warnings=allow_warnings
)
vars=None,
subdir=None,
hide_symbols=False,
+ allow_warnings=True,
pyext=False,
pyembed=False):
'''define a Samba subsystem'''
features = features,
source = source,
target = modname,
- samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols),
+ samba_cflags = CURRENT_CFLAGS(bld, modname, cflags,
+ allow_warnings=allow_warnings,
+ hide_symbols=hide_symbols),
depends_on = depends_on,
samba_deps = TO_LIST(deps),
samba_includes = includes,
bld.add_group('headers')
bld.add_group('main')
bld.add_group('symbolcheck')
- bld.add_group('libraries')
- bld.add_group('binaries')
bld.add_group('syslibcheck')
bld.add_group('final')
Build.BuildContext.SETUP_BUILD_GROUPS = SETUP_BUILD_GROUPS
bld.SET_BUILD_GROUP('build_source')
for s in TO_LIST(source):
iname = s
- if installname != None:
+ if installname is not None:
iname = installname
target = os.path.join(installdir, iname)
tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
replacement="""sys.path.insert(0, "%s")
sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
+ shebang = None
+
+ if task.env["PYTHON"][0] == "/":
+ replacement_shebang = "#!%s\n" % task.env["PYTHON"]
+ else:
+ replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"]
+
installed_location=task.outputs[0].bldpath(task.env)
source_file = open(task.inputs[0].srcpath(task.env))
installed_file = open(installed_location, 'w')
+ lineno = 0
for line in source_file:
newline = line
- if pattern in line:
+ if lineno == 0 and task.env["PYTHON_SPECIFIED"] == True and line[:2] == "#!":
+ newline = replacement_shebang
+ elif pattern in line:
newline = line.replace(pattern, replacement)
installed_file.write(newline)
+ lineno = lineno + 1
installed_file.close()
os.chmod(installed_location, 0755)
return 0
target=inst_file)
bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONARCHDIR"])
bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONDIR"])
+ bld.add_manual_dependency(bld.path.find_or_declare(inst_file), str(bld.env["PYTHON_SPECIFIED"]))
+ bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHON"])
file = inst_file
if base_name:
file = os.path.join(base_name, file)
Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
-def MANPAGES(bld, manpages):
+def MANPAGES(bld, manpages, install):
'''build and install manual pages'''
bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
for m in manpages.split():
group='final',
rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
)
- bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
+ if install:
+ bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
Build.BuildContext.MANPAGES = MANPAGES
-def SAMBAMANPAGES(bld, manpages):
+def SAMBAMANPAGES(bld, manpages, extra_source=None):
'''build and install manual pages'''
bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
- os.environ["XML_CATALOG_FILES"] = 'file:///etc/xml/catalog file://' + bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
+ bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
+
for m in manpages.split():
source = m + '.xml'
+ if extra_source is not None:
+ source = [source, extra_source]
bld.SAMBA_GENERATOR(m,
source=source,
target=m,
group='final',
- rule='${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC} && ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'
+ rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
+ export XML_CATALOG_FILES
+ ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
+ ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
)
bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES