'KCPPFLAGS'에 해당하는 글 1건


출처 : http://stackoverflow.com/questions/15430921/how-to-pass-parameters-from-makefile-to-linux-kernel-module-source-code



As the Linux build system uses kernel provided Makefiles that can reasonably not be changed. I'd suggest to place your version number directly into the source code instead of in the Makefile.

There's a possibility thought. You can define a CPPFLAGS environment variable. It should be passed by the kernel Makefile to the C compiler command line. If you define this CPPFLAGS variable as -DVERSION=42, maybe you can use this VERSION macro inside your source file.

all:
    CPPFLAGS="-DVERSION=42" make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

Note that CPPFLAGS stands for "C PreProcessor FLAGS". It is unrelated to C++.

After testing it. This does not work. There's a solution however. The kernel Makefile allows (and uses) the definition of the KCPPFLAGS environment variable that will be added to the kernel Makefile defined own CPPFLAGS.

You have to use:

all:
    KCPPFLAGS="-DVERSION=42" make -C /lib/modules/$(shell uname -r)/build M=$(PWD) 


WRITTEN BY
RootFriend
개인적으로... 나쁜 기억력에 도움되라고 만들게되었습니다.

,