[Scons-users] Building Linux Kernel Loadable Modules

Enrique Herrera enriqueh73 at gmail.com
Wed Jan 14 15:42:32 EST 2015

I have a legacy Linux embedded application, that uses Scons has its build
tool. The project only consists of an SConstruct file. I do not have the
luxury of having SConfig.py and Sconscript files within this project. I
have been trying to add a new env.Environment() that will build an
external loadable module of a Linux Kernel 2.4.x driver.

Basically, this is what I need to do this to build the driver:

gcc -Wall -D__KERNEL__ -DMODULE -I/<kernel path>/linux/include
-fno-strict-aliasing -O2 -c -o foo.o foo.c
gcc -Wall -D__KERNEL__ -DMODULE -I/<kernel path>/linux/include
-fno-strict-aliasing -O2 -c -o bar.o bar.c

ld -r foo.o bar.o -o foobar.o

So far, this is what I have in SConstruct to build this driver:

kflags = '-Wall -D__KERNEL__ -DMODULE -I/<kernel path>/linux/include
-fno-strict-aliasing -O2 '
driver_srouce = Split("""

env_driver = Environment(CC='gcc',
                         SRC='/<src path>'


I do not know what to do after this. I tried to use
env_driver.StaticLibrary().  But i got :

=== Running SCons at 1/14/15 1:22 PM ====
Command line: /usr/local/python/bin/scons-2.3.4 -u --jobs=16
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build/target
gcc -o build/target/foo.o -c -Wall -fno-strict-aliasing -O2 -D__KERNEL__
-DMODULE -I/<path>/<kerne>/<src>/linux/include driver/foo.c
gcc -o build/target/bar.o -c -Wall -fno-strict-aliasing -O2 -D__KERNEL__
-DMODULE -I/<path>/<kerne>/<src>/linux/include driver/bar.c
ar rc "build/target/libfoobar.o " build/target/foo.o build/target/bar.o
ranlib "build/target/libmfoobar.o "
scons: done building targets.
Duration 1127 ms.

That's not what I really want to do. I just need to link the two object
files together. I really do not know how.

I would appreciate any help you might have.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150114/7b7c2d96/attachment.html>

More information about the Scons-users mailing list