[lkml]   [1999]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patches in this message
SubjectRe: toplevel Makefile bug and simple fix
On Sat, 6 Nov 1999 06:56:07 -0500, 
"Theodore Y. Ts'o" <> wrote:
>P.S. And we really *have* to be able to support stand-alone source
>distribution of drivers. The Linux kernel sources are still growing
>expenontially, with a time constant of roughly 18 months. This is
>mostly due to new drivers. Sooner or later, we will need to address the
>question of how to distribute drivers independently of the kernel, in
>source form at the very least.

Cc:ed to linux-kbuild.

Recommended solution - anybody distributing a driver independently of
the kernel should ship a patch against the kernel source tree that

(a) adds the files required by the driver
(b) defines a Makefile fragment for the new driver, the fragment adds
object names to the standard kernel Makefile variables.

Then the user just does "make bzlilo modules modules_install".

AFAICT this method (adding independent modules to the kernel Makefile
tree) is the only way to guarantee that the module is compiled with the
correct options. I have seen people try to copy kernel compile options
by hand into a separate source tree and get them wrong, in particular
they get genksyms wrong most of the time. Also most separate compiles
completely omit dependency checking. Using the kernel makefile
structure gets it right every time.

To prevent independent module patches from affecting the rest of the
tree, create a directory called independent under linux and under
/lib/modules/`uname -r`. All independent drivers should go in these
directories. This patch against 2.3.24 creates linux/independent.

Index: 24.1/Makefile
--- 24.1/Makefile Thu, 28 Oct 1999 09:57:17 +1000 keith (linux-2.3/M/b/40_Makefile 644)
+++ 24.1(w)/Makefile Sat, 06 Nov 1999 23:57:07 +1100 keith (linux-2.3/M/b/40_Makefile 644)
@@ -114,7 +114,7 @@
drivers/misc/misc.o \
LIBS =$(TOPDIR)/lib/lib.a
-SUBDIRS =kernel drivers mm fs net ipc lib
+SUBDIRS =kernel drivers mm fs net ipc lib independent

DRIVERS := $(DRIVERS) drivers/nubus/nubus.a
@@ -361,6 +361,7 @@
if [ -f IRDA_MODULES ]; then inst_mod IRDA_MODULES net; fi; \
if [ -f USB_MODULES ]; then inst_mod USB_MODULES usb; fi; \
if [ -f PCMCIA_MODULES ]; then inst_mod PCMCIA_MODULES pcmcia; fi; \
+ if [ -f INDEPENDENT_MODULES ]; then inst_mod INDEPENDENT_MODULES independent; fi; \
ls *.o > $$MODLIB/.allmods; \
echo $$MODULES | tr ' ' '\n' | sort | comm -23 $$MODLIB/.allmods - > $$MODLIB/.misc; \
Index: 24.1/independent/Makefile
--- 24.1/independent/Makefile Sun, 07 Nov 1999 00:19:04 +1100 keith ()
+++ 24.1(w)/independent/Makefile Sun, 07 Nov 1999 00:04:13 +1100 keith (linux-2.3/k/c/3_Makefile 644)
@@ -0,0 +1,43 @@
+# Makefile for modules that are not distributed with the Linux kernel,
+# instead they are shipped as independent kernel patches.
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (not a .c file).
+# Note 2! The CFLAGS definitions are now in the main makefile.
+# Note 3! Independent modules must not patch this file. Instead they
+# supply a file called <modname>.makefile. <modname>.makefile
+# is only allowed to set module specific variables and to *add* to
+# (not replace) the global Makefile variables.
+# Some patches may want their own subdirectory
+# List of modules that do not export symbols
+M_OBJS :=
+# List of modules that do export symbols
+# List of objects that form part of other modules and do not export symbols
+# List of objects that form part of other modules and do export symbols
+# Pull in all the independent makefile fragments
+ifneq "$(wildcard *.makefile)" ""
+ include $(wildcard *.makefile)
+# File to hold the list of independent modules
+# By definition, all directories contain modules
+include $(TOPDIR)/Rules.make
And this patch is a demonstration of how to add an independent module.
Note that the patch is totally isolated from all other kernel files so
there are no problems about overlapping or conflicting patches.
Because each independent module is totally isolated, they do not even
have to be supplied in patch format; zip, tar or just plain cp will do
the job.

As long as independent patches are given unique names (note the kao_
prefix) there are no conflicts. If two groups create an independent
module called fred.o they will have problems but there is nothing we
can do about that.

Index: 24.1/independent/kao_demo.makefile
--- 24.1/independent/kao_demo.makefile Sun, 07 Nov 1999 00:19:04 +1100 keith ()
+++ 24.1(w)/independent/kao_demo.makefile Sun, 07 Nov 1999 00:18:32 +1100 keith (linux-2.3/k/c/4_kao_demo.m 644)
@@ -0,0 +1,25 @@
+# Makefile fragment for demonstration independent module.
+# These makefile fragments must only append to the global module
+# Makefile variables. All assignments must be '+=', not ':=' nor '='.
+# The only variables that should be assigned are SUB_DIRS, M_OBJS,
+# MX_OBJS, MI_OBJS, MIX_OBJS, plus any variables that are specific to
+# this independent module.
+# Some patches may want their own subdirectory
+# List of modules that do not export symbols
+M_OBJS += kao_demo.o
+# List of modules that do export symbols
+# List of objects that form part of other modules and do not export symbols
+# List of objects that form part of other modules and do export symbols
Index: 24.1/independent/kao_demo.c
--- 24.1/independent/kao_demo.c Sun, 07 Nov 1999 00:19:04 +1100 keith ()
+++ 24.1(w)/independent/kao_demo.c Sun, 07 Nov 1999 00:13:04 +1100 keith (linux-2.3/k/c/5_kao_demo.c 644)
@@ -0,0 +1,23 @@
+ * Demonstration independent module.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+int init_module(void)
+ printk(KERN_INFO "Demonstration independent module loaded\n");
+ return 0;
+void cleanup_module(void)
+ printk(KERN_INFO "Demonstration independent module removed\n");
If the first patch is accepted into the kernel Makefile structure I
will update modutils to include /lib/modules/`uname -r`/independent.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:54    [W:0.124 / U:7.148 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site