我的存在的祸根 Makefile 遇到了一些麻烦。我正在尝试创建一个名为“can.ko”的内核模块(.ko 文件)。我正在编译十几个源文件:
TARGET = can
OBJS = can_core.o can_open.o can_select.o can_sysctl.o can_write.o can_close.o \
can_ioctl.o can_read.o can_util.o can_debug.o can_error.o can_async.o
KDIR = /lib/modules/3.1.10-1.16-desktop/build
PWD := $(shell pwd)
obj-m += $(TARGET).o
default:
make -C $(KDIR) M=$(PWD) modules
$(TARGET).o : $(OBJS)
编译器吐出它找不到。“can.c”。
make[4]: *** No rule to make target `/home/mike/iCOM-SDKv1.11.000/framework/drivers/can/can.c', needed by `/home/mike/iCOM-SDKv1.11.000/framework/drivers/can/can.o'. Stop.
我很确定我不需要在源文件之后命名输出对象,所以很明显有问题。我做了一些搜索,将多个源文件放在一起,发现这是另一种选择:
TARGET = can
can-objs := can_core.c can_open.c can_select.c can_sysctl.c can_write.c \
can_close.c can_ioctl.c can_read.c can_util.c \
can_debug.c can_error.c \
can_async.c
KDIR = /lib/modules/3.1.10-1.16-desktop/build
PWD := $(shell pwd)
obj-m += $(TARGET).o
default:
make -C $(KDIR) M=$(PWD) modules
这次我被告知它不知道如何处理 .c 文件:
LD [M] /home/mike/iCOM-SDKv1.11.000/framework/drivers/can/can.o
/home/mike/iCOM-SDKv1.11.000/framework/drivers/can/can_core.c: file not recognized: File format not recognized
任何人都可以帮我让这个东西工作吗?