- 论坛徽章:
- 0
|
内核:
需要编译lib库,但C文件和内核源码不在一个目录下
如何编写Makefile引用内核源码?
我的Makefile如下,提示找不到用到的内核源码
KERNELDIR=/PROJECT/kernel/kernel
CROSS_COMPILE ?=
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
lib_OBJECTS = hook_driver.o
lib_SOURCE = hook_driver.c
hook_driver.a (lib_OBJECTS)
$(AR) $(KERNELDIR) M=$(shell pwd) -o $@ $^
$(lib_OBJECTS) (lib_SOURCE)
$(CC) $(KERNELDIR) M=$(shell pwd) -o $@ $^
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions *.bak Module.symvers *.order |
|