File: Makefile

package info (click to toggle)
sl-modem 2.9.11~20110321-11
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 3,448 kB
  • ctags: 2,972
  • sloc: ansic: 11,002; sh: 809; makefile: 232; python: 40; perl: 11
file content (165 lines) | stat: -rw-r--r-- 4,316 bytes parent folder | download | duplicates (2)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
###########################################################################
#
#
#       Makefile  --  modem kernel drivers Makefile.
#
#       Copyright(c) 2003, Smart Link Ltd. (www.smlink.com)
#	All rights reserved.
#
#       Author: Sasha K (sashak@smlink.com)
#
#
###########################################################################
#
###########################################################################

#KBUILD_VERBOSE=1
#export KBUILD_VERBOSE

KERNEL_DIR:=/lib/modules/$(shell uname -r)/build
SUBLEVEL:=$(shell echo $(KERNEL_DIR) | cut -d. -f3 | cut -d. -f1 | cut -d-  -f1)
# slusb support ends at 2.6.24

ifndef USB
AGE:=$(shell if [ "$(SUBLEVEL)" -gt 24 ] ;then echo NEW;fi)
endif

FOUND_CLASS_SIMPLE := $(shell grep -q 'class_simple_device_add' ${KERNEL_DIR}/include/linux/device.h 2> /dev/null && echo -DFOUND_CLASS_SIMPLE)

EXTRA_CFLAGS = -I$(obj) -I$(obj)/../modem $(FOUND_CLASS_SIMPLE)

ifdef CONFIG_X86_32
ARCH64:=0
else
ARCH64:=$(shell uname -m | sed -e '/amd64/s//x86_64/' | grep -c x86_64)
endif

ifeq ($(ARCH64), 0)
obj-m:= slamr.o 
endif

# AGE:=test
ifneq ($(AGE), NEW)
obj-m:= $(obj-m) slusb.o 
endif

slamr-objs:= amrmo_init.o sysdep_amr.o amrlibs.o
slusb-objs:= st7554.o

ifndef KERNELRELEASE
ifndef KERNEL_VER


KVERS?=$(shell ./kernel-ver)



all install uninstall: kernel-ver
	$(MAKE) $@ KERNEL_VER=$(KVERS)
#	$(MAKE) $@ KERNEL_VER=$(shell ./kernel-ver)

install: install-devices
uninstall: remove-devices

kernel-ver::
	@echo "doing kernel-ver::"
	$(CC) -I$(KERNEL_DIR)/include -o $@ $@.c

dep:
clean:
	$(RM) kernel-ver $(obj-m) $(obj-m:.o=.ko) *st7554.o amrmo_init.o sysdep_amr.o *.mod.* .*.cmd *~ slusb.*
	$(RM) -r .tmp_versions

install-devices:
	mkdir -p ${DESTDIR}/dev
	$(foreach minor,0 1 2 3, \
	    mknod -m 600 ${DESTDIR}/dev/slamr$(minor) c 242 $(minor) ; ) echo -n
ifneq ($(AGE), NEW)
	$(foreach minor,0 1 2 3, \
	    mknod -m 600 ${DESTDIR}/dev/slusb$(minor) c 243 $(minor) ; ) echo -n
endif

remove-devices:
	$(foreach minor,0 1 2 3, \
	    $(RM) ${DESTDIR}/dev/slamr$(minor) ; ) echo -n
	$(foreach minor,0 1 2 3, \
	    $(RM) ${DESTDIR}/dev/slusb$(minor) ; ) echo -n

else
ifeq ($(shell grep 'UTS.*"\(2\.6\|3\)' $(KERNEL_DIR)/include/generated/utsrelease.h $(KERNEL_DIR)/include/linux/utsrelease.h $(KERNEL_DIR)/include/linux/version.h 2>/dev/null),)

slusb-objs:= old_st7554.o
obj:=.
module-dir ?= ${DESTDIR}/lib/modules/$(KERNEL_VER)/misc

CFLAGS:= -Wall -pipe -O3 -fomit-frame-pointer -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB `test -f $(KERNEL_DIR)/include/linux/modversions.h && echo -DMODVERSIONS --include $(KERNEL_DIR)/include/linux/modversions.h -I$(KERNEL_DIR)/include` $(FOUND_CLASS_SIMPLE)

all: $(obj-m)

slamr.o: $(slamr-objs)
slusb.o: $(slusb-objs)
slamr.o slusb.o:
	$(LD) -r -o $@ $^

install: uninstall-old
ifeq ($(ARCH64), 0)
	install -D -m 644 slamr.o $(module-dir)/slamr.o
endif
	install -D -m 644 slusb.o $(module-dir)/slusb.o
	cp /etc/modules.conf /etc/modules.conf.slamr && \
	    echo 'alias char-major-242 slamr' >> /etc/modules.conf && \
	    echo 'alias char-major-243 slusb' >> /etc/modules.conf 
	/sbin/depmod -a
uninstall:
	/sbin/modprobe -r slamr slusb
	cp /etc/modules.conf /etc/modules.conf.slamr && \
	   egrep -ve 'alias char-major-242 slamr|alias char-major-243 slusb' /etc/modules.conf.slamr > /etc/modules.conf
	$(RM) $(module-dir)/slamr.o
	$(RM) $(module-dir)/slusb.o
	/sbin/depmod -a
uninstall-old:
	$(RM) $(module-dir)/slmdm.o \
              $(module-dir)/slfax.o \
              $(module-dir)/slusb.o \
              $(module-dir)/slamrmo.o \
              $(module-dir)/slmodem.o  # remove old 2.7,2.8 version

%.o: %.c
	@echo "	doing %.o: %.c"
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -o $@ -c $<

else

module-dir:=${DESTDIR}/lib/modules/$(KERNEL_VER)/extra

all:
	@echo "	obj-m=$(obj-m)"
	@echo "	slamr-objs=$(slamr-objs)" 
	$(MAKE) modules -C $(KERNEL_DIR) SUBDIRS=$(shell pwd)
	@echo "	finished all:"

install:
ifeq ($(ARCH64), 0)
	install -D -m 644 slamr.ko $(module-dir)/slamr.ko
endif
ifneq ($(AGE), NEW)
	install -D -m 644 slusb.ko $(module-dir)/slusb.ko
endif
	/sbin/depmod -a

uninstall:
ifeq ($(ARCH64), 0)
	modprobe -r slamr ; echo -n
endif
	modprobe -r slusb ; echo -n
	$(RM) $(module-dir)/slamr.ko
	$(RM) $(module-dir)/slusb.ko
	/sbin/depmod -a
endif

endif
endif

$(obj)/amrlibs.o:
	echo "$@ done"