1 |
|
# Linux makefile for sheep_net driver |
2 |
+ |
KERNEL_DIR = /lib/modules/$(shell uname -r) |
3 |
+ |
KERNEL_SOURCE = $(KERNEL_DIR)/build |
4 |
+ |
LV := $(shell test -f $(KERNEL_SOURCE)/Rules.make && echo 24 || echo 26) |
5 |
+ |
MP := $(shell test -f $(KERNEL_SOURCE)/Rules.make && echo "o" || echo "ko") |
6 |
+ |
|
7 |
+ |
ifeq ($(LV),26) |
8 |
+ |
# Kernel 2.6 |
9 |
+ |
|
10 |
+ |
obj-m = sheep_net.o |
11 |
+ |
|
12 |
+ |
sheep_net.ko: sheep_net.c |
13 |
+ |
$(MAKE) -C $(KERNEL_SOURCE) M=$$PWD modules |
14 |
+ |
|
15 |
+ |
clean: |
16 |
+ |
$(MAKE) -C $(KERNEL_SOURCE) M=$$PWD clean |
17 |
+ |
|
18 |
+ |
else |
19 |
+ |
# Kernel 2.4 |
20 |
|
|
21 |
|
## System specific configuration |
22 |
< |
CC = cc |
5 |
< |
CPPFLAGS = -I. -I/usr/src/linux/include |
22 |
> |
CPPFLAGS = -I. -I$(KERNEL_SOURCE)/include |
23 |
|
CFLAGS = -O2 -Wall -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES |
24 |
|
ASFLAGS = |
25 |
|
LDFLAGS = |
26 |
|
LIBS = |
10 |
– |
KERNDIR = /lib/modules/$(shell uname -r) |
27 |
|
|
28 |
|
## Files |
29 |
|
OBJS = sheep_net.o |
32 |
|
sheep_net.o: sheep_net.c |
33 |
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) sheep_net.c |
34 |
|
|
19 |
– |
dev: |
20 |
– |
mknod /dev/sheep_net c 10 198 |
21 |
– |
|
22 |
– |
install: sheep_net.o |
23 |
– |
install -d $(KERNDIR)/misc |
24 |
– |
install -m 644 sheep_net.o $(KERNDIR)/misc |
25 |
– |
depmod -a |
26 |
– |
|
35 |
|
clean: |
36 |
|
-rm $(OBJS) |
37 |
|
|
38 |
|
dep depend: |
39 |
|
makedepend $(CPPFLAGS) -Y *.c |
40 |
|
|
41 |
+ |
endif |
42 |
+ |
|
43 |
+ |
dev: |
44 |
+ |
mknod /dev/sheep_net c 10 198 |
45 |
+ |
|
46 |
+ |
install: sheep_net.$(MP) |
47 |
+ |
install -d $(KERNEL_DIR)/misc |
48 |
+ |
install -m 644 sheep_net.$(MP) $(KERNEL_DIR)/misc |
49 |
+ |
depmod -a |
50 |
+ |
|
51 |
|
# DO NOT DELETE |