aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJohn Rigby <john.rigby@linaro.org>2011-03-02 20:57:21 -0500
committerLuis Henriques <luis.henriques@canonical.com>2012-03-26 05:27:07 -0400
commita6b3d7a1815c4a11efacd4ef8141a02eb9805a79 (patch)
tree30a5bea756cba9c71ca0d4bc6017d52668e07f86 /scripts
parentd4920420d54c6d433fd7f185341daed4787a2fdd (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.include6
-rw-r--r--scripts/Makefile.build6
-rw-r--r--scripts/kconfig/Makefile34
-rw-r--r--scripts/mod/Makefile10
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
221ifeq ($(KBUILD_SCRIPTROOT),)
222KBUILD_SCRIPTROOT=.
223endif
224
221# Execute the command and also postprocess generated .d dependencies file. 225# Execute the command and also postprocess generated .d dependencies file.
222if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ 226if_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;
289endif 289endif
290 290
291ifeq ($(KBUILD_SCRIPTROOT),)
292KBUILD_SCRIPTROOT=.
293endif
294
291define rule_cc_o_c 295define 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
11Kconfig := Kconfig 11Kconfig := Kconfig
12endif 12endif
13 13
14ifdef KBUILD_SCRIPTROOT
15CONF = $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf
16else
17CONF = $(obj)/conf
18endif
19
14xconfig: $(obj)/qconf 20xconfig: $(obj)/qconf
15 $< $(Kconfig) 21 $< $(Kconfig)
16 22
@@ -20,16 +26,16 @@ gconfig: $(obj)/gconf
20menuconfig: $(obj)/mconf 26menuconfig: $(obj)/mconf
21 $< $(Kconfig) 27 $< $(Kconfig)
22 28
23config: $(obj)/conf 29config: $(CONF)
24 $< --oldaskconfig $(Kconfig) 30 $< --oldaskconfig $(Kconfig)
25 31
26nconfig: $(obj)/nconf 32nconfig: $(obj)/nconf
27 $< $(Kconfig) 33 $< $(Kconfig)
28 34
29oldconfig: $(obj)/conf 35oldconfig: $(CONF)
30 $< --$@ $(Kconfig) 36 $< --$@ $(Kconfig)
31 37
32silentoldconfig: $(obj)/conf 38silentoldconfig: $(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)),)
41endif 47endif
42endif 48endif
43 49
44localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 50localmodconfig: $(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
59localyesconfig: $(obj)/streamline_config.pl $(obj)/conf 65localyesconfig: $(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
99PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig 105PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
100 106
101allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf 107allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(CONF)
102 $< --$@ $(Kconfig) 108 $< --$@ $(Kconfig)
103 109
104PHONY += listnewconfig oldnoconfig savedefconfig defconfig 110PHONY += listnewconfig oldnoconfig savedefconfig defconfig
105 111
106listnewconfig oldnoconfig: $(obj)/conf 112listnewconfig oldnoconfig: $(CONF)
107 $< --$@ $(Kconfig) 113 $< --$@ $(Kconfig)
108 114
109savedefconfig: $(obj)/conf 115savedefconfig: $(CONF)
110 $< --$@=defconfig $(Kconfig) 116 $< --$@=defconfig $(Kconfig)
111 117
112defconfig: $(obj)/conf 118defconfig: $(CONF)
113ifeq ($(KBUILD_DEFCONFIG),) 119ifeq ($(KBUILD_DEFCONFIG),)
114 $< --defconfig $(Kconfig) 120 $< --defconfig $(Kconfig)
115else 121else
@@ -117,7 +123,7 @@ else
117 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 123 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
118endif 124endif
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 @@
1hostprogs-y := modpost mk_elfconfig 1hostprogs-y := modpost mk_elfconfig
2always := $(hostprogs-y) empty.o 2always := $(hostprogs-y) empty.o
3 3
4ifdef KBUILD_SCRIPTROOT
5MKELFCONFIG = $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig
6else
7MKELFCONFIG = $(obj)/mk_elfconfig
8endif
9
4modpost-objs := modpost.o file2alias.o sumversion.o 10modpost-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
10quiet_cmd_elfconfig = MKELF $@ 16quiet_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
16targets += elfconfig.h 22targets += elfconfig.h