lkml.org 
[lkml]   [2004]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2] kbuild: Improved external module support
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/06/20 22:59:03+02:00 sam@mars.ravnborg.org
# kbuild: External module support improved
#
# To improve support for external modules and to make usage
# of separate output directory easier the following
# changes has been implemented:
#
# 1) When using a separate output directory create a small
# Makefile that is a simple wrapper, calling the Makefile
# in the kernel tree.
# - This allows the user to shift to the output directory
# and execute make.
# - The Makefile is also useful to document the location
# source used for the kernel
#
# 2) When installing the kernel a new symlink is now created
# pointing to the source of kernel.
#
# 3) The build symlink now points to the output of the kernel
# compile.
# - When a kernel is compiled with output and source
# mixed, the build and source symlinks will point
# to the same directory. In this case there is
# no change in behaviour.
#
# Adding the Makefile in step 1) allow the for a long
# time recommended way to build an external module to
# continue working even with separate output directory.
#
# The following command now works independent of the kernel
# being build with separate output directory, or with
# output and source mixed.
#
# make -C /lib/modules/`uname -r`/build M=`pwd`
#
# [Substituting M= with SUBDIRS= give same effect].
#
# It is recommended that distributions pick up this
# method, and especially start shipping kernel output and
# source separately.
#
# Please note that when the kernel is being build
# using a separate output directory it may (will?) break
# modules that has not yet picked up the recommended
# way to build modules for 2.6.
# See Documentation/kbuild/modules.txt for details.
#
# Patch includes contributions from:
# Andreas Gruenbacher <agruen@suse.de> and
# Geert Uytterhoeven <geert@linux-m68k.org>
#
# Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
#
# scripts/mkmakefile
# 2004/06/20 22:58:48+02:00 sam@mars.ravnborg.org +25 -0
#
# scripts/mkmakefile
# 2004/06/20 22:58:48+02:00 sam@mars.ravnborg.org +0 -0
# BitKeeper file /home/sam/bk/kbuild/scripts/mkmakefile
#
# Makefile
# 2004/06/20 22:58:48+02:00 sam@mars.ravnborg.org +23 -4
# External module support improved
#
diff -Nru a/Makefile b/Makefile
--- a/Makefile 2004-06-20 23:06:03 +02:00
+++ b/Makefile 2004-06-20 23:06:03 +02:00
@@ -608,14 +608,23 @@
# A multi level approach is used. prepare1 is updated first, then prepare0.
# prepare-all is the collection point for the prepare targets.

-.PHONY: prepare-all prepare prepare0 prepare1
+.PHONY: prepare-all prepare prepare0 prepare1 prepare2
+
+# prepare 2 generate Makefile to be placed in output directory, if
+# using a seperate output directory. This allows convinient use
+# of make in output directory
+prepare2:
+ $(Q)if [ ! $(srctree) -ef $(objtree) ]; then \
+ $(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) $(objtree) \
+ > $(objtree)/Makefile; \
+ fi

# prepare1 is used to check if we are building in a separate output directory,
# and if so do:
# 1) Check that make has not been executed in the kernel src $(srctree)
# 2) Create the include2 directory, used for the second asm symlink

-prepare1:
+prepare1: prepare2
ifneq ($(KBUILD_SRC),)
@echo ' Using $(srctree) as source for kernel'
$(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
@@ -725,6 +734,12 @@
modules_prepare: prepare-all scripts

# Target to install modules
+# Modules are pr. default installed in /lib/modules/$(KERNELRELEASE)/...
+# Within this directory create two symlinks:
+# build => link to the directory containing the output files of the kernel build
+# source => link to the directory containing the source for the kernel
+# source and build are equal except for the case when the kernel is build using
+# a separate output directory
.PHONY: modules_install
modules_install: _modinst_ _modinst_post

@@ -736,9 +751,13 @@
sleep 1; \
fi
@rm -rf $(MODLIB)/kernel
- @rm -f $(MODLIB)/build
+ @rm -f $(MODLIB)/source
@mkdir -p $(MODLIB)/kernel
- @ln -s $(TOPDIR) $(MODLIB)/build
+ @ln -s $(srctree) $(MODLIB)/source
+ @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
+ rm -f $(MODLIB)/build ; \
+ ln -s $(objtree) $(MODLIB)/build ; \
+ fi
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst

# If System.map exists, run depmod. This deliberately does not have a
diff -Nru a/scripts/mkmakefile b/scripts/mkmakefile
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/scripts/mkmakefile 2004-06-20 23:06:03 +02:00
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Generates a small Makefile used in the root of the output
+# directory, to allow make to be started from there.
+# The Makefile also allow for more convinient build of external modules
+
+# Usage
+# $1 - Kernel src directory
+# $2 - Output directory
+
+
+cat << EOF
+
+KERNELSRC := $1
+KERNELOUTPUT := $2
+
+MAKEFLAGS += --no-print-directory
+
+all:
+ \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
+
+%:
+ \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
+
+EOF
+
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.134 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site