mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] slightly enhance cross builds
@ 2005-11-07 12:58 Jan Beulich
  2005-11-07 14:53 ` Alexey Dobriyan
  2005-11-07 23:04 ` Sam Ravnborg
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Beulich @ 2005-11-07 12:58 UTC (permalink / raw)
  To: sam; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

This adds functionality to default CROSS_COMPILE to a sensible value
when cross-building (so one doesn't always have to specify this on the
make command line), as well as storing ARCH and SUBARCH in the
Makefile
generated when building outside of the source directory (so that
subsequent make invocations don't have to always repeat these).

From: Jan Beulich <jbeulich@novell.com>

(actual patch attached)

[-- Attachment #2: linux-2.6.14-arch.patch --]
[-- Type: application/octet-stream, Size: 4017 bytes --]

This adds functionality to default CROSS_COMPILE to a sensible value
when cross-building (so one doesn't always have to specify this on the
make command line), as well as storing ARCH and SUBARCH in the Makefile
generated when building outside of the source directory (so that
subsequent make invocations don't have to always repeat these).

From: Jan Beulich <jbeulich@novell.com>

--- /home/jbeulich/tmp/linux-2.6.14/Makefile	2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14/Makefile	2005-11-04 15:05:23.000000000 +0100
@@ -160,15 +160,19 @@ LOCALVERSION = $(subst $(space),, \
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(LOCALVERSION)
 
+HOSTARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+				   -e s/arm.*/arm/ -e s/sa110/arm/ \
+				   -e s/s390x/s390/ -e s/parisc64/parisc/ )
+
 # SUBARCH tells the usermode build what the underlying arch is.  That is set
 # first, and if a usermode build is happening, the "ARCH=um" on the command
 # line overrides the setting of ARCH below.  If a native build is happening,
 # then ARCH is assigned, getting whatever value it gets normally, and 
 # SUBARCH is subsequently ignored.
 
-SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-				  -e s/arm.*/arm/ -e s/sa110/arm/ \
-				  -e s/s390x/s390/ -e s/parisc64/parisc/ )
+ifeq ($(SUBARCH),)
+SUBARCH         := $(if $(filter-out um xen,$(ARCH)),$(ARCH),$(HOSTARCH))
+endif
 
 # Cross compiling and selecting different set of gcc/bin-utils
 # ---------------------------------------------------------------------------
@@ -190,7 +198,7 @@ SUBARCH := $(shell uname -m | sed -e s/i
 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
 
 ARCH		?= $(SUBARCH)
-CROSS_COMPILE	?=
+CROSS_COMPILE	?= $(if $(filter-out $(ARCH) $(SUBARCH),$(HOSTARCH)),$(SUBARCH)-linux-)
 
 # Architecture as present in compile.h
 UTS_MACHINE := $(ARCH)
@@ -386,16 +395,19 @@ scripts_basic:
 scripts/basic/%: scripts_basic ;
 
 .PHONY: outputmakefile
-# outputmakefile generate a Makefile to be placed in output directory, if
-# using a seperate output directory. This allows convinient use
-# of make in output directory
+# outputmakefile generates a Makefile in the output directory, if
+# using a separate output directory. This allows convenient use
+# of make in the output directory.
 outputmakefile:
-	$(Q)if test ! $(srctree) -ef $(objtree); then \
-	$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile              \
-	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)         \
-	    > $(objtree)/Makefile;                                 \
-	    echo '  GEN    $(objtree)/Makefile';                   \
+ifneq ($(KBUILD_SRC),)
+	$(Q)if [ ! -r $(objtree)/Makefile -o -O $(objtree)/Makefile ]; then \
+	    echo '  GEN     $(objtree)/Makefile';                           \
+	    $(CONFIG_SHELL) $(srctree)/scripts/mkmakefile                   \
+		$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)              \
+		$(ARCH) $(SUBARCH) $(HOSTARCH)                              \
+		> $(objtree)/Makefile;                                      \
 	fi
+endif
 
 # To make sure we do not include .config for any of the *config targets
 # catch them early, and hand them over to scripts/kconfig/Makefile
--- /home/jbeulich/tmp/linux-2.6.14/scripts/mkmakefile	2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14/scripts/mkmakefile	2005-11-04 15:24:35.000000000 +0100
@@ -8,6 +8,9 @@
 # $2 - Output directory
 # $3 - version
 # $4 - patchlevel
+# $5 - architecture
+# $6 - sub-architecture
+# $7 - host architecture
 
 
 cat << EOF
@@ -20,12 +23,15 @@ KERNELSRC    := $1
 KERNELOUTPUT := $2
 
 MAKEFLAGS += --no-print-directory
+MAKEARGS  := $(echo -n "-C \$(KERNELSRC) O=\$(KERNELOUTPUT)"; \
+	test "$5" = "$7" || echo -n " ARCH=$5"; \
+	test "$6" = "$5" -o "$6" = "$7" || echo -n " SUBARCH=$6")
 
 all:
-	\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
+	\$(MAKE) \$(MAKEARGS)
 
 %::
-	\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
+	\$(MAKE) \$(MAKEARGS) \$@
 
 EOF
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-11-08 21:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-07 12:58 [PATCH] slightly enhance cross builds Jan Beulich
2005-11-07 14:53 ` Alexey Dobriyan
2005-11-07 23:04 ` Sam Ravnborg
2005-11-08  7:50   ` Jan Beulich
2005-11-08 21:28     ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome