1695cec664e5c45a03c6b0e12fcaa4ce07a4ca51
[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 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libpri.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libpri.so.1),)
96   CFLAGS+=-DZAPATA_PRI
97   ZAPPRI=-lpri
98 endif
99
100 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libmfcr2.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libmfcr2.so.1),)
101   CFLAGS+=-DZAPATA_R2
102   ZAPR2=-lmfcr2
103 endif
104
105 ALSA_SRC=chan_alsa.c
106
107 ifneq ($(wildcard alsa-monitor.h),)
108   CFLAGS+=-DALSA_MONITOR
109   ALSA_SRC+=alsa-monitor.h
110 endif
111
112 ifndef WITHOUT_ZAPTEL
113 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),)
114   ifeq (${OSARCH},NetBSD)
115     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/pkg/lib
116   endif
117   ifeq (${OSARCH},FreeBSD)
118     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
119   endif
120   CFLAGS+=-DIAX_TRUNKING
121   CHANNEL_LIBS+=chan_zap.so
122 endif
123 endif # WITHOUT_ZAPTEL
124
125 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
126   CHANNEL_LIBS+=chan_vpb.so
127   CFLAGS+=-DLINUX
128 endif
129
130 CFLAGS+=-DCRYPTO
131
132 ifneq ($(OSARCH),CYGWIN)
133 CFLAGS+=-fPIC
134 endif
135
136 CFLAGS+=#-DVOFRDUMPER
137
138 ZAPDIR=/usr/lib
139
140 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/nbs.h),)
141   CHANNEL_LIBS+=chan_nbs.so
142 endif
143
144 ifndef OPENH323DIR
145   OPENH323DIR=$(HOME)/openh323
146 endif
147
148 ifndef PWLIBDIR
149   PWLIBDIR=$(HOME)/pwlib
150 endif
151
152 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
153
154 all: depend $(CHANNEL_LIBS) 
155
156 clean:
157         rm -f *.so *.o .depend
158         rm -f busy.h ringtone.h gentone gentone-ulaw
159
160 %.so : %.o
161         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${LIBS}
162
163 ifneq ($(wildcard .depend),)
164   include .depend
165 endif
166
167 ifneq ($(wildcard h323/Makefile.ast),)
168   include h323/Makefile.ast
169 endif
170
171 ifneq ($(wildcard misdn/Makefile.ast),)
172   include misdn/Makefile.ast
173 endif
174
175 gentone: gentone.c
176         $(HOST_CC) -o gentone gentone.c -lm
177
178 gentone-ulaw: gentone-ulaw.c
179         $(HOST_CC) -o gentone-ulaw gentone-ulaw.c -lm
180
181 busy.h: gentone
182         ./gentone busy 480 620
183
184 ringtone.h: gentone
185         ./gentone ringtone 440 480
186
187 chan_oss.o: chan_oss.c busy.h ringtone.h
188
189 chan_alsa.o: chan_alsa.c busy.h ringtone.h
190
191 ifeq (${OSARCH},OpenBSD)
192 chan_oss.so: chan_oss.o
193         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
194 endif
195 ifeq (${OSARCH},NetBSD)
196 chan_oss.so: chan_oss.o
197         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
198 endif
199
200 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
201         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_iax2.o iax2-parser.o iax2-provision.o ${CYGSOLIB}
202
203 chan_zap.o: chan_zap.c
204         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
205
206 chan_zap.so: chan_zap.o
207         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
208
209 chan_sip.so: chan_sip.o
210         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}
211
212 chan_agent.so: chan_agent.o
213         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_agent.o ${CYGSOLIB} ${CYG_CHAN_AGENT}
214
215 chan_alsa.o: $(ALSA_SRC)
216
217 chan_alsa.so: chan_alsa.o
218         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
219
220 chan_nbs.so: chan_nbs.o
221         $(CC) $(SOLINK) -o $@ $< -lnbs
222
223 chan_vpb.o: chan_vpb.c
224         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
225
226 chan_vpb.so: chan_vpb.o
227          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
228
229 ifeq (${OSARCH},Linux)
230 chan_h323.so: chan_h323.o h323/libchanh323.a h323/Makefile.ast
231         $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) -lstdc++
232 else
233 chan_h323.so: chan_h323.o h323/libchanh323.a
234         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
235 endif
236
237 chan_misdn.so: chan_misdn.o chan_misdn_config.o misdn/chan_misdn_lib.a
238         $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN
239
240 chan_misdn.o: chan_misdn.c
241         $(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.2.1\" -c $< -o $@
242
243 #chan_modem.so : chan_modem.o
244 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
245
246 install: all
247         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
248         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
249
250 depend: .depend
251
252 .depend:
253         ../build_tools/mkdep $(CFLAGS) `ls *.c`
254
255 env:
256         env
257