blob: 51f01afa70a5fe77e3ee9dee916e17ecea7aac98 (
plain)
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
|
#
# Makefile for building the dopanic module on Linux 2.4
#
MOD=dopanic
MOD_CONF= $(MOD:%=%.conf)
RHVER=RH7.1
KVER=2.6.0
KTAG=
KSRC=/usr/src/linux
# Note: /usr/src/linux should point to /usr/src/linux-$(KVER)$(KTAG).
# The KVER is only used here for "make install".
CC=gcc
#Use the cflags that shows all warnings or the one that doesn't.
#CFLAGS = -O2 -Wall -DLINUX_DEBUG
CFLAGS = -O2
#Note: Use the following to build a driver with no versioning.
#K_CFLAGS = -D__KERNEL__ -DMODULE -D__SMP__ -DCONFIG_X86_LOCAL_APIC -D__NO_VERSION__
#
#The K_CFLAGS is used to build on all RedHat systems.
#ADDK_CFLAGS is used only when building on pre RedHat 7.0 systems.
#
K_CFLAGS = -D__KERNEL__ -DMODULE -D__SMP__ -DCONFIG_X86_LOCAL_APIC -DMODULES
ADDK_CFLAGS = -DMODVERSIONS -include /usr/include/linux/modversions.h
CPPFLAGS = -I. -DLINUX -I/usr/src/linux/include
K_VERSION:=$(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
ifeq ($(K_VERSION), 2.6)
TARGET = dopanic.ko
# CFILES = dopanic.c
# dopanic-objs := $(CFILES:.c=.o)
obj-m += dopanic.o
make -C $(KSRC) V=1 SUBDIRS=$(shell pwd) modules
endif
#List all the relevant files here
OBJS = dopanic.o
all: $(MOD)
$(MOD): $(OBJS)
$(LD) -r -o $(MOD) $(OBJS)
%.o: %.c
if [ "$(RHVER)" = "PRE-7.0" ]; \
then \
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(K_CFLAGS) $(ADDK_CFLAGS) -o $@ $< ; \
else \
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(K_CFLAGS) -o $@ $< ; \
fi
install: $(MOD)
cp $(MOD) /lib/modules/$(KVER)$(KTAG)/kernel/arch/i386/kernel
clean:
rm -f $(OBJS) $(MOD)
clobber:
rm -f $(OBJS) $(MOD)
|