-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
49 lines (39 loc) · 1.19 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
###################################################################
#
# make file to build and install/uninstall the ttyebus module
#
#
###################################################################
TARGET_MODULE:=ttyebus
TARGET_DIR:=/lib/modules/$(shell uname -r)/kernel/drivers/tty/serial
# If we running by kernel building system
ifneq ($(KERNELRELEASE),)
$(TARGET_MODULE)-objs := $(TARGET_MODULE)m.o
obj-m := $(TARGET_MODULE).o
# If we are running without kernel build system
else
BUILDSYSTEM_DIR?=/lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd)
all :
# run kernel build system to make module
$(MAKE) -C $(BUILDSYSTEM_DIR) M=$(PWD) modules
clean:
# run kernel build system to cleanup in current directory
$(MAKE) -C $(BUILDSYSTEM_DIR) M=$(PWD) clean
load:
modprobe $(TARGET_DIR)/$(TARGET_MODULE)
unload:
modprobe -r $(TARGET_MODULE)
install:
cp $(TARGET_MODULE).ko $(TARGET_DIR)/$(TARGET_MODULE).ko
depmod -a
cd $(TARGET_DIR)/
modprobe $(TARGET_MODULE)
sed -i "s/$(TARGET_MODULE)//g" /etc/modules
echo "$(TARGET_MODULE)" >> /etc/modules
uninstall:
modprobe -r $(TARGET_MODULE)
rm $(TARGET_DIR)/$(TARGET_MODULE).ko
sed -i "s/$(TARGET_MODULE)//g" /etc/modules
endif