diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-04-12 22:06:51 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-04-12 23:13:30 +1000 |
commit | d12605c679cf4f2c5057c548de1210e7fa03a2f1 (patch) | |
tree | 55947166783069670fcded9cc18d392433482946 /buildtools | |
parent | 83312a9e501ebbee15b4fd2353330880496f4add (diff) | |
download | samba-d12605c679cf4f2c5057c548de1210e7fa03a2f1.tar.gz samba-d12605c679cf4f2c5057c548de1210e7fa03a2f1.tar.bz2 samba-d12605c679cf4f2c5057c548de1210e7fa03a2f1.zip |
build: added cross-compilation configure options
this enables use of a cross-compilation emulator, so configure tests
run on an emulator of the target platform
Diffstat (limited to 'buildtools')
-rw-r--r-- | buildtools/wafsamba/samba_autoconf.py | 4 | ||||
-rw-r--r-- | buildtools/wafsamba/samba_cross.py | 34 | ||||
-rw-r--r-- | buildtools/wafsamba/wscript | 15 |
3 files changed, 53 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index d12fb9d9cd..cbb10a27ca 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -4,6 +4,7 @@ import Build, os, Options, preproc, Logs import string from Configure import conf from samba_utils import * +import samba_cross missing_headers = set() @@ -367,6 +368,8 @@ def CHECK_CODE(conf, code, define, cflags = TO_LIST(cflags) cflags.extend(ccflags) + exec_args = conf.SAMBA_CROSS_ARGS() + ret = conf.check(fragment=fragment, execute=execute, define_name = define, @@ -378,6 +381,7 @@ def CHECK_CODE(conf, code, define, type=type, msg=msg, quote=quote, + exec_args=exec_args, define_ret=define_ret) if not ret and CONFIG_SET(conf, define): # sometimes conf.check() returns false, but it diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py new file mode 100644 index 0000000000..70d74e0c94 --- /dev/null +++ b/buildtools/wafsamba/samba_cross.py @@ -0,0 +1,34 @@ +# functions for handling cross-compilation + +import pproc, Utils +from Configure import conf +from pproc import Popen + +real_Popen = None + +class cross_Popen(Popen): + '''cross-compilation wrapper for Popen''' + def __init__(*k, **kw): + (obj, args) = k + if '--cross-execute' in args: + # when --cross-execute is set, then change the arguments + # to use the cross emulator + i = args.index('--cross-execute') + newargs = args[i+1].split() + newargs.extend(args[0:i]) + args = newargs + Popen.__init__(*(obj, args), **kw) + + +@conf +def SAMBA_CROSS_ARGS(conf): + '''get exec_args to pass when running cross compiled binaries''' + if not conf.env.CROSS_COMPILE or not conf.env.CROSS_EXECUTE: + return [] + + global real_Popen + if real_Popen is None: + real_Popen = Utils.pproc.Popen + Utils.pproc.Popen = cross_Popen + + return ['--cross-execute', conf.env.CROSS_EXECUTE] diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 2e42139bb9..87e70702dc 100644 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -68,6 +68,17 @@ def set_options(opt): help=("Enable even more compiler warnings"), action='store_true', dest='pedantic', default=False) + opt.add_option('--cross-compile', + help=("configure for cross-compilation"), + action='store_true', dest='CROSS_COMPILE', default=False) + opt.add_option('--cross-execute', + help=("command prefix to use for cross-execution in configure"), + action='store', dest='CROSS_EXECUTE', default='') + opt.add_option('--hostcc', + help=("set host compiler when cross compiling"), + action='store', dest='HOSTCC', default=False) + + @wafsamba.runonce def configure(conf): conf.env.hlist = [] @@ -105,6 +116,10 @@ def configure(conf): conf.env.BUNDLED_EXTENSION = Options.options.BUNDLED_EXTENSION conf.env.BUNDLED_EXTENSION_EXCEPTION = Options.options.BUNDLED_EXTENSION_EXCEPTION.split(',') + conf.env.CROSS_COMPILE = Options.options.CROSS_COMPILE + conf.env.CROSS_EXECUTE = Options.options.CROSS_EXECUTE + conf.env.HOSTCC = Options.options.HOSTCC + # see if we can compile and run a simple C program conf.CHECK_CODE('printf("hello world\\n")', define='HAVE_SIMPLE_C_PROG', |