mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: <sam@ravnborg.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] slightly enhance cross builds
Date: Mon, 07 Nov 2005 13:58:46 +0100	[thread overview]
Message-ID: <436F5D96.76F0.0078.0@novell.com> (raw)

[-- 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
 

             reply	other threads:[~2005-11-07 12:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-07 12:58 Jan Beulich [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=436F5D96.76F0.0078.0@novell.com \
    --to=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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