add experimental mISDN channel driver (issue #4077)
[asterisk/asterisk.git] / channels / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Makefile for channel drivers
5 #
6 # Copyright (C) 1999-2005, Mark Spencer
7 #
8 # Mark Spencer <markster@digium.com>
9 #
10 # Edited By Belgarath <> Aug 28 2004
11 # Added bare bones ultrasparc-linux support.
12 #
13 # This program is free software, distributed under the terms of
14 # the GNU General Public License
15 #
16
17 CHANNEL_LIBS=chan_modem.so chan_sip.so \
18              chan_modem_aopen.so \
19              chan_modem_bestdata.so \
20              chan_agent.so chan_mgcp.so chan_iax2.so \
21              chan_local.so chan_skinny.so chan_features.so
22
23 ifeq ($(findstring BSD,${OSARCH}),BSD)
24  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
25 endif
26
27 ifeq (${OSARCH},OpenBSD)
28   PTLIB=-lpt_OpenBSD_x86_r
29   H323LIB=-lh323_OpenBSD_x86_r
30 endif
31
32 ifeq (${OSARCH},Linux)
33   PTLIB=-lpt_linux_x86_r
34   H323LIB=-lh323_linux_x86_r
35   CHANH323LIB=-ldl
36 endif
37
38 ifeq ($(PROC),sparc64)
39   PROC=ultrasparc
40   CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
41 endif
42
43 ifeq (${OSARCH},FreeBSD)
44   PTLIB=-lpt_FreeBSD_x86_r
45   H323LIB=-lh323_FreeBSD_x86_r
46   CHANH323LIB=-pthread
47 endif
48
49 ifeq (${OSARCH},NetBSD)
50   PTLIB=-lpt_NetBSD_x86_r
51   H323LIB=-lh323_NetBSD_x86_r
52 endif
53
54 ifneq (${OSARCH},Darwin)
55   ifneq (${OSARCH},SunOS)
56     CHANNEL_LIBS+=chan_oss.so chan_modem_i4l.so 
57   endif
58 endif
59
60 ifeq (${OSARCH},SunOS)
61   SOLINK+=-lrt
62 endif
63
64 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/ixjuser.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/ixjuser.h),)
65   CHANNEL_LIBS+=chan_phone.so
66 endif
67
68 ifneq ($(wildcard h323/libchanh323.a),)
69   CHANNEL_LIBS+=chan_h323.so
70 endif
71
72 ifneq ($(wildcard misdn/chan_misdn_lib.a),)
73   CHANNEL_LIBS+=chan_misdn.so
74 endif
75
76 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
77
78 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/alsa/asoundlib.h),)
79   CHANNEL_LIBS+=chan_alsa.so
80 endif
81
82 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libpri.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libpri.so.1),)
83   CFLAGS+=-DZAPATA_PRI
84   ZAPPRI=-lpri
85 endif
86
87 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libmfcr2.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libmfcr2.so.1),)
88   CFLAGS+=-DZAPATA_R2
89   ZAPR2=-lmfcr2
90 endif
91
92 ALSA_SRC=chan_alsa.c
93
94 ifneq ($(wildcard alsa-monitor.h),)
95   CFLAGS+=-DALSA_MONITOR
96   ALSA_SRC+=alsa-monitor.h
97 endif
98
99 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/pkg/include/zaptel.h),)
100   ifeq (${OSARCH},NetBSD)
101     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/pkg/lib
102   endif
103   ifeq (${OSARCH},FreeBSD)
104     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
105   endif
106   CFLAGS+=-DIAX_TRUNKING
107   CHANNEL_LIBS+=chan_zap.so
108 endif
109
110 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
111   CHANNEL_LIBS+=chan_vpb.so
112   CFLAGS+=-DLINUX
113 endif
114
115 CFLAGS+=-DCRYPTO
116 CFLAGS+=-fPIC
117
118 CFLAGS+=#-DVOFRDUMPER
119
120 ZAPDIR=/usr/lib
121
122 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/nbs.h),)
123   CHANNEL_LIBS+=chan_nbs.so
124 endif
125
126 ifndef OPENH323DIR
127   OPENH323DIR=$(HOME)/openh323
128 endif
129
130 ifndef PWLIBDIR
131   PWLIBDIR=$(HOME)/pwlib
132 endif
133
134 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
135
136 all: depend $(CHANNEL_LIBS) 
137
138 clean:
139         rm -f *.so *.o .depend
140         rm -f busy.h ringtone.h gentone gentone-ulaw
141
142 %.so : %.o
143         $(CC) $(SOLINK) -o $@ $<
144
145 ifneq ($(wildcard .depend),)
146   include .depend
147 endif
148
149 ifneq ($(wildcard h323/Makefile.ast),)
150   include h323/Makefile.ast
151 endif
152
153 ifneq ($(wildcard misdn/Makefile.ast),)
154   include misdn/Makefile.ast
155 endif
156
157 gentone: gentone.c
158         $(HOST_CC) -o gentone gentone.c -lm
159
160 gentone-ulaw: gentone-ulaw.c
161         $(HOST_CC) -o gentone-ulaw gentone-ulaw.c -lm
162
163 busy.h: gentone
164         ./gentone busy 480 620
165
166 ringtone.h: gentone
167         ./gentone ringtone 440 480
168
169 chan_oss.o: chan_oss.c busy.h ringtone.h
170
171 chan_alsa.o: chan_alsa.c busy.h ringtone.h
172
173 ifeq (${OSARCH},OpenBSD)
174 chan_oss.so: chan_oss.o
175         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
176 endif
177 ifeq (${OSARCH},NetBSD)
178 chan_oss.so: chan_oss.o
179         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
180 endif
181
182 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
183         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o iax2-provision.o
184
185 chan_zap.o: chan_zap.c
186         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
187
188 chan_zap.so: chan_zap.o
189         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
190
191 chan_sip.so: chan_sip.o
192         $(CC) $(SOLINK) -o $@ chan_sip.o
193
194 chan_alsa.o: $(ALSA_SRC)
195
196 chan_alsa.so: chan_alsa.o
197         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
198
199 chan_nbs.so: chan_nbs.o
200         $(CC) $(SOLINK) -o $@ $< -lnbs
201
202 chan_vpb.o: chan_vpb.c
203         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
204
205 chan_vpb.so: chan_vpb.o
206          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
207
208 ifeq (${OSARCH},Linux)
209 chan_h323.so: chan_h323.o h323/libchanh323.a h323/Makefile.ast
210         $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) -lstdc++
211 else
212 chan_h323.so: chan_h323.o h323/libchanh323.a
213         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
214 endif
215
216 chan_misdn.so: chan_misdn.o chan_misdn_config.o misdn/chan_misdn_lib.a
217         $(CC) -shared -Xlinker -x -o $@ $^ $(MISDNUSER)/i4lnet/libisdnnet.a $(MISDNUSER)/lib/libmISDN.a 
218
219 chan_misdn_config.o: chan_misdn_config.c
220         $(CC) $(CFLAGS) -c chan_misdn_config.c
221
222
223 #chan_modem.so : chan_modem.o
224 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
225
226 install: all
227         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
228         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
229
230 depend: .depend
231
232 .depend:
233         ../build_tools/mkdep $(CFLAGS) `ls *.c`
234
235 env:
236         env
237