Conditional compilation depending on CONFIG_FOOBAR

Srivatsa Bhat bhat.srivatsa at gmail.com
Mon Dec 12 02:59:10 EST 2011


On Mon, Dec 12, 2011 at 9:17 AM, contemplating zombie <
contemplatingzombie at gmail.com> wrote:

> Just to clarify more, if I put my code in something like:
> #ifdef CONFIG_FOOBAR
> my code
> #endif
>
> Then my module's Makefile should check if this parameter is defined in the
> ".config" file. How should I modify my Makefile to do that?
>
>
> On Sun, Dec 11, 2011 at 10:44 PM, contemplating zombie <
> contemplatingzombie at gmail.com> wrote:
>
>> Hi,
>>
>> I want to conditionally compile some code in module if CONFIG_FOOBAR is
>> defined.
>> How can I add this check to my module's makefile?
>>
>> -Thanks.
>>
>
>
If I understand correctly, you want some part of your module to be compiled
only
when CONFIG_FOOBAR is defined. You already mentioned the solution yourself!:
Just put that code within #ifdef CONFIG_FOOBAR and #endif
That would check the .config file and see if CONFIG_FOOBAR is defined; and
only if it
is defined, that code piece gets compiled, else it will simply get stripped
off.

Regards,
Srivatsa S. Bhat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111212/a16e25aa/attachment-0001.html 


More information about the Kernelnewbies mailing list