All of lore.kernel.org
 help / color / mirror / Atom feed
* kbuild feature/question: default ARCH
@ 2007-02-14  6:06 Randy Dunlap
  2007-02-14  6:23 ` Randy Dunlap
  2007-02-14  9:11 ` Sam Ravnborg
  0 siblings, 2 replies; 4+ messages in thread
From: Randy Dunlap @ 2007-02-14  6:06 UTC (permalink / raw)
  To: lkml; +Cc: olecom, sam, zippel

Hi,

I'd like for kbuild to default ARCH to the already-symlinked
arch in include/asm-$(ARCH) if ARCH is not specified on the
command line or in the environment.  I have a non-working patch,
complete with a circular dependency which is dropped:

make: Circular ' <- ' dependency dropped.

Any suggestions for how to complete this?

Thanks.
---

From: Randy Dunlap <randy.dunlap@oracle.com>

If ARCH is unspecified (command line or environment) and if
include/asm is already a symlink to include/asm-$ARCH,
use that ARCH as the default instead of the host ARCH.
Undo the effect of this by using 'make mrproper' or just 'rm include/asm'.

This allows us to drop 'ARCH=fobr' for subsequent builds of the same
ARCH, after using it in a build one time (not counting make *config).

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 Makefile |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

--- linux-2.6.20-git9.orig/Makefile
+++ linux-2.6.20-git9/Makefile
@@ -172,6 +172,10 @@ SUBARCH := $(shell uname -m | sed -e s/i
 # make ARCH=ia64
 # Another way is to have ARCH set in the environment.
 # The default ARCH is the host where make is executed.
+#
+# However, if include/asm is already a symlink to include/asm-$ARCH,
+# use that ARCH as the default instead of the host ARCH.
+# Undo the effect of this by using 'make mrproper' or just 'rm include/asm'.
 
 # CROSS_COMPILE specify the prefix used for all executables used
 # during compilation. Only gcc and related bin-utils executables
@@ -182,6 +186,20 @@ SUBARCH := $(shell uname -m | sed -e s/i
 # Default value for CROSS_COMPILE is not to prefix executables
 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
 
+# if ARCH is unspecified & symlink include/asm exists, set ARCH to
+# its symlink arch
+@echo '  CHK DEF ARCH -> include/asm:'
+$(Q)if [ "$(ARCH)" == "" -a -h $(srctree)/include/asm ]; then \
+	symlink=`readlink include/asm` \
+	len=`expr length $symlink` \
+	if [ len -le 4 ]; then \
+		@echo '    no symlink for include/asm' \
+	else \
+		ARCH=${symlink:4} \
+		@echo '    ARCH symlink to ${ARCH}' \
+	fi \
+fi
+
 ARCH		?= $(SUBARCH)
 CROSS_COMPILE	?=
 

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

* Re: kbuild feature/question: default ARCH
  2007-02-14  6:06 kbuild feature/question: default ARCH Randy Dunlap
@ 2007-02-14  6:23 ` Randy Dunlap
  2007-02-14  9:11 ` Sam Ravnborg
  1 sibling, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2007-02-14  6:23 UTC (permalink / raw)
  To: lkml; +Cc: olecom, sam, zippel

On Tue, 13 Feb 2007 22:06:19 -0800 Randy Dunlap wrote:

> ---
> 
> If ARCH is unspecified (command line or environment) and if
> include/asm is already a symlink to include/asm-$ARCH,
> use that ARCH as the default instead of the host ARCH.
> Undo the effect of this by using 'make mrproper' or just 'rm include/asm'.

Probably simpler just to do

$ export ARCH=i386
$ make ...

and skip this patch.  g/nite.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

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

* Re: kbuild feature/question: default ARCH
  2007-02-14  6:06 kbuild feature/question: default ARCH Randy Dunlap
  2007-02-14  6:23 ` Randy Dunlap
@ 2007-02-14  9:11 ` Sam Ravnborg
  2007-02-14 11:27   ` [pp] kbuild: ARCH-setup (Re: kbuild feature/question: default ARCH) Oleg Verych
  1 sibling, 1 reply; 4+ messages in thread
From: Sam Ravnborg @ 2007-02-14  9:11 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: lkml, olecom, zippel

On Tue, Feb 13, 2007 at 10:06:19PM -0800, Randy Dunlap wrote:
> Hi,
> 
> I'd like for kbuild to default ARCH to the already-symlinked
> arch in include/asm-$(ARCH) if ARCH is not specified on the
> command line or in the environment.
Another approach I have been toying with previously was to
include ARCH in .config. But I somehow failed
to get it working and it went on my TODO list.

If kconfig get extended to so it can include Kconfig
files for all archs then it could be a Kconfig
option like anything else to select architecture
and this would also solve your issue.

As for the "export ARCH=i386" proposal this is of no
use for people crosscompiling a lot.
Think of the 'Al Viro' setup with crosscompile for 5+
different architectures.

But as I have no patches this is just cheap talk for now.

	Sam

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

* [pp] kbuild: ARCH-setup (Re: kbuild feature/question: default ARCH)
  2007-02-14  9:11 ` Sam Ravnborg
@ 2007-02-14 11:27   ` Oleg Verych
  0 siblings, 0 replies; 4+ messages in thread
From: Oleg Verych @ 2007-02-14 11:27 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Randy Dunlap, lkml, zippel

Hallo.

On Wed, Feb 14, 2007 at 10:11:44AM +0100, Sam Ravnborg wrote:
> On Tue, Feb 13, 2007 at 10:06:19PM -0800, Randy Dunlap wrote:
> > Hi,
> > 
> > I'd like for kbuild to default ARCH to the already-symlinked
> > arch in include/asm-$(ARCH) if ARCH is not specified on the
> > command line or in the environment.
> Another approach I have been toying with previously was to
> include ARCH in .config. But I somehow failed
> to get it working and it went on my TODO list.

Sam, IMHO this is one inconvenience of the many, due to absence of
conf-build, build mechanism (you have my message about just for fun
thoughts ;).

> If kconfig get extended to so it can include Kconfig
> files for all archs then it could be a Kconfig
> option like anything else to select architecture
> and this would also solve your issue.
> 
> As for the "export ARCH=i386" proposal this is of no
> use for people crosscompiling a lot.
> Think of the 'Al Viro' setup with crosscompile for 5+
> different architectures.

While trying to do something with lguest and "private" asm-offsets on
AMD64, i must use ARCH=i386 for testing stuff. Thus, i give you my patch
proposition (proposed patch, whatever) that remembers ARCH in Makefile
in $(objtree). Once you have setup, you may use just 
`make target' there.

Randy, maybe this is *something* to have, than nothing. Testing is
appreciated.

,-*- shell -*-
|olecom@flower:/mnt/work/app-src-build/kernel.org/linux-2.6.20$
|olecom@flower:/mnt/work/app-src-build/kernel.org/linux-2.6.20$ rm -rf /tmp/linuz
|olecom@flower:/mnt/work/app-src-build/kernel.org/linux-2.6.20$ mkdir /tmp/linuz
|olecom@flower:/mnt/work/app-src-build/kernel.org/linux-2.6.20$ make ARCH=i386 O=/tmp/linu
|linux-2.6.20/ linuz/
|olecom@flower:/mnt/work/app-src-build/kernel.org/linux-2.6.20$ make ARCH=i386 O=/tmp/linuz/ defconfig > /dev/null
|/mnt/work/app-src-build/kernel.org/linux-2.6.20/arch/i386/defconfig:1122:warning:
|trying to assign nonexistent symbol USB_MULTITHREAD_PROBE
|olecom@flower:/mnt/work/app-src-build/kernel.org/linux-2.6.20$ cd /tmp/linuz
|olecom@flower:/tmp/linuz$ make prepare
|make -C /mnt/work/app-src-build/kernel.org/linux-2.6.20 O=/dev/shm/linuz prepare
|scripts/kconfig/conf -s arch/i386/Kconfig
|  Using /mnt/work/app-src-build/kernel.org/linux-2.6.20 as source for kernel
|  CHK     include/linux/version.h
|  UPD     include/linux/version.h
|  CHK     include/linux/utsrelease.h
|  UPD     include/linux/utsrelease.h
|  SYMLINK include/asm -> include/asm-i386
|  CC      arch/i386/kernel/asm-offsets.s
|  GEN     include/asm-i386/asm-offsets.h
|olecom@flower:/tmp/linuz$ arch
|x86_64
|olecom@flower:/tmp/linuz$
`-*-

Thanks.

---
 Changes for mkmakefile:
 * bugfix: _really_ generate Makefile once '!'
 * use shell paramenter expansion only where needed, thus Makefile's body
   is a little bit easy to read and write.

 Makefile           |    2 +-
 scripts/mkmakefile |   26 ++++++++++++++++----------
 2 files changed, 17 insertions(+), 11 deletions(-)

Index: linux-2.6.20/scripts/mkmakefile
===================================================================
--- linux-2.6.20.orig/scripts/mkmakefile	2007-02-14 11:53:43.972144500 +0100
+++ linux-2.6.20/scripts/mkmakefile	2007-02-14 11:55:34.879075750 +0100
@@ -9,12 +9,13 @@
 # $3 - version
 # $4 - patchlevel
+# $5 - ARCH
 
-
-test ! -r $2/Makefile -o -O $2/Makefile || exit 0
+test ! -r $2/Makefile -o ! -O $2/Makefile || exit 0
 echo "  GEN     $2/Makefile"
 
-cat << EOF > $2/Makefile
-# Automatically generated by $0: don't edit
-
+echo "#
+# Automatically generated by
+# $0
+#
 VERSION = $3
 PATCHLEVEL = $4
@@ -22,15 +23,20 @@ PATCHLEVEL = $4
 KERNELSRC    := $1
 KERNELOUTPUT := $2
+ARCH         := $5
+" > $2/Makefile
+
+cat << "EOF" >> $2/Makefile
+MAKEFLAGS    += -rR --no-print-directory
 
-MAKEFLAGS += --no-print-directory
+export ARCH
 
-.PHONY: all \$(MAKECMDGOALS)
+.PHONY: all $(MAKECMDGOALS)
 
 all:
-	\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
+	$(MAKE) -C $(KERNELSRC) O=$(KERNELOUTPUT)
 
 Makefile:;
 
-\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/:
-	\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
+$(filter-out all Makefile,$(MAKECMDGOALS)) %/:
+	$(MAKE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $@
 EOF
Index: linux-2.6.20/Makefile
===================================================================
--- linux-2.6.20.orig/Makefile	2007-02-14 11:55:50.068025000 +0100
+++ linux-2.6.20/Makefile	2007-02-14 11:56:56.756192750 +0100
@@ -358,5 +358,5 @@ outputmakefile:
 ifneq ($(KBUILD_SRC),)
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
-	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
+	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) $(ARCH)
 endif
 

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

end of thread, other threads:[~2007-02-14 11:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14  6:06 kbuild feature/question: default ARCH Randy Dunlap
2007-02-14  6:23 ` Randy Dunlap
2007-02-14  9:11 ` Sam Ravnborg
2007-02-14 11:27   ` [pp] kbuild: ARCH-setup (Re: kbuild feature/question: default ARCH) Oleg Verych

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.