From: Sam Ravnborg <sam@ravnborg.org>
To: linux-kbuild@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Subject: [PATCH 4/5] kbuild: asm symlink support for arch/$ARCH/include
Date: Mon, 23 Jun 2008 00:08:43 +0200 [thread overview]
Message-ID: <1214172524-9043-4-git-send-email-sam@ravnborg.org> (raw)
In-Reply-To: <20080622220508.GA8957@uranus.ravnborg.org>
Adjust the asm symlink support so we do not create the
symlink unless really needed.
We check the precense of include/asm-$ARCH by checking
for the system.h file. We may end up with a stale directory
so it is not enough to check if the directory is present.
For "make O=..." build if we see that asm is a symlink
then it is deleted. This happens when we apply this patch
to a kernel with a valid build - so we do not require
a "make mrproper".
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
Kbuild | 2 +-
Makefile | 50 ++++++++++++++++++++++++++++++++++++--------------
2 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/Kbuild b/Kbuild
index e750e9c..254a6af 100644
--- a/Kbuild
+++ b/Kbuild
@@ -43,7 +43,7 @@ $(obj)/$(bounds-file): kernel/bounds.s Kbuild
# 2) Generate asm-offsets.h
#
-offsets-file := include/asm-$(SRCARCH)/asm-offsets.h
+offsets-file := include/asm/asm-offsets.h
always += $(offsets-file)
targets += $(offsets-file)
diff --git a/Makefile b/Makefile
index 115eb48..aac0ae0 100644
--- a/Makefile
+++ b/Makefile
@@ -921,7 +921,9 @@ ifneq ($(KBUILD_SRC),)
/bin/false; \
fi;
$(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
- $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm
+ $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/system.h ]; then \
+ ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
+ fi
endif
# prepare2 creates a makefile if using a separate output directory
@@ -947,22 +949,42 @@ export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
# 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 \
+define check-symlink
+ 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 " set ARCH or 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) $@; \
+ exit 1; \
+ fi; \
fi
+endef
+
+# For make O=... builds we create a directory when we create
+# asm-offsets so no need to try to create a symlink then
+ifneq ($(KBUILD_SRC),)
+define create-symlink
+ if [ -L include/asm ]; then \
+ rm include/asm; \
+ fi
+endef
+else
+define create-symlink
+ if [ ! -L include/asm ]; then \
+ if [ -e $(srctree)/include/asm-$(SRCARCH)/system.h ]; then \
+ echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
+ if [ ! -d include ]; then \
+ mkdir -p include; \
+ fi; \
+ ln -fsn asm-$(SRCARCH) $@; \
+ fi \
+ fi
+endef
+endif
+
+include/asm: FORCE
+ $(Q)$(check-symlink)
+ $(Q)$(create-symlink)
# Generate some files
# ---------------------------------------------------------------------------
--
1.5.4.1.143.ge7e51
next prev parent reply other threads:[~2008-06-22 22:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-21 22:07 Support arch/$ARCH/include in kbuild Sam Ravnborg
2008-06-21 22:08 ` [PATCH] kbuild: prepare headers_* for arch/$ARCH/include Sam Ravnborg
2008-06-21 22:08 ` [PATCH] kbuild: support arch/$ARCH/include/ Sam Ravnborg
2008-06-21 22:11 ` Support arch/$ARCH/include in kbuild Sam Ravnborg
2008-06-22 22:05 ` Sam Ravnborg
2008-06-22 22:08 ` [PATCH 1/5] kbuild: prepare headers_* for arch/$ARCH/include Sam Ravnborg
2008-06-24 14:31 ` Arnd Bergmann
2008-06-22 22:08 ` [PATCH 2/5] kbuild: include/asm may be a file - fix mrproper for this Sam Ravnborg
2008-06-22 22:08 ` [PATCH 3/5] kbuild: support arch/$ARCH/include for tags, cscope Sam Ravnborg
2008-06-22 22:08 ` Sam Ravnborg [this message]
2008-06-22 22:08 ` [PATCH 5/5] kbuild: add arch/$ARCH/include to search path Sam Ravnborg
2008-06-24 15:32 ` Support arch/$ARCH/include in kbuild Arnd Bergmann
2008-06-26 18:56 ` 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=1214172524-9043-4-git-send-email-sam@ravnborg.org \
--to=sam@ravnborg.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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