可編譯一個目錄下層所有文件夾,每個文件夾生成一個同文件夾名的內(nèi)核模塊文件
目錄結(jié)構:
.
├── fpgd_gpp
│ ├── fpgd_gpp_console.c
│ ├── fpgd_gpp_console.h
│ ├── fpgd_gpp_console.o
│ ├── fpgd_gpp_hw.c
│ ├── fpgd_gpp_hw.h
│ ├── fpgd_gpp_hw.o
│ ├── fpgd_gpp_image.c
│ ├── fpgd_gpp_image.h
│ ├── fpgd_gpp_image.o
│ ├── fpgd_gpp.ko
│ ├── fpgd_gpp_mmio.c
│ ├── fpgd_gpp_mmio.h
│ ├── fpgd_gpp_mmio.o
│ ├── fpgd_gpp.mod.c
│ ├── fpgd_gpp.mod.o
│ ├── fpgd_gpp_module.c
│ ├── fpgd_gpp_module.h
│ ├── fpgd_gpp_module.o
│ ├── fpgd_gpp.o
│ ├── fpgd_gpp_osal.c
│ ├── fpgd_gpp_osal.o
│ ├── fpgd_gpp_unit.c
│ ├── fpgd_gpp_unit.o
│ ├── fpgd_gpp_update.c
│ ├── fpgd_gpp_update.h
│ ├── fpgd_gpp_update.o
│ ├── Makefile
│ ├── modules.order
│ └── Module.symvers
├── Makefile
上層Makefile
KERNEL_VER = linux-2.6.37
export KERNEL_VER
KDIR = ../../kernel/$(KERNEL_VER)
export KDIR
SUBDIRS := fpgd_gpp
.PHONY:all
all:
@echo
"building for" $(strip $(KERNEL_VER))
for dir in
$(SUBDIRS);\
do make -C
$$dir;\
done;
@echo
"building for" $(strip $(KERNEL_VER)) finish
.PHONY:install
install:
@echo
"installing for" $(strip $(KERNEL_VER))
for dir in
$(SUBDIRS);\
do make -C
$$dir install;\
done;
@echo
"installing for" $(strip $(KERNEL_VER)) finish
.PHONY:clean
clean:
@echo
"cleaning for" $(strip $(KERNEL_VER))
for dir in
$(SUBDIRS);\
do make -C
$$dir clean;\
done;
@echo
"cleaning for" $(strip $(KERNEL_VER)) finish
下層Makefile
ifneq ($(KERNELRELEASE),)
export EXTRA_CFLAGS := -I../../include/
# second run in kernel dir
obj-m := $(MODNAME).o
$(MODNAME)-objs = $(LOCOBJS)
else
# first run in module dir
PWD:= $(shell pwd)
SRCS := $(shell echo *.c)
LOCOBJS := $(SRCS:.c=.o)
MODNAME = $(shell basename `pwd`)
export LOCOBJS
export MODNAME
default:
$(MAKE) -C
$(KDIR) M=$(PWD) modules
clean:
rm -f *.o
*.ko .*.mod.c .*.cmd *.mod.c *.o.p *.order *.symvers
rm -rf
.tmp_versions
install:
cp -f *.ko
../../drivers_build/bin/
endif
|