LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-14-2006, 03:05 AM   #1
bhuvanmital
LQ Newbie
 
Registered: Dec 2005
Posts: 23

Rep: Reputation: 15
How to get make communicate with my module?


I have written a device driver in linux-2.6.15. There are certain parts of code that involve conditional execution using
#ifdef LINUX statements.(LINUX being my userdefined variable)

Now when i compile my code using a make file, i want to define/undefile linux through that makefile.
But unfortunately make -C /lib/modules/linux/build modules does not allow the declaration of variables that can be communicated to my module..

Please help me..

I am looking for a statement like the following:

make -LINUX -C /lib/modules/2.6.15/build M=`pwd` modules
(obviously this statement doesnt work, so please suggest how to make my module recognize the definition of LINUX variable??)
 
Old 02-14-2006, 04:17 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Usually, the options and definitions are given in the CFLAGS definition in the Makefile. You can define a variable like this: -DLINUX.

You can also define variables on the line before or after the make command. The manual for make will much more indepth information on the order of preference for variables defined before, after the make command, and in the Makefile.
example:
make CFLAGS='-DLINUX'

Last edited by jschiwal; 02-14-2006 at 04:29 AM.
 
Old 02-14-2006, 06:00 AM   #3
bhuvanmital
LQ Newbie
 
Registered: Dec 2005
Posts: 23

Original Poster
Rep: Reputation: 15
the CFLAGS and LDFLAGS etc. work only while making a user level file when i'm using gcc command. But thats not the case here.

I am relying on the parent makefile in /lib/modules/2.6.15/build for the gcc command. It is to this file i want to pass my own flag (called LINUX). How do i do that???

Please help someone. My situation is dire....
 
Old 02-14-2006, 05:41 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Does the Makefile have a $(CFLAGS) or $(CXFLAGS) reference in the definition of $(CC). How about the Makefile for your module? I would think that an environment variable would still be defined when your Makefile is called.
 
Old 02-15-2006, 05:20 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I had an earlier message which hasn't shown up. Perhaps it wasn't posted.

You could have the source located outside of the kernel source. Then you can write your own ./configuration file and Makefile.

The nvidia driver and ndiswrapper driver are installed this way. The kernal module is compiled, modprobe scripts are modified as needed, libraries are copied if needed, and depmod -a and ldconfig are run as part of the "make install" target.

Official patches and drivers have configuration items defined in the .config file for the kernel. The #ifdefs in module source will reference these values.
You could also have tests based on whether standard linux definitions exists.
In other words, perform an indirect test to make the same determination. An indirect test for a definition, that only a Linux kernel would have, could be placed in one of your header files and result in defining LINUX then.

Also, if you study several of the text and docbook docs in /usr/source/kernel-<version>/Documentation/ you should get a good grasp on how kernel module developement is done. You may need to install a kernel-doc package, if the kernel source you have was installed from a package.

Last edited by jschiwal; 02-15-2006 at 07:35 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What can you ACTUALLY make a module for in the kernel? djuhl30 Linux - Hardware 2 01-30-2006 02:34 AM
module and make problems j0ck Linux - General 1 06-26-2005 02:03 PM
Make Module problem hardyvoje Red Hat 5 05-19-2005 02:27 PM
How to make a module load on boot WolfCub Debian 8 05-13-2005 12:46 PM
2.6.0 make module error RTT Slackware 3 12-19-2003 06:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration