Re: [PATCH] Symlinks for building external modules

From: Andreas Gruenbacher
Date: Sat Jun 05 2004 - 08:44:41 EST


On Friday 04 June 2004 21:45, Måns Rullgård wrote:
> Sam Ravnborg <sam@xxxxxxxxxxxx> writes:
> > Andreas - please expalin why you want build to be a symlink, and not
> > the directory used when actually building the kernel.
>
> I can't speak for Andreas, but I prefer to keep my root filesystem as
> clean as possible. Often it's mounted read-only.

Either way would work, but I prefer to have the actual files below /usr/src.
The /lib directory is meant for files required during boot, whereas /usr may
be mounted later. If we want to allow both possibilities, we probably want to
add the following check:

Index: linux-2.6.7-rc2/Makefile
===================================================================
--- linux-2.6.7-rc2.orig/Makefile
+++ linux-2.6.7-rc2/Makefile
@@ -735,7 +735,8 @@ _modinst_:
@rm -f $(MODLIB)/{source,build}
@mkdir -p $(MODLIB)/kernel
@ln -s $(srctree) $(MODLIB)/source
- @ln -s $(objtree) $(MODLIB)/build
+ @[ $(objtree) -ef $(MODLIB)/build ] \
+ || ln -s $(objtree) $(MODLIB)/build
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst


Next, we may want to add a Makefile to the output directory so that external
modules will build the same way they did before, without specifying the
source tree separately:

Index: linux-2.6.7-rc2/Makefile
===================================================================
--- linux-2.6.7-rc2.orig/Makefile
+++ linux-2.6.7-rc2/Makefile
@@ -125,11 +125,19 @@ ifeq ($(skip-makefile),)
# but instead _all depend on modules
.PHONY: all
ifeq ($(KBUILD_EXTMOD),)
-_all: all
+_all: $(objtree)/Makefile all
else
_all: modules
endif

+.PHONY: $(objtree)/Makefile
+$(objtree)/Makefile:
+ $(Q)if [ ! $(srctree) -ef $(objtree) ]; then \
+ ( echo "modules modules_install clean:" ; \
+ echo -e "\t\$$(MAKE) -C $(srctree) \$$@ O=\$$(CURDIR)" \
+ ) > $(objtree)/Makefile ; \
+ fi
+
# Make sure we're not wasting cpu-cycles doing locale handling, yet do make
# sure error messages appear in the user-desired language
ifdef LC_ALL


Cheers,
--
Andreas Gruenbacher <agruen@xxxxxxx>
SUSE Labs, SUSE LINUX AG
-
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/