Skip to contentSkip to conversation

compiling external kernel modules (comedi.org)

DISCUSSION Bernd Porr 3 participants 7 messages Aug 2, 2003 – Aug 11, 2003

lore
Share & tools
lore

Bernd Porr

author
#0 lore raw

Hi all,

I'm trying to compile comedi on 2.6-test2. The very naive way (with configure) does not work (as expected). However, comedi conforms (mainly) to the kernel makefile convention. So I tried this:

make -C /usr/src/linux-2.6.0-test2 SUBDIRS=/home/bp1/c/usb/2.6/comedi/comedi/ V=1

make -f scripts/Makefile.build obj=/home/bp1/c/usb/2.6/comedi/comedi//drivers
scripts/Makefile.build:27: kbuild: /home/bp1/c/usb/2.6/comedi/comedi//drivers/Makefile - Usage of export-objs is obsolete in 2.5. Please fix! make -f scripts/Makefile.build obj=/home/bp1/c/usb/2.6/comedi/comedi//kcomedilib
scripts/Makefile.build:27: kbuild: /home/bp1/c/usb/2.6/comedi/comedi//kcomedilib/Makefile - Usage of export-objs is obsolete in 2.5. Please fix! make -f scripts/Makefile.build obj=arch/i386/boot arch/i386/boot/bzImage

make -f scripts/Makefile.build obj=arch/i386/boot/compressed \
                               IMAGE_OFFSET=0x100000 

arch/i386/boot/compressed/
vmlinux
Kernel: arch/i386/boot/bzImage is ready
Building modules, stage 2.
make -rR -f scripts/Makefile.modpost
scripts/modpost vmlinux drivers/net/pcmcia/3c574_cs.o
drivers/net/pcmcia/3c589
_cs.o drivers/net/8139cp.o drivers/net/8139too.o drivers/net/8390.o drivers/char /agp/agpgart.o drivers/net/wireless/airo.o drivers/net/wireless/airo_cs.o driver s/net/wireless/arlan-proc.o drivers/net/wireless/arlan.o drivers/net/wireless/at mel.o drivers/net/wireless/atmel_cs.o drivers/usb/class/audio.o drivers/net/pcmc

Looks like as if the kernel itself has been compiled and not comedi.

In comparison: kernel 2.4.x makes it (nearly) right:

make -C /usr/src/linux SUBDIRS=/home/bp1/c/usb/2.6/comedi/comedi/

make: Entering directory `/usr/src/linux-2.4.21'
. scripts/mkversion > .tmpversion
gcc -D__KERNEL__ -I/usr/src/linux-2.4.21/include -Wall -Wstrict-prototypes -Wno- trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpref erred-stack-boundary=2 -march=athlon -DUTS_MACHINE='"i386"' -DKBUILD_BASENAME=v ersion -c -o init/version.o init/version.c
make CFLAGS="-D__KERNEL__ -I/usr/src/linux-2.4.21/include -Wall -Wstrict-prototy pes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pi pe -mpreferred-stack-boundary=2 -march=athlon " -C /home/bp1/c/usb/2.6/comedi/c omedi
make[1]: Entering directory `/home/bp1/c/usb/2.6/comedi/comedi'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.21/include -Wall -Wstrict-prototypes -Wno- trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpref erred-stack-boundary=2 -march=athlon -D__KERNEL__ -I/usr/src/linux-2.4.21/inclu de -c -o comedi_fops.o comedi_fops.c
make[1]: Leaving directory `/home/bp1/c/usb/2.6/comedi/comedi'
make: Leaving directory `/usr/src/linux-2.4.21'

Is it a kernel2.6 issue or is it a comedi issue? Actually the comedi configuration is a hack and does not completely comply with the kernel makefile conventions. Probably because it has to run on either 2.x.x kernel. Who can help? Is the way to compile exernal modules from the 2.4.x kernel deprecated? Is there another (more elegant) way? Would be nice to use as much as possible from the 2.6 stuff. Just now comdi does most of the stuff by a "configure" by itself. This leads to another problem where comedi is not able to obtain the compiler flags etc from the 2-6 kernel. However, this is a hack and has to be chnanged anyway.

Therefore my questions: What is the best way to compile external modules?
What has changed from 2.4 to 2.6? I noticed that .htdepend is no longer there and that there is no rules file.

/Bernd

Signature · 2 lines
http://www.cn.stir.ac.uk/~bp1/
mailto:[email protected]
#1 lore raw
Quoted 8 lines · Bernd Porr

Hi all,

I'm trying to compile comedi on 2.6-test2. The very naive way (with configure) does not work (as expected). However, comedi conforms (mainly) to the kernel makefile convention. So I tried this:

make -C /usr/src/linux-2.6.0-test2
SUBDIRS=/home/bp1/c/usb/2.6/comedi/comedi/ V=1

When compiling modules use:
make -C /usr/src/linux-2.6.0-test2 SUBDIRS=$PWD V=1 modules See the added "modules" target.

Sam

author
#2 lore raw

Ok. Thanks. Now the bug is that comedi cannot find the file "Rules.make" which is apparently no longer there in 2.6. Is it right that the rules are now integrated in the corresponding makefiles?

Can you recommend me a Makefile which I can take as a template? Comedi uses some sort of autoconfig and I have to append then the "rules" to the automatically generated makefile.

Another thing: can a prevent the kernel of generating the "Stage 2"? It would be nice if the kernel doen't need to write to it's own directories if it compiles external modules. The best thing would be that one could compile external modules as a normal user and then only at the end becomes root. In my case this would be convenient as my home is a NFS directory which does not allow compiling as root. However the kernel modules at the end are stored on a root writable directory.

/Bernd

--------------------------------------------------------------------------------
removed the Rules.make includes from the comedi Makefiles:

2.4.21: only to test. Comedi cannot compile since an evil programmer has removed Rules.make.

snoopy:/home/bp1/c/usb/comedi/comedi# make -C /usr/src/linux SUBDIRS=$PWD V=1 modules
make: Entering directory `/usr/src/linux-2.4.21'
make -C  /home/bp1/c/usb/comedi/comedi CFLAGS="-D__KERNEL__ -I/usr/src/linux-2.4.21/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=athlon -DMODULE -DMODVERSIONS -include /usr/src/linux-2.4.21/include/linux/modversions.h" MAKING_MODULES=1 modules
make[1]: Entering directory `/home/bp1/c/usb/comedi/comedi'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/home/bp1/c/usb/comedi/comedi'
make: *** [_mod_/home/bp1/c/usb/comedi/comedi] Error 2
make: Leaving directory `/usr/src/linux-2.4.21'

2.6.21: Comedi compiles without error since the kernel expects the Makefile to trigger the make of modules which is no longer there.

snoopy:/home/bp1/c/usb/comedi/comedi# make -C /usr/src/linux-2.6.0-test2 SUBDIRS=$PWD V=1 modules
make: Entering directory `/usr/src/linux-2.6.0-test2'
make -f scripts/Makefile.build obj=scripts
make -f scripts/Makefile.build obj=arch/i386/kernel arch/i386/kernel/asm-offsets.s
make[1]: `arch/i386/kernel/asm-offsets.s' is up to date.
*** Warning: Overriding SUBDIRS on the command line can cause
***          inconsistencies
mkdir -p .tmp_versions
make -f scripts/Makefile.build obj=/home/bp1/c/usb/comedi/comedi
scripts/Makefile.build:27: kbuild: /home/bp1/c/usb/comedi/comedi/Makefile - Usage of export-objs is obsolete in 2.5. Please fix!
make -f scripts/Makefile.build obj=/home/bp1/c/usb/comedi/comedi/drivers
scripts/Makefile.build:27: kbuild: /home/bp1/c/usb/comedi/comedi/drivers/Makefile - Usage of export-objs is obsolete in 2.5. Please fix!
make -f scripts/Makefile.build obj=/home/bp1/c/usb/comedi/comedi/kcomedilib
scripts/Makefile.build:27: kbuild: /home/bp1/c/usb/comedi/comedi/kcomedilib/Makefile - Usage of export-objs is obsolete in 2.5. Please fix!
 Building modules, stage 2.
make -rR -f scripts/Makefile.modpost
 scripts/modpost vmlinux drivers/net/pcmcia/3c574_cs.o 
drivers/net/pcmcia/3c589_cs.o drivers/net/8139cp.o drivers/net/8139too.o

------------------------

Quoted 23 lines · Sam Ravnborg
Quoted 7 lines · Bernd Porr

Hi all,

I'm trying to compile comedi on 2.6-test2. The very naive way (with configure) does not work (as expected). However, comedi conforms (mainly) to the kernel makefile convention. So I tried this:

make -C /usr/src/linux-2.6.0-test2 SUBDIRS=/home/bp1/c/usb/2.6/comedi/comedi/ V=1

When compiling modules use:
make -C /usr/src/linux-2.6.0-test2 SUBDIRS=$PWD V=1 modules See the added "modules" target.

Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
http://www.cn.stir.ac.uk/~bp1/
mailto:[email protected]
#3 lore raw
Quoted 3 lines · Bernd Porr

Ok. Thanks. Now the bug is that comedi cannot find the file "Rules.make" which is apparently no longer there in 2.6. Is it right that the rules are now integrated in the corresponding makefiles?

The way to find the Makefiles changed during the 2.5 development cycle. Now the kbuild Makefile (the one for comedi for example) are included from scripts/Makfile.build hereby obsoleting Rules.make.

You will NOT succeed creating a single simple makefile supporting both 2.4 and 2.6. On the other hand the Makefile are so trivial that creating two distinct version should be acceptable?

Quoted 3 lines

Can you recommend me a Makefile which I can take as a template? Comedi uses some sort of autoconfig and I have to append then the "rules" to the automatically generated makefile.

The most simple Makefile looks like this:

obj-m := comedi.o

No more is actually needed.
You should get rid of export-objs as well - they are also obsoleted in 2.5/2.6.

Quoted 3 lines

Another thing: can a prevent the kernel of generating the "Stage 2"? It would be nice if the kernel doen't need to write to it's own directories if it compiles external modules.

The right fix is to allow you to build a kernel in a directory separate from the kernel src. This is WIP - hopefully included in mainline within a few weeks.

PS. Please do not cc: subscription only mailing lists.

Sam

author
#4 lore raw

Sam,

how can I include the "legal way" includes for comedi? Just now comedi has set up a "linux/include" path in its directory but I think this not the elegant way and it also dosn't work right now.

snoopy:/home/bp1/c/usb/2.6/comedi/comedi# make -C /usr/src/linux-2.6.0-test2 SUBDIRS=$PWD V=1 modules
make: Entering directory `/usr/src/linux-2.6.0-test2'
make -f scripts/Makefile.build obj=scripts
make -f scripts/Makefile.build obj=arch/i386/kernel arch/i386/kernel/asm-offsets.s
make[1]: `arch/i386/kernel/asm-offsets.s' is up to date.
*** Warning: Overriding SUBDIRS on the command line can cause
***          inconsistencies
mkdir -p .tmp_versions
make -f scripts/Makefile.build obj=/home/bp1/c/usb/2.6/comedi/comedi
 gcc -Wp,-MD,/home/bp1/c/usb/2.6/comedi/comedi/.comedi_fops.o.d 
-D__KERNEL__ -Iinclude -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=athlon -Iinclude/asm-i386/mach-default -nostdinc -iwithprefix include -DMODULE   -DKBUILD_BASENAME=comedi_fops -DKBUILD_MODNAME=comedi_fops -c -o /home/bp1/c/usb/2.6/comedi/comedi/comedi_fops.o /home/bp1/c/usb/2.6/comedi/comedi/comedi_fops.c
/home/bp1/c/usb/2.6/comedi/comedi/comedi_fops.c:42:29: linux/comedidev.h: No such file or directory

/Bernd
P.S.: I'm subscribed...

Quoted 49 lines · Sam Ravnborg
Quoted 3 lines · Bernd Porr

Ok. Thanks. Now the bug is that comedi cannot find the file "Rules.make" which is apparently no longer there in 2.6. Is it right that the rules are now integrated in the corresponding makefiles?

The way to find the Makefiles changed during the 2.5 development cycle. Now the kbuild Makefile (the one for comedi for example) are included from scripts/Makfile.build hereby obsoleting Rules.make.

You will NOT succeed creating a single simple makefile supporting both 2.4 and 2.6. On the other hand the Makefile are so trivial that creating two distinct version should be acceptable?

Quoted 3 lines

Can you recommend me a Makefile which I can take as a template? Comedi uses some sort of autoconfig and I have to append then the "rules" to the automatically generated makefile.

The most simple Makefile looks like this:

obj-m := comedi.o

No more is actually needed.
You should get rid of export-objs as well - they are also obsoleted in 2.5/2.6.

Quoted 3 lines

Another thing: can a prevent the kernel of generating the "Stage 2"? It would be nice if the kernel doen't need to write to it's own directories if it compiles external modules.

The right fix is to allow you to build a kernel in a directory
separate from the kernel src. This is WIP - hopefully included in mainline within a few weeks.

PS. Please do not cc: subscription only mailing lists.

Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
http://www.cn.stir.ac.uk/~bp1/
mailto:[email protected]
#5 lore raw
Quoted 5 lines · Bernd Porr

Sam,

how can I include the "legal way" includes for comedi? Just now comedi has set up a "linux/include" path in its directory but I think this not the elegant way and it also dosn't work right now.

I have not tried this, but specifying the include path relative to the directory where the .c file is placed should do the trick. So if you have:
comedi/
include/
And execute "make -C ...." within the comedi/ directory, the statement:
EXTRA_CFLAGS := -I$(obj)/../include
in the Makefile should do the trick.

Quoted 2 lines

/Bernd
P.S.: I'm subscribed...

But I'm not - getting these:

Subject: Your message to comedi awaits moderator approval

My point was not to cc: the comedi ML, since potential repliers (like me) get these kind of replies.

Sam

#6 lore raw
Quoted 2 lines · Sam Ravnborg

EXTRA_CFLAGS := -I$(obj)/../include
in the Makefile should do the trick.

Be careful -- in the case where you're building a newer driver than one which is already in the kernel, you may need to ensure your own include directory supersedes the kernel's. In that case 'CC=$(CROSS_COMPILE)gcc -I$(obj)/../include' may be useful.

An example which is currently working for 2.4 and 2.6 kernels, and which used to work for 2.2 too until quite recently, is at
http://cvs.infradead.org/cgi-bin/cvsweb.cgi/mtd/drivers/mtd/

Some people seem to think that the 'SUBDIRS=' trick is a new thing for 2.6. It's not -- it's worked for ever, and was _always_ the only reliable way of building modules to match the kernel.

Signature · 1 line
dwmw2