-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
66 lines (49 loc) · 1.66 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
obj-m += udp_client.o
obj-m += udp_server.o
K_DIR:= kern_udp
COMMON_FILES:= $(K_DIR)/kernel_udp.o $(K_DIR)/k_file.o \
$(K_DIR)/kernel_service.o $(K_DIR)/kernel_message.o
udp_server-y:= \
$(COMMON_FILES) \
$(K_DIR)/udp_server.o \
$(K_DIR)/kserver_operations.o
udp_client-y:= \
$(COMMON_FILES) \
$(K_DIR)/udp_client.o \
$(K_DIR)/kclient_operations.o
# ADDITIONAL_FLAG:= #add here if you want to give flags to modules
EXTRA_CFLAGS:= -I$(PWD)/$(K_DIR)/include -O2 # $(ADDITIONAL_FLAG)
endif
USER_FLAGS:= -I$(PWD)/user_udp/include -O2
ccflags-y:= -std=gnu99 -Wno-declaration-after-statement
COMMON_OBJ:=user_udp.o user_message.o
COMMON_HDR:=user_udp.h user_message.h
I_DIR:= user_udp
USER_CL_OBJ:=user_client.o uclient_operations.o $(COMMON_OBJ)
USER_SERV_OBJ:=user_server.o userver_operations.o $(COMMON_OBJ)
_USER_CL_HEAD:= user_udp.h uclient_operations.h $(COMMON_HDR)
USER_CL_HEAD:= $(patsubst %,$(I_DIR)/include/%,$(_USER_CL_HEAD))
_USER_SERV_HEAD:= user_udp.h userver_operations.h $(COMMON_HDR)
USER_SERV_HEAD:= $(patsubst %,$(I_DIR)/include/%,$(_USER_CL_HEAD))
ifeq ($(UNAME), Linux)
all: user_client user_server
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
else
all: user_client user_server
endif
%.o: $(I_DIR)/%.c $(USER_CL_HEAD) $(USER_SERV_HEAD)
$(CC) $(USER_FLAGS) $(ccflags-y) -c $< -o $@
user_client: $(USER_CL_OBJ)
$(CC) $(USER_FLAGS) -o $@ $^
user_server: $(USER_SERV_OBJ)
$(CC) $(USER_FLAGS) -o $@ $^
ifeq ($(UNAME), Linux)
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
rm user_client user_server
else
clean:
rm user_client user_server *.o
endif