| 1 |
# pcwd Kernel Module Makefile |
|---|
| 2 |
# |
|---|
| 3 |
|
|---|
| 4 |
VERSION=1.40 |
|---|
| 5 |
|
|---|
| 6 |
# The currently running kernel version. This is used right below to |
|---|
| 7 |
# determine where the kernel sources can be found. |
|---|
| 8 |
KERNELVERSION := $(shell uname -r) |
|---|
| 9 |
|
|---|
| 10 |
# The location of linux itself. This is used to find the kernel headers |
|---|
| 11 |
# and other things. |
|---|
| 12 |
#LINUX := /usr/src/linux |
|---|
| 13 |
LINUX := /lib/modules/$(KERNELVERSION)/build |
|---|
| 14 |
LINUX_HEADERS := $(LINUX)/include |
|---|
| 15 |
|
|---|
| 16 |
# Uncomment the third line on SMP systems if the magic invocation fails. It |
|---|
| 17 |
# is a bit complicated because SMP configuration changed around kernel 2.1.130 |
|---|
| 18 |
SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \ |
|---|
| 19 |
grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \ |
|---|
| 20 |
then echo 1; else echo 0; fi) |
|---|
| 21 |
#SMP := 0 |
|---|
| 22 |
#SMP := 1 |
|---|
| 23 |
|
|---|
| 24 |
# Uncomment the second or third line if the magic invocation fails. |
|---|
| 25 |
# We need to know whether CONFIG_MODVERSIONS is defined. |
|---|
| 26 |
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) |
|---|
| 27 |
#MODVER := 0 |
|---|
| 28 |
#MODVER := 1 |
|---|
| 29 |
|
|---|
| 30 |
MODCPPFLAGS := |
|---|
| 31 |
|
|---|
| 32 |
ifeq ($(SMP),1) |
|---|
| 33 |
MODCPPFLAGS += -D__SMP__ |
|---|
| 34 |
endif |
|---|
| 35 |
|
|---|
| 36 |
ifeq ($(MODVER),1) |
|---|
| 37 |
MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h |
|---|
| 38 |
endif |
|---|
| 39 |
|
|---|
| 40 |
CFLAGS := $(MODCPPFLAGS) -D__KERNEL__ -DMODULE -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing -I$(LINUX_HEADERS) |
|---|
| 41 |
|
|---|
| 42 |
OBJS = p4b_smbus.o |
|---|
| 43 |
|
|---|
| 44 |
all: $(OBJS) |
|---|
| 45 |
|
|---|
| 46 |
install: all |
|---|
| 47 |
install -d /lib/modules/$(KERNELVERSION)/kernel/drivers/i2c/busses |
|---|
| 48 |
install -c p4b_smbus.o /lib/modules/$(KERNELVERSION)/kernel/drivers/i2c/busses |
|---|
| 49 |
# test ! -x /dev/watchdog || mknod -m 600 /dev/watchdog c 10 130 |
|---|
| 50 |
# test ! -x /dev/temperature || mknod -m 600 /dev/temperature c 10 131 |
|---|
| 51 |
|
|---|
| 52 |
inst: all |
|---|
| 53 |
rmmod p4b_smbus |
|---|
| 54 |
install -d /lib/modules/$(KERNELVERSION)/kernel/drivers/i2c/busses |
|---|
| 55 |
install -c p4b_smbus.o /lib/modules/$(KERNEL)/kernel/drivers/i2c/busses |
|---|
| 56 |
depmod -a |
|---|
| 57 |
# modprobe p4b_smbus |
|---|
| 58 |
|
|---|
| 59 |
clean: |
|---|
| 60 |
rm -f *.o *~ core |
|---|
| 61 |
|
|---|
| 62 |
cleandist: |
|---|
| 63 |
rm -f *.o *~ core |
|---|
| 64 |
|
|---|