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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
#
# Makefile for tormenta/carrier driver and utilities
#
BASEADDR=0xd0000
#
# Okay, the people at RedHat have to break everything they can possibly even attempt to.
# So, we have to look in /usr/src/linux-2.4/include for header files given their brain dead
# crappy installation. (Mind you, I'm a RedHat user myself, so I suppose I'm just as
# stupid as they are). Everyone else who is mildly sane of course links /usr/include/linux
# to their working kernel source directory, the way God himself does, of course
# (assuming He's running Linux -- which we all know He must).
#
HOSTCC=gcc
KINCLUDES=$(shell if [ -d /usr/src/linux-2.4/include ]; then echo /usr/src/linux-2.4/include ; else echo /usr/src/linux/include ; fi)
CFLAGS+=-I. -O4 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
CFLAGS+=$(shell if uname -m | grep -q x86_64; then echo "-m64"; fi)
LCFLAGS=-fPIC $(CFLAGS) -DBUILDING_TONEZONE
KFLAGS+=-I/usr/src/linux-2.4/include -O6
KFLAGS+=-DMODULE -D__KERNEL__ -DEXPORT_SYMTAB -I/usr/src/linux/drivers/net \
-Wall -I. -Wstrict-prototypes -fomit-frame-pointer -I/usr/src/linux/drivers/net/wan -I /usr/src/linux/include -I/usr/src/linux/include/net
KFLAGS+=$(shell [ -f $(KINCLUDES)/linux/modversions.h ] && echo "-DMODVERSIONS -include $(KINCLUDES)/linux/modversions.h")
KFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-msoft-float -fsigned-char"; fi)
#
# Features are now configured in zconfig.h
#
#
KFLAGS+=-DSTANDALONE_ZAPATA
CFLAGS+=-DSTANDALONE_ZAPATA
INSTALL_PREFIX=
BUILDVER=$(shell if uname -r | grep -q ^2.6; then echo "linux26"; else echo "linux24"; fi)
MODCONF=$(shell if [ -d $(INSTALL_PREFIX)/etc/modprobe.d ]; then echo "$(INSTALL_PREFIX)/etc/modprobe.d/zaptel"; elif [ -d $(INSTALL_PREFIX)/etc/modutils ]; then echo "$(INSTALL_PREFIX)/etc/modutils/zaptel"; elif [ -f $(INSTALL_PREFIX)/etc/modprobe.conf ]; then echo "$(INSTALL_PREFIX)/etc/modprobe.conf"; elif [ -f $(INSTALL_PREFIX)/etc/modules.conf ]; then echo "$(INSTALL_PREFIX)/etc/modules.conf"; else echo $(INSTALL_PREFIX)/etc/conf.modules ; fi)
ifeq (${BUILDVER},linux24)
#We only support DEVFS in linux 2.4 kernels, since its considered obsolete post 2.4
DEVFS=$(shell ps ax | grep -v grep | grep devfsd)
endif
TZOBJS=zonedata.lo tonezone.lo
LIBTONEZONE=libtonezone.so.1.0
MODULES=zaptel tor2 torisa wcusb wcfxo wcfxs \
ztdynamic ztd-eth wct1xxp wct4xxp # ztdummy
#MODULES+=wcfxsusb
MODULESO=$(shell for x in $(MODULES); do echo "$$x.o "; done )
MODULESKO=$(shell for x in $(MODULES); do echo "$$x.ko "; done )
ZTTOOL=$(shell if [ -f /usr/include/newt.h ]; then echo zttool; fi)
BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest
#PRIMARY=wcfxsusb
PRIMARY=torisa
#PRIMARY=wcfxo
PWD=$(shell pwd)
all: $(BUILDVER)
linux24: $(MODULESO) $(BINS)
linux26:
linux26: prereq $(BINS)
@if ! [ -d /usr/src/linux-2.6 ]; then echo "Link /usr/src/linux-2.6 to your kernel sources first!"; exit 1 ; fi
make -C /usr/src/linux-2.6 SUBDIRS=$(PWD) modules
obj-m := $(MODULESO) ztdummy.o
#ifneq ($(TOPDIR),)
#include $(TOPDIR)/Rules.make
#endif
MOD_DESTDIR := zaptel
devel: tor2ee
tests: patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest
tor2.o: tor2.c tor2-hw.h tor.h tor2fw.h zaptel.h
$(HOSTCC) $(KFLAGS) -c tor2.c
zaptel.o: zaptel.c zaptel.h digits.h arith.h sec.h mec.h sec-2.h mec2.h mec3.h
$(HOSTCC) $(KFLAGS) -c zaptel.c
torisa.o: torisa.c zaptel.h torisa.h
$(HOSTCC) $(KFLAGS) -c torisa.c
wcusb.o: wcusb.c wcusb.h zaptel.h
$(HOSTCC) $(KFLAGS) -c wcusb.c
wcfxsusb.o: wcfxsusb.c wcfxsusb.h zaptel.h
$(HOSTCC) $(KFLAGS) -c wcfxsusb.c
wcfxo.o: wcfxo.c zaptel.h
$(HOSTCC) $(KFLAGS) -c wcfxo.c
wct1xxp.o:wct1xxp.c zaptel.h
$(HOSTCC) $(KFLAGS) -c wct1xxp.c
wct4xxp.o:wct4xxp.c zaptel.h
$(HOSTCC) $(KFLAGS) -c wct4xxp.c
wcfxs.o:wcfxs.c zaptel.h
$(HOSTCC) $(KFLAGS) -c wcfxs.c
wcs3200p.o:wcs3200p.c zaptel.h
$(HOSTCC) $(KFLAGS) -c wcs3200p.c
ztdummy.o:ztdummy.c ztdummy.h
$(HOSTCC) $(KFLAGS) -c ztdummy.c
ztdynamic.o: ztdynamic.c zaptel.h
$(HOSTCC) $(KFLAGS) -c ztdynamic.c
ztd-eth.o: ztd-eth.c zaptel.h
$(HOSTCC) $(KFLAGS) -c ztd-eth.c
tor2ee.o: tor2-hw.h
tor2ee: tor2ee.o
$(CC) $(CFLAGS) -o tor2ee tor2ee.o -lpci
zonedata.lo: zonedata.c
$(CC) -c $(LCFLAGS) -o zonedata.lo zonedata.c
tonezone.lo: tonezone.c
$(CC) -c $(LCFLAGS) -o tonezone.lo tonezone.c
torisatool: torisatool.o
$(CC) -o torisatool torisatool.o
tones.h: gendigits
./gendigits
tor2fw.h: makefw tormenta2.rbt
./makefw tormenta2.rbt tor2fw > tor2fw.h
gendigits: gendigits.o
$(CC) -o gendigits gendigits.o -lm
zaptel.c: tones.h
prereq: tones.h tor2fw.h
zttool.o: zttool.c zaptel.h
ztprovision.o: ztprovision.c zaptel.h
ztmonitor.o: ztmonitor.c zaptel.h
ztspeed.o: ztspeed.c
$(CC) -c ztspeed.c
zttool: zttool.o
$(CC) -o zttool zttool.o -lnewt
ztprovision: ztprovision.o
$(CC) -o ztprovision ztprovision.o -lnewt
ztmonitor: ztmonitor.o
$(CC) -o ztmonitor ztmonitor.o
ztcat: ztcat.o
$(CC) -o ztcat ztcat.o -ltonezone
ztspeed: ztspeed.o
$(CC) -o ztspeed ztspeed.o
sethdlc-new: sethdlc-new.o
$(CC) -o sethdlc-new sethdlc-new.o
sethdlc-new.o: sethdlc-new.c
$(CC) -c $(CFLAGS) -I$(KINCLUDES) sethdlc-new.c
libtonezone.a: $(TZOBJS)
ar rcs libtonezone.a $(TZOBJS)
$(LIBTONEZONE): $(TZOBJS)
$(CC) -shared -Wl,-soname,libtonezone.so.1 -lm -o $@ $(TZOBJS)
/sbin/ldconfig -n .
ln -sf libtonezone.so.1 libtonezone.so
ztcfg.c: ztcfg.h
ztcfg-shared: ztcfg.o $(LIBTONEZONE)
$(CC) -o ztcfg-shared ztcfg.o -lm -L. -ltonezone
ztcfg: ztcfg.o libtonezone.a
$(CC) -o ztcfg ztcfg.o -lm -L. libtonezone.a
ztcfg-dude: ztcfg-dude.o mknotch.o complex.o $(LIBTONEZONE)
$(CC) -o ztcfg ztcfg-dude.o mknotch.o complex.o -lm -L. -ltonezone
mknotch.o: mknotch.cc
$(CC) -c mknotch.cc
complex.o: complex.cc
$(CC) -c complex.cc
usbfxstest.o: usbfxstest.c
$(CC) -g -c usbfxstest.c
usbfxstest: usbfxstest.o
$(CC) -o usbfxstest usbfxstest.o -lzap
fxstest: fxstest.o
$(CC) -o fxstest fxstest.o -ltonezone
fxsdump: fxsdump.o
$(CC) -o fxsdump fxsdump.o -lm
devices:
ifeq ($(DEVFS),)
mkdir -p $(INSTALL_PREFIX)/dev/zap
rm -f $(INSTALL_PREFIX)/dev/zap/ctl
rm -f $(INSTALL_PREFIX)/dev/zap/channel
rm -f $(INSTALL_PREFIX)/dev/zap/pseudo
rm -f $(INSTALL_PREFIX)/dev/zap/timer
rm -f $(INSTALL_PREFIX)/dev/zap/253
rm -f $(INSTALL_PREFIX)/dev/zap/252
rm -f $(INSTALL_PREFIX)/dev/zap/251
rm -f $(INSTALL_PREFIX)/dev/zap/250
mknod $(INSTALL_PREFIX)/dev/zap/ctl c 196 0
mknod $(INSTALL_PREFIX)/dev/zap/timer c 196 253
mknod $(INSTALL_PREFIX)/dev/zap/channel c 196 254
mknod $(INSTALL_PREFIX)/dev/zap/pseudo c 196 255
N=1; \
while [ $$N -lt 250 ]; do \
rm -f $(INSTALL_PREFIX)/dev/zap/$$N; \
mknod $(INSTALL_PREFIX)/dev/zap/$$N c 196 $$N; \
N=$$[$$N+1]; \
done
else
@echo "**** devfs detected -- not making device nodes"
endif
install: all devices $(LIBTONEZONE)
mkdir -p $(INSTALL_PREFIX)/sbin
install -m 755 ztcfg $(INSTALL_PREFIX)/sbin
if [ -f sethdlc-new ]; then \
install -m 755 sethdlc-new $(INSTALL_PREFIX)/sbin/sethdlc; \
elif [ -f sethdlc ]; then \
install -m 755 sethdlc $(INSTALL_PREFIX)/sbin ; \
fi
if [ -f zttool ]; then install -m 755 zttool $(INSTALL_PREFIX)/sbin; fi
mkdir -p $(INSTALL_PREFIX)/lib/modules/`uname -r`/misc
if [ -f zaptel.ko ]; then \
for x in $(MODULESKO) ztdummy.ko; do \
install -m 644 $$x $(INSTALL_PREFIX)/lib/modules/`uname -r`/misc ; \
done; \
if ! [ -f wcfxsusb.ko ]; then \
rm -f $(INSTALL_PREFIX)/lib/modules/`uname -r`/misc/wcfxsusb.o; \
fi; \
else \
for x in $(MODULESO); do \
install -m 644 $$x $(INSTALL_PREFIX)/lib/modules/`uname -r`/misc ; \
done; \
if ! [ -f wcfxsusb.o ]; then \
rm -f $(INSTALL_PREFIX)/lib/modules/`uname -r`/misc/wcfxsusb.ko; \
fi; \
fi
mkdir -p $(INSTALL_PREFIX)/usr/lib
install -m 755 $(LIBTONEZONE) $(INSTALL_PREFIX)/usr/lib
mkdir -p $(INSTALL_PREFIX)/usr/include/linux
install -m 644 zaptel.h $(INSTALL_PREFIX)/usr/include/linux
install -m 644 torisa.h $(INSTALL_PREFIX)/usr/include/linux
install -m 644 tonezone.h $(INSTALL_PREFIX)/usr/include
( cd $(INSTALL_PREFIX)/usr/lib ; rm -f libtonezone.so ; ln -sf $(LIBTONEZONE) libtonezone.so )
/sbin/ldconfig
if [ -f $(MODCONF) ]; then mv -f $(MODCONF) $(MODCONF).bak ; fi
cat $(MODCONF).bak | grep -v "alias char-major-250" | \
grep -v "post-install torisa /sbin/ztcfg" | \
grep -v "post-install wcfxsusb /sbin/ztcfg" | \
grep -v "post-install wcfxs /sbin/ztcfg" > $(MODCONF) || true
if ! grep "options torisa" $(MODCONF); then \
echo "options torisa base=$(BASEADDR)" >> $(MODCONF); \
fi
if ! grep "alias char-major-196" $(MODCONF); then \
echo "alias char-major-196 $(PRIMARY)" >> $(MODCONF); \
fi
for x in $(MODULES); do \
if ! grep "post-install $$x" $(MODCONF); then \
if ! grep "install $$x " $(MODCONF); then \
if [ "$$x" != "zaptel" ] ; then \
if [ -f zaptel.ko ]; then echo "install $$x /sbin/modprobe --ignore-install $$x && /sbin/ztcfg" >> $(MODCONF); \
else echo "post-install $$x /sbin/ztcfg" >> $(MODCONF); \
fi; \
fi; \
fi; \
fi; \
done
if [ -d /etc/modutils ]; then \
/sbin/update-modules ; \
fi
-/sbin/depmod -a
[ -f $(INSTALL_PREFIX)/etc/zaptel.conf ] || install -m 644 zaptel.conf.sample $(INSTALL_PREFIX)/etc/zaptel.conf
config:
if [ -d $(INSTALL_PREFIX)/etc/rc.d/init.d ]; then \
install -m 755 zaptel.init $(INSTALL_PREFIX)/etc/rc.d/init.d/zaptel; \
chkconfig --add zaptel; \
elif [ -d $(INSTALL_PREFIX)/etc/init.d ]; then \
install -m 755 zaptel.init $(INSTALL_PREFIX)/etc/init.d/zaptel; \
fi
if [ ! -f /etc/sysconfig/zaptel ]; then \
install -m 644 zaptel.sysconfig $(INSTALL_PREFIX)/etc/sysconfig/zaptel; \
fi
if [ -d /etc/sysconfig/network-scripts ]; then \
install -m 755 ifup-hdlc $(INSTALL_PREFIX)/etc/sysconfig/network-scripts/ifup-hdlc; \
fi
clean:
rm -f torisatool makefw tor2fw.h
rm -f zttool
rm -f *.o ztcfg tzdriver sethdlc sethdlc-new
rm -f $(TZOBJS) $(LIBTONEZONE) *.lo
rm -f *.ko *.mod.c .*o.cmd
rm -f gendigits tones.h
rm -f libtonezone*
rm -f tor2ee
rm -f core
|