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
|
# pcwd Kernel Module Makefile
#
VERSION=1.40
# The currently running kernel version. This is used right below to
# determine where the kernel sources can be found.
KERNELVERSION := $(shell uname -r)
# The location of linux itself. This is used to find the kernel headers
# and other things.
#LINUX := /usr/src/linux
LINUX := /lib/modules/$(KERNELVERSION)/build
LINUX_HEADERS := $(LINUX)/include
# Uncomment the third line on SMP systems if the magic invocation fails. It
# is a bit complicated because SMP configuration changed around kernel 2.1.130
SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \
grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
then echo 1; else echo 0; fi)
#SMP := 0
#SMP := 1
# Uncomment the second or third line if the magic invocation fails.
# We need to know whether CONFIG_MODVERSIONS is defined.
MODVER := $(shell if cat $(LINUX_HEADERS)/linux/config.h $(LINUX_HEADERS)/linux/autoconf.h 2>/dev/null | grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_MODVERSIONS[[:space:]]*1'; then echo 1; else echo 0; fi)
#MODVER := 0
#MODVER := 1
MODCPPFLAGS :=
ifeq ($(SMP),1)
MODCPPFLAGS += -D__SMP__
endif
ifeq ($(MODVER),1)
MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h
endif
CFLAGS := $(MODCPPFLAGS) -D__KERNEL__ -DMODULE -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing -I$(LINUX_HEADERS)
OBJS = p4b_smbus.o
all: $(OBJS)
install: all
install -d /lib/modules/$(KERNELVERSION)/kernel/drivers/i2c/busses
install -c p4b_smbus.o /lib/modules/$(KERNELVERSION)/kernel/drivers/i2c/busses
# test ! -x /dev/watchdog || mknod -m 600 /dev/watchdog c 10 130
# test ! -x /dev/temperature || mknod -m 600 /dev/temperature c 10 131
inst: all
rmmod p4b_smbus
install -d /lib/modules/$(KERNELVERSION)/kernel/drivers/i2c/busses
install -c p4b_smbus.o /lib/modules/$(KERNEL)/kernel/drivers/i2c/busses
depmod -a
# modprobe p4b_smbus
clean:
rm -f *.o *~ core
cleandist:
rm -f *.o *~ core
|