* External compilation
@ 2002-06-09 14:26 John Levon
2002-06-10 11:15 ` Gerd Knorr
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: John Levon @ 2002-06-09 14:26 UTC (permalink / raw)
To: linux-kernel
Is there any good example code for compiling a kernel module
externally, that works for modversions etc. on 2.2, 2.4, and 2.5,
and does the right thing (including Rules.make) ?
I'm having an awful time working out the exact incantations.
On a related note, is it at all possible to make a "mini filesystem"
that will work on 2.2 upwards, so I can avoid proc,sysctl, and ioctl ?
thanks
john
--
"Saying that taste is just personal preference is a good way to prevent
disputes. The trouble is, it's not true."
- Paul Graham
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: External compilation
2002-06-09 14:26 External compilation John Levon
@ 2002-06-10 11:15 ` Gerd Knorr
2002-06-10 14:31 ` Kai Germaschewski
2002-06-10 20:05 ` Greg KH
2 siblings, 0 replies; 6+ messages in thread
From: Gerd Knorr @ 2002-06-10 11:15 UTC (permalink / raw)
To: linux-kernel
John Levon wrote:
>
> Is there any good example code for compiling a kernel module
> externally, that works for modversions etc. on 2.2, 2.4, and 2.5,
> and does the right thing (including Rules.make) ?
>
> I'm having an awful time working out the exact incantations.
Here is a stripped down version of what I use for bttv currently.
Gerd
==============================[ Makefile ]==============================
# where the kernel sources are located
KDIR := /lib/modules/$(shell uname -r)/build
#KDIR := /work/bk/2.5/build
# kernel version
KVER := $(shell ./uts-release $(KDIR))
MDIR := /lib/modules/$(KVER)/kernel/drivers/media/video
export-objs := bttv-if.o video-buf.o
list-multi := bttv.o
bttv-objs := bttv-driver.o bttv-cards.o bttv-risc.o bttv-if.o bttv-vbi.o
obj-m := video-buf.o bttv.o
multi-m := $(filter $(list-multi), $(obj-m))
int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
EXTRA_CFLAGS=-g -Wmissing-prototypes -Wstrict-prototypes
here:
DIR=`pwd`; (cd $(KDIR); make SUBDIRS=$$DIR modules)
include $(KDIR)/Rules.make
bttv.o: $(bttv-objs)
$(LD) -r -o $@ $(bttv-objs)
==============================[ uts-release ]==============================
#! /bin/sh
cat <<-EOF | cpp -P -I$1/include | grep '"' | cut -d'"' -f2
#include <linux/version.h>
UTS_RELEASE
EOF
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: External compilation
2002-06-09 14:26 External compilation John Levon
2002-06-10 11:15 ` Gerd Knorr
@ 2002-06-10 14:31 ` Kai Germaschewski
2002-06-10 15:12 ` John Levon
2002-06-10 20:05 ` Greg KH
2 siblings, 1 reply; 6+ messages in thread
From: Kai Germaschewski @ 2002-06-10 14:31 UTC (permalink / raw)
To: John Levon; +Cc: linux-kernel
On Sun, 9 Jun 2002, John Levon wrote:
> Is there any good example code for compiling a kernel module
> externally, that works for modversions etc. on 2.2, 2.4, and 2.5,
> and does the right thing (including Rules.make) ?
Well, you need the source for the kernel you're building the module for,
it needs to be configured and "make dep" must have been run (for module
versions).
(You normally can find it by looking into /lib/modules/`uname -r`/kernel
for the currently running kernel)
Put your module source in some directory, and add a Makefile like
obj-m := my_module.o
include $(TOPDIR)/Rules.make
cd into the kernel source and run
make SUBDIRS=/path/to/your/module modules
--Kai
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: External compilation
2002-06-10 14:31 ` Kai Germaschewski
@ 2002-06-10 15:12 ` John Levon
2002-06-10 15:34 ` Kai Germaschewski
0 siblings, 1 reply; 6+ messages in thread
From: John Levon @ 2002-06-10 15:12 UTC (permalink / raw)
To: Kai Germaschewski; +Cc: linux-kernel
On Mon, Jun 10, 2002 at 09:31:42AM -0500, Kai Germaschewski wrote:
> Well, you need the source for the kernel you're building the module for,
> it needs to be configured and "make dep" must have been run (for module
> versions).
Obviously :)
I already have stuff working fine w/o the Rules.make include, I'm just
trying to do the "right thing"
> obj-m := my_module.o
>
> include $(TOPDIR)/Rules.make
>
> cd into the kernel source and run
>
> make SUBDIRS=/path/to/your/module modules
Doesn't work for 2.2. Hopefully I will be able to specify M_OBJS in
addition.
Also, you don't specify O_TARGET ?
Given :
TOPDIR=/usr/src/linux
THISDIR=/tmp/mod
O_TARGET=lartmod.o
obj-m := lart.o blah.o
include $(TOPDIR)/Rules.make
all:
(cd $(TOPDIR) && $(MAKE) SUBDIRS=/tmp/mod modules)
a) default target for Rules.make doesn't do anything useful
b) lartmod.o is never made (how could I convince it to ?)
c) is this going to work OK for modversions...
d) the above seems to disallow a lart.c forming only part of a final lart.o target
e) there seems something is going horribly wrong :
moz mod 317 make all
make: execvp: /usr/src/linux/scripts/pathdown.sh: Permission denied
¶@¶@re/locale/en_US/LC_MESSAGES/make.mo(cd /usr/src/linux && make SUBDIRS=/tmp/mod modules)
make[1]: Entering directory `/usr/src/linux-2.4.0'
The above problems is why I asked for working examples :)
regards
john
--
"I continue to be amazed at what Andrei can make templates do. Some of it
still makes my head hurt."
- Herb Sutter
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: External compilation
2002-06-10 15:12 ` John Levon
@ 2002-06-10 15:34 ` Kai Germaschewski
0 siblings, 0 replies; 6+ messages in thread
From: Kai Germaschewski @ 2002-06-10 15:34 UTC (permalink / raw)
To: John Levon; +Cc: linux-kernel
On Mon, 10 Jun 2002, John Levon wrote:
> Doesn't work for 2.2. Hopefully I will be able to specify M_OBJS in
> addition.
I think later 2.2 support obj-[ym], though I maybe wrong. It won't hurt to
specify M_OBJS additionally.
> Also, you don't specify O_TARGET ?
>
> Given :
>
> TOPDIR=/usr/src/linux
> THISDIR=/tmp/mod
>
> O_TARGET=lartmod.o
> obj-m := lart.o blah.o
>
> include $(TOPDIR)/Rules.make
>
> all:
> (cd $(TOPDIR) && $(MAKE) SUBDIRS=/tmp/mod modules)
My example was for a single source module. If you have multiple sources,
you can either
O_TARGET := lartmod.o
obj-y := lart.o blah.o
obj-m := $(O_TARGET)
or
obj-m := lartmod.o
lartmod-objs := lart.o blah.o
where the later in 2.4 additionally needs
list-multi := lartmod.o
and a link rule like
lartmod.o: $(lartmod-objs)
$(LD) -r -o $@ $(lartmod-objs)
> a) default target for Rules.make doesn't do anything useful
The default target (at least in < current 2.5) only builds built-in code.
> b) lartmod.o is never made (how could I convince it to ?)
See first example above.
> c) is this going to work OK for modversions...
Yup.
> d) the above seems to disallow a lart.c forming only part of a final lart.o target
If you only have one source, see my first mail.
> e) there seems something is going horribly wrong :
>
> moz mod 317 make all
> make: execvp: /usr/src/linux/scripts/pathdown.sh: Permission denied
> ¶@¶@re/locale/en_US/LC_MESSAGES/make.mo(cd /usr/src/linux && make SUBDIRS=/tmp/mod modules)
> make[1]: Entering directory `/usr/src/linux-2.4.0'
That I suppose is due to the fact that during the "make all"
$(CONFIG_SHELL) is not set, thus the
MOD_DESTDIR := $(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
in Rules.make fails. Try doing the "cd $(TOPDIR) && ..." by hand, it
should work then.
--Kai
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: External compilation
2002-06-09 14:26 External compilation John Levon
2002-06-10 11:15 ` Gerd Knorr
2002-06-10 14:31 ` Kai Germaschewski
@ 2002-06-10 20:05 ` Greg KH
2 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2002-06-10 20:05 UTC (permalink / raw)
To: John Levon; +Cc: linux-kernel
On Sun, Jun 09, 2002 at 03:26:02PM +0100, John Levon wrote:
>
> On a related note, is it at all possible to make a "mini filesystem"
> that will work on 2.2 upwards, so I can avoid proc,sysctl, and ioctl ?
Take a look at drivers/usb/inode.c in the 2.2 kernel. Yes it's ugly,
but seems to be the only way to do it on 2.2. It also will work on 2.4
and 2.5. For 2.4/2.5 it's _much_ easier to make a "mini filesystem".
See libfs on 2.5, or the pci_hotplug code in 2.4 for examples of this.
Hope this helps,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-06-10 20:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-09 14:26 External compilation John Levon
2002-06-10 11:15 ` Gerd Knorr
2002-06-10 14:31 ` Kai Germaschewski
2002-06-10 15:12 ` John Levon
2002-06-10 15:34 ` Kai Germaschewski
2002-06-10 20:05 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox