Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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??)
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'
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???
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.