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