diff options
author | John Rigby <john.rigby@linaro.org> | 2011-03-02 20:57:21 -0500 |
---|---|---|
committer | Luis Henriques <luis.henriques@canonical.com> | 2012-03-26 05:27:07 -0400 |
commit | a6b3d7a1815c4a11efacd4ef8141a02eb9805a79 (patch) | |
tree | 30a5bea756cba9c71ca0d4bc6017d52668e07f86 /scripts | |
parent | d4920420d54c6d433fd7f185341daed4787a2fdd (diff) |
KBuild: Allow scripts/* to be cross compiled
BugLink: http://bugs.launchpad.net/bugs/963823
Cross compiling the binaries in scripts/* is not possible
because various makefiles assume that $(obj)/whatever is
executable on the build host.
This patch introduces a new variable called KBUILD_SCRIPTROOT
that points to script/binaries to use while cross compiling.
Usage:
Build scripts for the build host:
make O=path/to/buildhost/buildscripts \
silentoldconfig prepare scripts
Then cross build script for target:
make O=path/to/target/buildscripts \
HOSTCC=$CROSS_COMPILE \
KBUILD_SCRIPTROOT=path/to/buildhost/buildscripts
silentoldconfig prepare scripts
This patch does not use KBUILD_SCRIPTROOT for all script invocations
it only redefines the following if KBUILD_SCRIPTROOT is defined.
scripts/Makefile.build
scripts/basic/fixdep --> $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep
scripts/kconfig/Makefile
$(obj)/conf --> $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf
scripts/mod/Makefile
$(obj)mk_elfconfig --> $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig
Signed-off-by: John Rigby <john.rigby@linaro.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Kbuild.include | 6 | ||||
-rw-r--r-- | scripts/Makefile.build | 6 | ||||
-rw-r--r-- | scripts/kconfig/Makefile | 34 | ||||
-rw-r--r-- | scripts/mod/Makefile | 10 |
4 files changed, 38 insertions, 18 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index be39cd1c74c..30103da6e38 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -218,11 +218,15 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ | |||
218 | $(echo-cmd) $(cmd_$(1)); \ | 218 | $(echo-cmd) $(cmd_$(1)); \ |
219 | echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) | 219 | echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) |
220 | 220 | ||
221 | ifeq ($(KBUILD_SCRIPTROOT),) | ||
222 | KBUILD_SCRIPTROOT=. | ||
223 | endif | ||
224 | |||
221 | # Execute the command and also postprocess generated .d dependencies file. | 225 | # Execute the command and also postprocess generated .d dependencies file. |
222 | if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ | 226 | if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ |
223 | @set -e; \ | 227 | @set -e; \ |
224 | $(echo-cmd) $(cmd_$(1)); \ | 228 | $(echo-cmd) $(cmd_$(1)); \ |
225 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ | 229 | $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ |
226 | rm -f $(depfile); \ | 230 | rm -f $(depfile); \ |
227 | mv -f $(dot-target).tmp $(dot-target).cmd) | 231 | mv -f $(dot-target).tmp $(dot-target).cmd) |
228 | 232 | ||
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a0fd5029cfe..40c3e3de323 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -288,13 +288,17 @@ cmd_record_mcount = \ | |||
288 | fi; | 288 | fi; |
289 | endif | 289 | endif |
290 | 290 | ||
291 | ifeq ($(KBUILD_SCRIPTROOT),) | ||
292 | KBUILD_SCRIPTROOT=. | ||
293 | endif | ||
294 | |||
291 | define rule_cc_o_c | 295 | define rule_cc_o_c |
292 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ | 296 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ |
293 | $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ | 297 | $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ |
294 | $(cmd_modversions) \ | 298 | $(cmd_modversions) \ |
295 | $(call echo-cmd,record_mcount) \ | 299 | $(call echo-cmd,record_mcount) \ |
296 | $(cmd_record_mcount) \ | 300 | $(cmd_record_mcount) \ |
297 | scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ | 301 | $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ |
298 | $(dot-target).tmp; \ | 302 | $(dot-target).tmp; \ |
299 | rm -f $(depfile); \ | 303 | rm -f $(depfile); \ |
300 | mv -f $(dot-target).tmp $(dot-target).cmd | 304 | mv -f $(dot-target).tmp $(dot-target).cmd |
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index faa9a4701b6..ada56df8714 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
@@ -11,6 +11,12 @@ else | |||
11 | Kconfig := Kconfig | 11 | Kconfig := Kconfig |
12 | endif | 12 | endif |
13 | 13 | ||
14 | ifdef KBUILD_SCRIPTROOT | ||
15 | CONF = $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf | ||
16 | else | ||
17 | CONF = $(obj)/conf | ||
18 | endif | ||
19 | |||
14 | xconfig: $(obj)/qconf | 20 | xconfig: $(obj)/qconf |
15 | $< $(Kconfig) | 21 | $< $(Kconfig) |
16 | 22 | ||
@@ -20,16 +26,16 @@ gconfig: $(obj)/gconf | |||
20 | menuconfig: $(obj)/mconf | 26 | menuconfig: $(obj)/mconf |
21 | $< $(Kconfig) | 27 | $< $(Kconfig) |
22 | 28 | ||
23 | config: $(obj)/conf | 29 | config: $(CONF) |
24 | $< --oldaskconfig $(Kconfig) | 30 | $< --oldaskconfig $(Kconfig) |
25 | 31 | ||
26 | nconfig: $(obj)/nconf | 32 | nconfig: $(obj)/nconf |
27 | $< $(Kconfig) | 33 | $< $(Kconfig) |
28 | 34 | ||
29 | oldconfig: $(obj)/conf | 35 | oldconfig: $(CONF) |
30 | $< --$@ $(Kconfig) | 36 | $< --$@ $(Kconfig) |
31 | 37 | ||
32 | silentoldconfig: $(obj)/conf | 38 | silentoldconfig: $(CONF) |
33 | $(Q)mkdir -p include/generated | 39 | $(Q)mkdir -p include/generated |
34 | $< --$@ $(Kconfig) | 40 | $< --$@ $(Kconfig) |
35 | 41 | ||
@@ -41,22 +47,22 @@ ifeq ($(findstring /,$(LSMOD)),) | |||
41 | endif | 47 | endif |
42 | endif | 48 | endif |
43 | 49 | ||
44 | localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | 50 | localmodconfig: $(obj)/streamline_config.pl $(CONF) |
45 | $(Q)mkdir -p include/generated | 51 | $(Q)mkdir -p include/generated |
46 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config | 52 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config |
47 | $(Q)if [ -f .config ]; then \ | 53 | $(Q)if [ -f .config ]; then \ |
48 | cmp -s .tmp.config .config || \ | 54 | cmp -s .tmp.config .config || \ |
49 | (mv -f .config .config.old.1; \ | 55 | (mv -f .config .config.old.1; \ |
50 | mv -f .tmp.config .config; \ | 56 | mv -f .tmp.config .config; \ |
51 | $(obj)/conf --silentoldconfig $(Kconfig); \ | 57 | $(CONF) --silentoldconfig $(Kconfig); \ |
52 | mv -f .config.old.1 .config.old) \ | 58 | mv -f .config.old.1 .config.old) \ |
53 | else \ | 59 | else \ |
54 | mv -f .tmp.config .config; \ | 60 | mv -f .tmp.config .config; \ |
55 | $(obj)/conf --silentoldconfig $(Kconfig); \ | 61 | $(CONF) --silentoldconfig $(Kconfig); \ |
56 | fi | 62 | fi |
57 | $(Q)rm -f .tmp.config | 63 | $(Q)rm -f .tmp.config |
58 | 64 | ||
59 | localyesconfig: $(obj)/streamline_config.pl $(obj)/conf | 65 | localyesconfig: $(obj)/streamline_config.pl $(CONF) |
60 | $(Q)mkdir -p include/generated | 66 | $(Q)mkdir -p include/generated |
61 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config | 67 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config |
62 | $(Q)sed -i s/=m/=y/ .tmp.config | 68 | $(Q)sed -i s/=m/=y/ .tmp.config |
@@ -64,11 +70,11 @@ localyesconfig: $(obj)/streamline_config.pl $(obj)/conf | |||
64 | cmp -s .tmp.config .config || \ | 70 | cmp -s .tmp.config .config || \ |
65 | (mv -f .config .config.old.1; \ | 71 | (mv -f .config .config.old.1; \ |
66 | mv -f .tmp.config .config; \ | 72 | mv -f .tmp.config .config; \ |
67 | $(obj)/conf --silentoldconfig $(Kconfig); \ | 73 | $(CONF) --silentoldconfig $(Kconfig); \ |
68 | mv -f .config.old.1 .config.old) \ | 74 | mv -f .config.old.1 .config.old) \ |
69 | else \ | 75 | else \ |
70 | mv -f .tmp.config .config; \ | 76 | mv -f .tmp.config .config; \ |
71 | $(obj)/conf --silentoldconfig $(Kconfig); \ | 77 | $(CONF) --silentoldconfig $(Kconfig); \ |
72 | fi | 78 | fi |
73 | $(Q)rm -f .tmp.config | 79 | $(Q)rm -f .tmp.config |
74 | 80 | ||
@@ -98,18 +104,18 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | |||
98 | 104 | ||
99 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig | 105 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig |
100 | 106 | ||
101 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf | 107 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(CONF) |
102 | $< --$@ $(Kconfig) | 108 | $< --$@ $(Kconfig) |
103 | 109 | ||
104 | PHONY += listnewconfig oldnoconfig savedefconfig defconfig | 110 | PHONY += listnewconfig oldnoconfig savedefconfig defconfig |
105 | 111 | ||
106 | listnewconfig oldnoconfig: $(obj)/conf | 112 | listnewconfig oldnoconfig: $(CONF) |
107 | $< --$@ $(Kconfig) | 113 | $< --$@ $(Kconfig) |
108 | 114 | ||
109 | savedefconfig: $(obj)/conf | 115 | savedefconfig: $(CONF) |
110 | $< --$@=defconfig $(Kconfig) | 116 | $< --$@=defconfig $(Kconfig) |
111 | 117 | ||
112 | defconfig: $(obj)/conf | 118 | defconfig: $(CONF) |
113 | ifeq ($(KBUILD_DEFCONFIG),) | 119 | ifeq ($(KBUILD_DEFCONFIG),) |
114 | $< --defconfig $(Kconfig) | 120 | $< --defconfig $(Kconfig) |
115 | else | 121 | else |
@@ -117,7 +123,7 @@ else | |||
117 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) | 123 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) |
118 | endif | 124 | endif |
119 | 125 | ||
120 | %_defconfig: $(obj)/conf | 126 | %_defconfig: $(CONF) |
121 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) | 127 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) |
122 | 128 | ||
123 | # Help text used by make help | 129 | # Help text used by make help |
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index ff954f8168c..258d4ba32d5 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile | |||
@@ -1,6 +1,12 @@ | |||
1 | hostprogs-y := modpost mk_elfconfig | 1 | hostprogs-y := modpost mk_elfconfig |
2 | always := $(hostprogs-y) empty.o | 2 | always := $(hostprogs-y) empty.o |
3 | 3 | ||
4 | ifdef KBUILD_SCRIPTROOT | ||
5 | MKELFCONFIG = $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig | ||
6 | else | ||
7 | MKELFCONFIG = $(obj)/mk_elfconfig | ||
8 | endif | ||
9 | |||
4 | modpost-objs := modpost.o file2alias.o sumversion.o | 10 | modpost-objs := modpost.o file2alias.o sumversion.o |
5 | 11 | ||
6 | # dependencies on generated files need to be listed explicitly | 12 | # dependencies on generated files need to be listed explicitly |
@@ -8,9 +14,9 @@ modpost-objs := modpost.o file2alias.o sumversion.o | |||
8 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h | 14 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h |
9 | 15 | ||
10 | quiet_cmd_elfconfig = MKELF $@ | 16 | quiet_cmd_elfconfig = MKELF $@ |
11 | cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ | 17 | cmd_elfconfig = $(MKELFCONFIG) < $< > $@ |
12 | 18 | ||
13 | $(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE | 19 | $(obj)/elfconfig.h: $(obj)/empty.o $(MKELFCONFIG) FORCE |
14 | $(call if_changed,elfconfig) | 20 | $(call if_changed,elfconfig) |
15 | 21 | ||
16 | targets += elfconfig.h | 22 | targets += elfconfig.h |