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 |
23 |
< |
CPPFLAGS = -I. -I/usr/src/linux/include |
6 |
< |
CFLAGS = -O2 -Wall -D__KERNEL__ -DMODULE -DLINUX |
22 |
> |
CPPFLAGS = -I. -I$(KERNEL_SOURCE)/include |
23 |
> |
CFLAGS = -O2 -Wall -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES |
24 |
|
ASFLAGS = |
25 |
|
LDFLAGS = |
26 |
|
LIBS = |
32 |
|
sheep_net.o: sheep_net.c |
33 |
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) sheep_net.c |
34 |
|
|
18 |
– |
dev: |
19 |
– |
mknod /dev/sheep_net c 10 198 |
20 |
– |
|
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 |