请高手详细解释一个makfile文件
# Comment/uncomment the following line to disable/enable debugging
#DEBUG = y
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
CFLAGS += $(DEBFLAGS)
CFLAGS += -I$(LDDINC)
ifneq ($(KERNELRELEASE),)
# call from kernel build system
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) LDDINC=$(PWD)/../include modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
====================================
上面是一个makfile文件,请问:
1.KERNELDIR ?= /lib/modules/$(shell uname -r)/build中的$(shell uname -r)是什么意思?我觉得uname是一个显示系统信息的命令,但是这里应该一个目录名呀!!
2.modules是一个伪目标吗?它是默认执行的吗?它里面的3句话
$(MAKE) -C $(KERNELDIR), M=$(PWD), LDDINC=$(PWD)/../include modules分别是什么意思?
3.
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
4.这个文件中的真正的编译命令在哪里?
这一整段是什么意思?这段里的-M与第2个问题里的M有关系吗?
请大家不吝赐教,谢谢