kbuild feature/question: default ARCH

From: Randy Dunlap
Date: Wed Feb 14 2007 - 01:26:36 EST


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@xxxxxxxxxx>

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@xxxxxxxxxx>
---
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 ?=

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/