Linux内核Makefile中的回显字符串
我曾多次使用标准的Linux内核Makefile中的回显字符串,linux,makefile,linux-kernel,linux-device-driver,kernel-module,Linux,Makefile,Linux Kernel,Linux Device Driver,Kernel Module,我曾多次使用标准的Makefile构建树外模块。现转载如下: # Comment/uncomment the following line to disable/enable debugging DEBUG = y # Add your debugging flag (or not) to CFLAGS ifeq ($(DEBUG),y) DEBFLAGS = -O0 -g3 -DSCULL_DEBUG # "-O" is needed to expand inlines else
Makefile
构建树外模块。现转载如下:
# Comment/uncomment the following line to disable/enable debugging
DEBUG = y
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O0 -g3 -DSCULL_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
LDDINC=$(PWD)/../include
EXTRA_CFLAGS += $(DEBFLAGS)
EXTRA_CFLAGS += -I$(LDDINC)
ifneq ($(KERNELRELEASE),)
# call from kernel build system
@echo 'called from kernel build system' #<-- FAILS HERE
scull-objs := main.o pipe.o access.o
obj-m := scull.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
cd /lib/modules/$(shell uname -r) && depmod -a
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(EXTRA_CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
#注释/取消注释以下行以禁用/启用调试
调试=y
#将调试标志(或不)添加到CFLAGS
ifeq($(调试),y)
DEBFLAGS=-O0-g3-DSCULL_DEBUG#扩展内联线需要“-O”
其他的
DEBFLAGS=-O2
恩迪夫
LDDINC=$(PWD)/../include
额外\u CFLAGS+=$(取消标记)
额外费用+=-I$(LDDINC)
ifneq($(内核发布),)
#来自内核构建系统的调用
@echo“从内核构建系统调用”#。依赖
ifeq(.depend,$(wildcard.depend))
包括,取决于
恩迪夫
我希望make
在处理此Makefile时打印自定义字符串消息,因此我尝试添加@echo
消息(请参阅代码中的此处失败
)。但这样做失败,出现以下错误:
Makefile:25:**配方在第一个目标之前开始。停下来
违规的线在上面标出。还有什么我可以做我想做的吗?删除非食谱行中的前导选项卡。制表符对于make很有意义,您不应该仅使用它们缩进
ifneq…else…endif
。使用简单的$(信息消息)
@RenaudPacalet是的,您是对的。对于echo,当标签添加到非配方的内容时,它不起作用。非常感谢。你是否在某个地方写博客?可能重复删除非食谱行中的前导选项卡。制表符对于make很有意义,您不应该仅使用它们缩进ifneq…else…endif
。使用简单的$(信息消息)
@RenaudPacalet是的,您是对的。对于echo,当标签添加到非配方的内容时,它不起作用。非常感谢。你在什么地方写博客吗?可能是重复的