summaryrefslogtreecommitdiff
path: root/doc/plustek/Makefile.kernel26
blob: 43a71adb38313fa5a56600aa919253871b0cb97f (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Makefile for the plustek scanner driver (kernel-module)
#
###############################################################################

#
# retrieve the version numbers
#
ifeq ($(LINUXVERSION),)
 LINUXVERSION = $(shell uname -r)
endif
LINUXRELEASE = $(shell uname -r | cut -d'.' -f3)

ifeq ($(VERSIONSTR),)
 ifeq ($(SUBDIRS),)
  VERSIONSTR = $(shell grep "define BACKEND_VERSION" $(M)/plustek_pp.c | cut -b25-50 )
 else
  VERSIONSTR = $(shell grep "define BACKEND_VERSION" $(SUBDIRS)/plustek_pp.c | cut -b25-50 )
 endif
endif

#
# extra flags
#
EXTRA_CFLAGS += -D_PTDRV_VERSTR=\"$(VERSIONSTR)\"

ifeq ($(DEBUG),y)
	EXTRA_CFLAGS += -DDEBUG
endif

#
# the module name
#
TARGET := pt_drv
MODULE := $(TARGET).ko

#
# our files...
#
NAMES := dac detect genericio image map misc models io procfs
NAMES := $(NAMES) motor p9636 ptdrv scale tpa p48xx p12 p12ccd
NAMES := $(addprefix plustek-pp_, $(NAMES))
OBJS  := $(addsuffix .o, $(NAMES))

#
# now the kernel magic
#
ifneq ($(KERNELRELEASE),)
obj-m := $(TARGET).o

$(TARGET)-objs := $(OBJS)

else
KDIR := /lib/modules/$(shell uname -r)/build
PWD  := $(shell pwd)

default:
	$(MAKE) -C $(KDIR) M=$(PWD) modules
endif

#
# the installation stuff
#
group = "root"
mode  = "644"
INST_DIR = /lib/modules/$(LINUXVERSION)/kernel/drivers/parport

#
# copy the driver to the modules directory
#
install:
	mkdir -p $(INST_DIR)
	install -c -m $(mode) $(MODULE) $(INST_DIR)
	/sbin/depmod -a

#
#
#
uninstall:
	rm -f $(INST_DIR)/$(MODULE)

#
# use modprobe to load the driver, remember to set the
# parameter in /etc/conf.modules (see INSTALL for more details)
#
load:   $(INST_DIR)/$(MODULE)
# invoke modprobe with all arguments we got
	/sbin/modprobe $(TARGET) || exit 1

# Remove stale nodes and replace them, then give gid and perms
	rm -f /dev/$(TARGET)*

# when using the devfs support, we check the /dev/scanner entries
# and only create links to the devfs nodes
# at least we create one link
	@if [ -e /dev/scanner/$(TARGET)* ]; then 				\
		ln -s /dev/scanner/$(TARGET)0 /dev/$(TARGET);		\
		for name in `ls /dev/scanner | grep $(TARGET)`; do	\
			ln -s /dev/scanner/$$name /dev/$$name ;     	\
		done												\
	else                      								\
		mknod /dev/$(TARGET) c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0;  \
		mknod /dev/$(TARGET)0 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0;	\
		mknod /dev/$(TARGET)1 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 1;	\
		mknod /dev/$(TARGET)2 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 2; \
		mknod /dev/$(TARGET)3 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 3;	\
																							\
		chgrp $(group) /dev/$(TARGET)*;	\
		chmod $(mode)  /dev/$(TARGET)*;	\
	fi

#
# unload the driver
#
unload:
	/sbin/modprobe -r $(TARGET) || exit 1

# Remove stale nodes
	rm -f /dev/$(TARGET)*

#
# cleanup the show
#
clean:
	@-rm -f *.o .depend depend dep $(MODULE) $(TARGET).o $(TARGET).mod.c .*.cmd