[Prism54-devel] Re: Add depmod to Makefile

Pavel Roskin proski@gnu.org
Wed, 19 May 2004 03:21:21 -0400 (EDT)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--Boundary_(ID_WhS9cOI+Y3yS/PgzlDs3sw)
Content-type: TEXT/PLAIN; charset=US-ASCII
Content-transfer-encoding: 7BIT

On Tue, 18 May 2004, Joerg Dorchain wrote:

> On Tue, May 18, 2004 at 06:54:03AM +0200, Margit Schubert-While wrote:
> > Luis, please revert this fix.
> > It is wrong. It depends on the target kernel being running.
> > KDIR/KMISC were introduced to build/install for non-booted kernels.
> > I use this regularly to bring my plethora of kernels up to date.
> > The make/install/depmod procedure is quite clearly explained
> > in the README.
>
> Is adding -b ${something derived from $KDIR} an option?

Here's what other drivers do.

Orinoco, atmelwlandriver and at76c503a run depmod unconditionally and
nobody complains.  Even when compiling for another kernel, depmod for the
current kernel should not be harmful.

HostAP extracts the kernel version from include/linux/version.h in the
kernel source.  depmod is run if this version matches the version returned
by uname.

linux-wlan-ng runs depmod unless the modules are installed unless the
modules are installed in a non-standard location.

The common part is that I never have to run depmod manually.  I'm new to
the prism54 driver, so it's not surprising that such minor details annoy
me more than others, but I think that other newcomers will get into the
same trap occasionally.

The new patch combines the sed magic from Orinoco and the version
comparison approach from HostAP.  Margit will hopefully appreciate that
KVER doesn't need to be overridden.  The default of KDIR is based on the
current kernel version.  The kernel version is taken from the kernel's
top-level Makefile.

The expression used to get the version has been used in the Orinoco driver
for months and there have been no complaints.  It takes right hand sides
of 4 lines starting with the one that starts with "VERSION".  They are
joined together using dashes, except the last part (EXTRAVERSION), which
is appended without a dash.

I added some comments.  Feel free to correct.  The idea is to separate
overridable and internal variables.  KMISC must be "recursively expanded"
because it uses KVER, which was moved below.

-- 
Regards,
Pavel Roskin

--Boundary_(ID_WhS9cOI+Y3yS/PgzlDs3sw)
Content-id: <Pine.LNX.4.58.0405190321210.1654@portland.hansa.lan>
Content-type: TEXT/plain; charset=US-ASCII; name=kver_depmod.diff
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=kver_depmod.diff
Content-description:

--- Makefile
+++ Makefile
@@ -1,11 +1,19 @@
 # $Id: Makefile,v 1.11 2004/05/18 01:47:51 mcgrof Exp $
 
-KVER	       := $(shell uname -r)
-KDIR           := /lib/modules/$(KVER)/build
-KMISC          := /lib/modules/$(KVER)/kernel/drivers/net/wireless/prism54/
-KEXT           := $(shell echo $(KVER) | sed -ne 's/^2\.[567]\..*/k/p')o
+# Path to the kernel source
+KDIR           := /lib/modules/$(shell uname -r)/build
+
+# Where to install the modules
+KMISC          = /lib/modules/$(KVER)/kernel/drivers/net/wireless/prism54/
+
+# Output directory for kernel compilation
 KOUT           := $(KDIR)
 
+# You should not need to override variables below this line
+KVER           := $(shell sed -n '/^VERSION/{s/.*=//;h;n;s/.*=/./;H;n;s/.*=/./;\
+                    H;n;s/.*=//;H;g;s/[[:space:]]//g;p;}' $(KDIR)/Makefile)
+KEXT           := $(shell echo $(KVER) | sed -ne 's/^2\.[567]\..*/k/p')o
+
 .PHONY: default modules install clean module-all modules-clean modules-install
 
 default: 
@@ -35,6 +43,9 @@
 modules-install:
 	install -d $(KMISC)
 	install -m 644 -c ksrc/prism54.$(KEXT) $(KMISC)
+ifeq ($(KVER), $(shell uname -r))
+	/sbin/depmod -ae
+endif
 	#install -d /usr/lib/hotplug/firmware
 	#install -c isl3877 /usr/lib/hotplug/firmware
 	#install -c isl3890 /usr/lib/hotplug/firmware

--Boundary_(ID_WhS9cOI+Y3yS/PgzlDs3sw)--