RE: Exporting symbols from a module.

Khachaturov, Vassilii (Vassilii.Khachaturov@comverse.com)
Thu, 17 May 2001 14:46:35 -0400


If you have a local makefile with which you wish to build your module
not linked under the kernel tree in the proper way, you still can
"ride" on the master Makefile.

This way one can eliminate the dependency on your particular
machine kernel compilation options to be hardwired in the local Makefile.
I.e., once you reconfigure the kernel, your driver will compile
itself when you do a local "make" with the correct set of the new flags.

This is what you can do on 2.2 (Makefile excerpt follows):
EXTRA_CFLAGS := -DDEBUG -DLINUX -I/usr/src/foo/include
MI_OBJS := your-module.o
O_TARGET := your-module.o
O_OBJS := your1.o your2.o

# Reuse Linux kernel master makefile on this directory
ifdef MAKING_MODULES
include $(TOPDIR)/Rules.make
else
all::
cd '/usr/src/linux' && make modules SUBDIRS=$(PWD)
endif

In 2.4 the syntax is different. Rename
MI_OBJS to obj-m and O_OBJS to obj-y to achieve the same goal there:
obj-m := your-module.o
O_TARGET := your-module.o
obj-y := your1.o your2.o

HTH,
Vassilii

> -----Original Message-----
> From: Anders Peter Fugmann [mailto:afu@fugmann.dhs.org]
> Sent: Thursday, May 17, 2001 12:51 PM
> To: Andreas Dilger
> Cc: linux-kernel
> Subject: Re: Exporting symbols from a module.
>
>
> Resolved.
>
> I just looked at what the kernel did whne compiling a module that
> exported some symbols, and discovered that I needed
> to set CFLAGS to:
>
> -D__KERNEL__ -I$/usr/src/linux) -Wall -Wstrict-prototypes \
> -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe \
> -DMODULE -DMODVERSIONS -include \
> /usr/src/linux/modversions.h
>
> Now all works correctly, and I can load my modules.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/