[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Include directories



Quoting Viktor Rosenfeld (rosenfel@informatik.hu-berlin.de):
> 
> Oswald Buddenhagen wrote:
> > 
> > > So basically my question is: Is it OK to softlink the include
> > > directories?  Or does the "don't mess with anything, but
> > > /usr/local/"-policy aplly and is there a Right Way [TM] to change the
> > > development environment?  What other directories have to be changed
> > > (/usr/include/scsi seems to be a good candidate, too.)?
> > >
> > the policy it simple: mess only with the different /usr/src/linux-*
> > directories. there should be a symlink /usr/src/linux to the
> > sources of the currently running kernel - the rest works automatically, if
> > the kernel was compiled once (this sets up the other symlinks).
> 
> But that's not my problem.  /usr/src/linux is a symlink to
> /usr/local/src/linux-2.2.14.  But when I compiled a kernel module (that
> is not part of the stock kernel!) from /usr/local/src/whatever it would
> use the include files in /usr/include/linux, which makes sense to me if
> there's just a #include <linux/whatever> in the source (although I'm not
> a C programmer).  /usr/include/linux/version.h says, it's for Linux
> 2.0.36, which makes sense, too, because that's the kernel, that comes
> along with Debian slink.  

Hmm. My reading of this (no expert) is that things that run in kernel
space should be compiled with kernel headers, things that run in
user space with /usr/include. And that's why Debian doesn't use the
infamous symlinks. It also means that you can compile modules for
different kernel versions just by moving the linux -> linux-x.x.xx
link. OTOH /usr/include matches the libc on your system. I think
compiling for different libc's is quite tricky by comparison.

BTW I think the kernel-headers packages are just that: a sub-set
of the kernel-source so you don't have to have all the .c files,
docs etc. just to compile a module. I've never downloaded a
kernel-headers package and I've compiled many kernels. Sorry, Oki DZ.

> So my problem is not a kernel compile, that works fine.  My problem is
> compiling a kernel module that is not part of the official kernel
> against the kernel.  Or in other words: How do I modify
> /usr/include/linux?

Are you saying that the software you downloaded has .c files and some .h
files specially for it? What I do in that case is to have all the .c
and .h files in the current directory (whereever), and use
something like (taken from a bash function)
/usr/bin/gcc -DMODULE -D__KERNEL__ -I. -I/usr/local/src/linux/include \
-O2 -m486 -g -Wall -c $@ -o ${SOURCE}.o ${SOURCE}.c
(for simple one-to-one source to object file compilations).
For this to work with #include <linux/whatever> headers, you need to
ln -s . linux
but remember to remove it before you zip up your files (circular
reference). Alternatively I suppose you could move the headers into
./linux instead.

Please let me know if you don't like this as I'm just about to upgrade
my own modules from 2.0 to 2.2 and need to look at that bash function.
I might as well get it right.

Cheers,

-- 
Email:  d.wright@open.ac.uk   Tel: +44 1908 653 739  Fax: +44 1908 655 151
Snail:  David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA
Disclaimer:   These addresses are only for reaching me, and do not signify
official stationery. Views expressed here are either my own or plagiarised.


Reply to: