📄 makefile
字号:
# Comment/uncomment the following line to disable/enable debugging
#DEBUG = y
KERNEL_NAME := $(shell uname -r)
#Install dir
INSTALLDIR = /lib/modules/$(KERNEL_NAME)/kernel/drivers/char
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DWDT_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
CFLAGS += $(DEBFLAGS)
CFLAGS += -Wall -DMODULE -pipe -DLINUX -D__KERNEL__
KERNELDIR := /lib/modules/$(KERNEL_NAME)/build
CFLAGS += -I$(KERNELDIR)/include -I.
#different linux version
K_VERSION:=$(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
ifeq ($(K_VERSION), 2.6)
#kernel 2.6
TARGET = w83627hf_wdt.ko
wdt-objs := w83627hf_wdt.o
obj-m := w83627hf_wdt.o
all:
$(MAKE) -C $(KERNELDIR) M=$(shell pwd) modules
else
#kernel 2.4
OBJS = w83627hf_wdt.o
TARGET = w83627hf_wdt.o
SRC = w83627hf_wdt.o
all: $(OBJS)
wdt.o: $(SRC:.c=.o)
$(LD) -r $^ -o $@
endif
.PHONY: clean install uninstall test
test:w83627hf_test
w83627hf_test:w83627hf_test.o
install:
install -D $(TARGET) $(INSTALLDIR)/$(TARGET)
uninstall:
rm -rf $(INSTALLDIR)/$(TARGET)
clean:
rm -rf *.o *.ko *.symvers *.mod.c .*.cmd .tmp_versions .*.swp wdt3114_test.o w83627hf_test
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -