mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFT] kbuild: check asm symlink when building a kernel
@ 2007-10-17 21:30 Sam Ravnborg
  0 siblings, 0 replies; only message in thread
From: Sam Ravnborg @ 2007-10-17 21:30 UTC (permalink / raw)
  To: LKML, kbuild devel

We often hit the situation where the asm symlink
in include/ points to the wrong architecture.
In 9 out of 10 cases thats because we forgot to set
ARCH but sometimes we just reused the same tree
for another ARCH. For the merged x86 tree we need
to create a new symlink but this is not obvious.
So with the following patch we check if the symlink
points to the correct architecture and error
out if this is not the case.

For x86 a "rm include/asm" is enough but we
recommend make mrproper for the general case.

The patch survives my testing but before pushing
it to -mm or -linus I would like a few more to
test it in their environment.
I am a bit unsafe with the use of readlink and cut since
they are not widely used by the kernel
build today.

Any feedback good/bad appreciated!

PS - I know that the lines are too long in the patch but
     breaking them would hurt readability.

	Sam

diff --git a/Makefile b/Makefile
index ed65de7..136d7c2 100644
--- a/Makefile
+++ b/Makefile
@@ -903,14 +903,24 @@ prepare: prepare0
 
 export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
 
-# FIXME: The asm symlink changes when $(ARCH) changes. That's
-# hard to detect, but I suppose "make mrproper" is a good idea
-# before switching between archs anyway.
-
-include/asm:
-	@echo '  SYMLINK $@ -> include/asm-$(SRCARCH)'
-	$(Q)if [ ! -d include ]; then mkdir -p include; fi;
-	@ln -fsn asm-$(SRCARCH) $@
+# The asm symlink changes when $(ARCH) changes.
+# Detect this and ask user to run make mrproper
+
+include/asm: FORCE
+	$(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`;   \
+	if [ -L include/asm ]; then                                     \
+		if [ "$$asmlink" != "$(SRCARCH)" ]; then                \
+			echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
+			echo "       save .config and run 'make mrproper' to fix it";                         \
+			exit 1;                                         \
+		fi;                                                     \
+	else                                                            \
+		echo '  SYMLINK $@ -> include/asm-$(SRCARCH)';          \
+		if [ ! -d include ]; then                               \
+			mkdir -p include;                               \
+		fi;                                                     \
+		ln -fsn asm-$(SRCARCH) $@;                              \
+	fi
 
 # Generate some files
 # ---------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-17 21:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-17 21:30 [RFT] kbuild: check asm symlink when building a kernel Sam Ravnborg

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

all inboxes | Powered by JetHome®