Creating a debug target in Linux 2.6 driver module makefile

夙愿已清 提交于 2019-12-05 17:41:06

A "-D" option is not meant to be passed to make: it is a C preprocesseor (cpp) option.

To define DEBUG_OUTPUT for your build you have to add the following line to your Kbuild file:

EXTRA_CFLAGS = -DDEBUG_OUTPUT

Afterwards you can call, as usual:

make -C $(KERNEL_DIR) M=`pwd`

EDIT: If you don't want to edit the Kbuild file, you can have a debug target like this:

INCLUDES="-Imy_include_dir1 -Imy_include_dir2"

.PHONY: debug
debug:
        $(MAKE) -C $(KDIR) M=`pwd` EXTRA_CFLAGS="$(INCLUDES) -DDEBUG_OUTPUT"

EDIT#2:

MY_CFLAGS=-DFOO -DBAR -Imydir1

all:
        $(MAKE) -C $(KDIR) M=`pwd` EXTRA_CFLAGS="$(MY_CFLAGS)"

debug: MY_CFLAGS+=-DDEBUG_OUTPUT
debug:
        $(MAKE) -C $(KDIR) M=`pwd` EXTRA_CFLAGS="$(MY_CFLAGS)"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!