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

* Re: [PATCH] slightly enhance cross builds
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Alexey Dobriyan @ 2005-11-07 14:53 UTC (permalink / raw)
  To: Jan Beulich; +Cc: sam, linux-kernel

On Mon, Nov 07, 2005 at 01:58:46PM +0100, Jan Beulich wrote:
> 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)

Put something like this into your ~/bin and forget. Or use Al's kmk
script: ftp://ftp.linux.org.uk/pub/people/viro/

$ cat ~/bin/cross-compile
#!/bin/sh

case "$#" in
0)
	echo "usage: cross-compile ARCH ..." >&2
	exit 1
	;;
esac

ARCH="$1"
shift
case $ARCH in
alpha|arm|m68k|s390|sh|sh64|sparc|sparc64|x86_64)
	CROSS_COMPILE=$ARCH-unknown-linux-gnu-
	;;
parisc)
	CROSS_COMPILE=hppa-unknown-linux-gnu-
	;;
ppc)
	CROSS_COMPILE=powerpc-unknown-linux-gnu-
	;;
ppc64)
	CROSS_COMPILE=powerpc64-unknown-linux-gnu-
	;;
*)
	echo "cross-compile: -ENOCROSSCOMPILER for $ARCH" >&2
	exit 1
	;;
esac
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE "$@"


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

* Re: [PATCH] slightly enhance cross builds
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2005-11-07 23:04 UTC (permalink / raw)
  To: Jan Beulich; +Cc: linux-kernel

On Mon, Nov 07, 2005 at 01:58:46PM +0100, Jan Beulich wrote:
> 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).

This patch introduce different behaviour with and without make O=
This will result on confusion and is bad.

The right approach is to come up with a patch that works in both cases.

	Sam

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

* Re: [PATCH] slightly enhance cross builds
  2005-11-07 23:04 ` Sam Ravnborg
@ 2005-11-08  7:50   ` Jan Beulich
  2005-11-08 21:28     ` Sam Ravnborg
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2005-11-08  7:50 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

>>> Sam Ravnborg <sam@ravnborg.org> 08.11.05 00:04:26 >>>
>On Mon, Nov 07, 2005 at 01:58:46PM +0100, Jan Beulich wrote:
>> 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).
>
>This patch introduce different behaviour with and without make O=
>This will result on confusion and is bad.

Though I admit that I never build inside the source tree, I can't see
what you apparently do. Where/how would the behavior differ? If you just
mean the fact that in-source-tree builds will need to continue to
specify ARCH/SUBARCH on the make command line, then of course yes, this
is going to be different. But building in the source tree is a bad idea
in general in my opinion, and hence I would view this as the price you
pay. Of course this information could be stored in a hidden file in the
output tree (rather than in mkmakefile itself) if that's more
desirable...

>The right approach is to come up with a patch that works in both
cases.

Jan

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

* Re: [PATCH] slightly enhance cross builds
  2005-11-08  7:50   ` Jan Beulich
@ 2005-11-08 21:28     ` Sam Ravnborg
  0 siblings, 0 replies; 5+ messages in thread
From: Sam Ravnborg @ 2005-11-08 21:28 UTC (permalink / raw)
  To: Jan Beulich; +Cc: linux-kernel, Roman Zippel

On Tue, Nov 08, 2005 at 08:50:52AM +0100, Jan Beulich wrote:
> 
> Though I admit that I never build inside the source tree, I can't see
> what you apparently do. Where/how would the behavior differ? If you just
> mean the fact that in-source-tree builds will need to continue to
> specify ARCH/SUBARCH on the make command line, then of course yes, this
> is going to be different. But building in the source tree is a bad idea
> in general in my opinion, and hence I would view this as the price you
> pay.
That's anyway how most users builds kernel.

> Of course this information could be stored in a hidden file in the
> output tree (rather than in mkmakefile itself) if that's more
> desirable...
Plan has been to add this during *config step to .config.
But I have been sidetracked the few times I looked at it.

Having it as part of *config process is good because
- this is when you configure the kernel
- .config is a natural file to keep configuration within
- and then we have same functionality with and without O=...

	Sam

^ 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