On Tue, Oct 6, 2009 at 12:33 PM, Leonidas . <[email protected]> wrote:
> Hi,
>
> Not much of a kernel question, more to do with kernel makefiles.
>
> I am porting a piece of userspace code to kernel, but the code base
> will remain same for user
> and kernel versions of the code, my makefile will take flags to
> compile for user/kernel
> space. My module is going to be a standalone module, meaning I will
> _never_ compile it as
> part of Linux kernel build system, so I will have to write make files
> for compiling standalone
> modules, this part I am aware of.
>
>
> Are there any examples where a common makefile is used? Any links etc?
> Also are there any makefile tricks which are specific to kernel space?
>
> Like
> #ifdef __kernel__
>  kernel specific stuff
> #endif
>
>
> Also, I read somewhere that some of the CFLAGS have different meaning
> in kernel etc?
>
>
> -Leo.
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [email protected]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

Yes its good to keep code common between user and kernel. You can
define you own macro e.g. USER while building user utility and pass it
as compilation flag like -DUSER. And then in your C code you can check
for definition of this macro like #ifdef USER.
Hope this helps.

-Vinit

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to