makefile与make 4.0并包含路径问题

时间:2016-03-30 12:40:36

标签: makefile include-path

我有一个内核模块的makefile。 EXTRA_CFLAGS用于传递包含路径。但是在Debian 3.82上,只有明确指定了完整路径(硬编码),如果使用了make函数,它才能正常工作:

EXTRA_CFLAGS += -I${PWD}/../include

INC_PATH = $(abspath ${PWD}/../include)
EXTRA_CFLAGS += -I$(INC_PATH)

这不起作用 - 找不到文件。我检查了EXTRA_CFLAGS的输出 - 它是正确的,这适用于其他linux的make 3.82。

增加:

gcc-4.8 -Wp,-MD,/home/user/temp/dmamemory.0/driver/./.DMATestmain.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/src/linux-headers-3.16.0-4-common/arch/x86/include -Iarch/x86/include/generated  -I/usr/src/linux-headers-3.16.0-4-common/include -Iinclude -I/usr/src/linux-headers-3.16.0-4-common/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/usr/src/linux-headers-3.16.0-4-common/include/uapi -Iinclude/generated/uapi -include /usr/src/linux-headers-3.16.0-4-common/include/linux/kconfig.h   -I/home/user/temp/dmamemory.0/driver -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -m64 -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 -Wframe-larger-than=2048 -fstack-protector -Wno-unused-but-set-variable -fno-var-tracking-assignments -g -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO   -I/usr/src/linux-headers-3.16.0-4-common/../include  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(DMATestmain)"  -D"KBUILD_MODNAME=KBUILD_STR(dmatest)" -c -o /home/user/temp/dmamemory.0/driver/./.tmp_DMATestmain.o /home/user/temp/dmamemory.0/driver/./DMATestmain.c

我发现它在/usr/src/linux-headers-3.16.0-4-common/中运行$(PWD),而不是在Makefile(当前)目录中运行。所以,EXTRA_CFLAGS看起来像:

-I/usr/src/linux-headers-3.16.0-4-common/../include

不喜欢:

 -I/home/user/temp/dmamemory.0/../include

SOLUTION:

使用KCFLAGS:

${MAKE} -C ${KDIR} M=$(PWD) KCFLAGS="-I$(PWD)/../include"  modules

0 个答案:

没有答案