allow forcing the build to exclude PRI support using WITHOUT_PRI, similar to
[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_sip.so chan_agent.so chan_mgcp.so chan_iax2.so chan_local.so chan_skinny.so chan_features.so
18
19 ifneq (${OSARCH},CYGWIN)
20 # if you really, really want to use these drivers, uncomment the line below
21 #CHANNEL_LIBS+=chan_modem.so chan_modem_aopen.so chan_modem_bestdata.so
22 endif
23
24 ifeq ($(findstring BSD,${OSARCH}),BSD)
25  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
26 endif
27
28 ifeq (${OSARCH},OpenBSD)
29   PTLIB=-lpt_OpenBSD_x86_r
30   H323LIB=-lh323_OpenBSD_x86_r
31 endif
32
33 ifeq (${OSARCH},Linux)
34   PTLIB=-lpt_linux_x86_r
35   H323LIB=-lh323_linux_x86_r
36   CHANH323LIB=-ldl
37 endif
38
39 ifeq (${OSARCH},CYGWIN)
40 CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
41 CYGSOLIB=-L.. -L. -L../res -lasterisk.dll -lres_features.so
42 CYG_CHAN_AGENT=-lres_monitor.so
43 endif
44
45 ifeq ($(PROC),sparc64)
46   PROC=ultrasparc
47   CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
48 endif
49
50 ifeq (${OSARCH},FreeBSD)
51   PTLIB=-lpt_FreeBSD_x86_r
52   H323LIB=-lh323_FreeBSD_x86_r
53   CHANH323LIB=-pthread
54 endif
55
56 ifeq (${OSARCH},NetBSD)
57   PTLIB=-lpt_NetBSD_x86_r
58   H323LIB=-lh323_NetBSD_x86_r
59 endif
60
61 ifneq (${OSARCH},Darwin)
62   ifneq (${OSARCH},SunOS)
63     ifneq (${OSARCH},CYGWIN)
64 # the ISDN4Linux channel driver is probably broken on all modern kernels,
65 # but if you wish to try to use it, uncomment the line below
66 #      CHANNEL_LIBS+=chan_modem_i4l.so 
67        CHANNEL_LIBS+=chan_oss.so
68     endif
69   endif
70 endif
71
72 ifeq (${OSARCH},SunOS)
73   SOLINK+=-lrt
74 endif
75
76 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/ixjuser.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/ixjuser.h),)
77   CHANNEL_LIBS+=chan_phone.so
78 endif
79
80 ifneq ($(wildcard h323/libchanh323.a),)
81   CHANNEL_LIBS+=chan_h323.so
82 endif
83
84 ifneq ($(wildcard misdn/chan_misdn_lib.a),)
85   CHANNEL_LIBS+=chan_misdn.so
86   CFLAGS+=-Imisdn 
87 endif
88
89 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
90
91 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/alsa/asoundlib.h),)
92   CHANNEL_LIBS+=chan_alsa.so
93 endif
94
95 ifndef WITHOUT_PRI
96 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libpri.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libpri.so.1),)
97   CFLAGS+=-DZAPATA_PRI
98   ZAPPRI=-lpri
99 endif
100 endif # WITHOUT_PRI
101
102 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libmfcr2.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libmfcr2.so.1),)
103   CFLAGS+=-DZAPATA_R2
104   ZAPR2=-lmfcr2
105 endif
106
107 ALSA_SRC=chan_alsa.c
108
109 ifneq ($(wildcard alsa-monitor.h),)
110   CFLAGS+=-DALSA_MONITOR
111   ALSA_SRC+=alsa-monitor.h
112 endif
113
114 ifndef WITHOUT_ZAPTEL
115 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),)
116   ifeq (${OSARCH},NetBSD)
117     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/pkg/lib
118   endif
119   ifeq (${OSARCH},FreeBSD)
120     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
121   endif
122   CFLAGS+=-DIAX_TRUNKING
123   CHANNEL_LIBS+=chan_zap.so
124 endif
125 endif # WITHOUT_ZAPTEL
126
127 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
128   CHANNEL_LIBS+=chan_vpb.so
129   CFLAGS+=-DLINUX
130 endif
131
132 CFLAGS+=-DCRYPTO
133
134 ifneq ($(OSARCH),CYGWIN)
135 CFLAGS+=-fPIC
136 endif
137
138 CFLAGS+=#-DVOFRDUMPER
139
140 ZAPDIR=/usr/lib
141
142 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/nbs.h),)
143   CHANNEL_LIBS+=chan_nbs.so
144 endif
145
146 ifndef OPENH323DIR
147   OPENH323DIR=$(HOME)/openh323
148 endif
149
150 ifndef PWLIBDIR
151   PWLIBDIR=$(HOME)/pwlib
152 endif
153
154 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
155
156 all: depend $(CHANNEL_LIBS) 
157
158 clean:
159         rm -f *.so *.o .depend
160         rm -f busy.h ringtone.h gentone gentone-ulaw
161
162 %.so : %.o
163         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${LIBS}
164
165 ifneq ($(wildcard .depend),)
166   include .depend
167 endif
168
169 ifneq ($(wildcard h323/Makefile.ast),)
170   include h323/Makefile.ast
171 endif
172
173 ifneq ($(wildcard misdn/Makefile.ast),)
174   include misdn/Makefile.ast
175 endif
176
177 gentone: gentone.c
178         $(HOST_CC) -o gentone gentone.c -lm
179
180 gentone-ulaw: gentone-ulaw.c
181         $(HOST_CC) -o gentone-ulaw gentone-ulaw.c -lm
182
183 busy.h: gentone
184         ./gentone busy 480 620
185
186 ringtone.h: gentone
187         ./gentone ringtone 440 480
188
189 chan_oss.o: chan_oss.c busy.h ringtone.h
190
191 chan_alsa.o: chan_alsa.c busy.h ringtone.h
192
193 ifeq (${OSARCH},OpenBSD)
194 chan_oss.so: chan_oss.o
195         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
196 endif
197 ifeq (${OSARCH},NetBSD)
198 chan_oss.so: chan_oss.o
199         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
200 endif
201
202 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
203         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_iax2.o iax2-parser.o iax2-provision.o ${CYGSOLIB}
204
205 chan_zap.o: chan_zap.c
206         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
207
208 chan_zap.so: chan_zap.o
209         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
210
211 chan_sip.so: chan_sip.o
212         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}
213
214 chan_agent.so: chan_agent.o
215         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_agent.o ${CYGSOLIB} ${CYG_CHAN_AGENT}
216
217 chan_alsa.o: $(ALSA_SRC)
218
219 chan_alsa.so: chan_alsa.o
220         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
221
222 chan_nbs.so: chan_nbs.o
223         $(CC) $(SOLINK) -o $@ $< -lnbs
224
225 chan_vpb.o: chan_vpb.c
226         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
227
228 chan_vpb.so: chan_vpb.o
229          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
230
231 ifeq (${OSARCH},Linux)
232 chan_h323.so: chan_h323.o h323/libchanh323.a h323/Makefile.ast
233         $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) -lstdc++
234 else
235 chan_h323.so: chan_h323.o h323/libchanh323.a
236         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
237 endif
238
239 chan_misdn.so: chan_misdn.o chan_misdn_config.o misdn/chan_misdn_lib.a
240         $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN
241
242 chan_misdn.o: chan_misdn.c
243         $(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.2.1\" -c $< -o $@
244
245 #chan_modem.so : chan_modem.o
246 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
247
248 install: all
249         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
250         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
251
252 depend: .depend
253
254 .depend:
255         ../build_tools/mkdep $(CFLAGS) `ls *.c`
256
257 env:
258         env
259