d9b6709993bc46687f9c9be3efbdffde6432b943
[asterisk/asterisk.git] / channels / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Makefile for Channel backends (dynamically loaded)
5 #
6 # Copyright (C) 1999, Mark Spencer
7 #
8 # Mark Spencer <markster@linux-support.net>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 OSARCH=$(shell uname -s)
15
16 USE_MYSQL_FRIENDS=0
17 USE_SIP_MYSQL_FRIENDS=0
18
19 CHANNEL_LIBS=chan_modem.so chan_sip.so \
20              chan_modem_aopen.so \
21              chan_modem_bestdata.so chan_modem_i4l.so \
22              chan_agent.so chan_mgcp.so chan_iax2.so \
23              chan_local.so chan_skinny.so
24
25 #
26 # If you really want IAX1 uncomment the following, but it is
27 # unmaintained
28 #
29 #CHANNEL_LIBS+=chan_iax.so
30
31 #
32 # If you really want VoFR you can have it :-P
33 #
34 #CHANNEL_LIBS+=chan_vofr
35
36 ifeq (${OSARCH},OpenBSD)
37 MYSQLLIB=-L/usr/local/lib/mysql -lmysqlclient
38 CFLAGS+=-I/usr/local/include
39 PTLIB=-lpt_OpenBSD_x86_r
40 H323LIB=-lh323_OpenBSD_x86_r
41 CHANH323LIB=-L/usr/local/lib
42 endif
43 ifeq (${OSARCH},Linux)
44 MYSQLLIB=-L/usr/lib/mysql -lmysqlclient
45 PTLIB=-lpt_linux_x86_r
46 H323LIB=-lh323_linux_x86_r
47 CHANH323LIB=-ldl
48 endif
49 ifeq (${OSARCH},FreeBSD)
50 PTLIB=-lpt_FreeBSD_x86_r
51 H323LIB=-lh323_FreeBSD_x86_r
52 CHANH323LIB=-pthread
53 SOLINK+=-L/usr/local/lib
54 endif
55 ifeq (${OSARCH},NetBSD)
56 PTLIB=-lpt_NetBSD_x86_r
57 H323LIB=-lh323_NetBSD_x86_r
58 SOLINK+=-L/usr/local/lib
59 endif
60 ifneq (${OSARCH},Darwin)
61 CHANNEL_LIBS+=chan_oss.so
62 endif
63
64 CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
65 CHANNEL_LIBS+=$(shell [ -f /usr/local/include/ixjuser.h ] && echo chan_phone.so)
66 CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
67
68 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
69 CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
70 CHANNEL_LIBS+=$(shell [ -f /usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
71 CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
72 CFLAGS+=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
73 CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
74 ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
75 ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
76 CFLAGS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
77 CFLAGS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
78 CHANNEL_LIBS+=$(shell [ -f /usr/include/vpbapi.h ] && echo "chan_vpb.so" )
79 CFLAGS+=$(shell [ -f /usr/include/vpbapi.h ] && echo " -DLINUX")
80
81 ALSA_SRC=chan_alsa.c
82 ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
83
84 CFLAGS+=-DCRYPTO
85 CFLAGS+=-fPIC
86
87 ifeq ($(USE_MYSQL_FRIENDS),1)
88 CFLAGS+=-DMYSQL_FRIENDS
89 USE_SIP_MYSQL_FRIENDS=1
90 endif
91 ifeq ($(USE_SIP_MYSQL_FRIENDS),1)
92 CFLAGS+=-DSIP_MYSQL_FRIENDS
93 endif
94
95 CFLAGS+=#-DVOFRDUMPER
96
97 ZAPDIR=/usr/lib
98
99 CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "chan_zap.so")
100 CHANNEL_LIBS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "chan_zap.so")
101
102 CHANNEL_LIBS+=$(shell [ -f /usr/include/nbs.h ] && echo "chan_nbs.so" )
103
104 ifndef OPENH323DIR
105 OPENH323DIR=$(HOME)/openh323
106 endif
107
108 ifndef PWLIBDIR
109 PWLIBDIR=$(HOME)/pwlib
110 endif
111
112 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
113
114 all: depend $(CHANNEL_LIBS) 
115
116 clean:
117         rm -f *.so *.o .depend
118         rm -f busy.h ringtone.h gentone gentone-ulaw
119
120 %.so : %.o
121         $(CC) $(SOLINK) -o $@ $<
122
123 ifneq ($(wildcard .depend),)
124 include .depend
125 endif
126
127 gentone: gentone.c
128         $(CC) -o gentone gentone.c -lm
129
130 gentone-ulaw: gentone-ulaw.c
131         $(CC) -o gentone-ulaw gentone-ulaw.c -lm
132
133 busy.h: gentone
134         ./gentone busy 480 620
135
136 ringtone.h: gentone
137         ./gentone ringtone 440 480
138
139 chan_oss.o: chan_oss.c  busy.h ringtone.h
140
141 ifeq (${OSARCH},OpenBSD)
142 chan_oss.so: chan_oss.o
143         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
144 endif
145 ifeq (${OSARCH},NetBSD)
146 chan_oss.so: chan_oss.o
147         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
148 endif
149
150 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
151 ifeq ($(USE_MYSQL_FRIENDS),1)
152         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o iax2-provision.o $(MYSQLLIB) -lz
153 else
154         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o iax2-provision.o
155 endif
156
157 chan_iax.so: chan_iax.o
158 ifeq ($(USE_MYSQL_FRIENDS),1)
159         $(CC) $(SOLINK) -o $@ chan_iax.o $(MYSQLLIB) -lz
160 else
161         $(CC) $(SOLINK) -o $@ chan_iax.o
162 endif
163
164 chan_zap.o: chan_zap.c
165         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
166
167 chan_zap.so: chan_zap.o
168         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
169
170 chan_sip.so: chan_sip.o
171 ifeq ($(USE_SIP_MYSQL_FRIENDS),1)
172         $(CC) $(SOLINK) -o $@ chan_sip.o $(MYSQLLIB) -lz
173 else
174         $(CC) $(SOLINK) -o $@ chan_sip.o
175 endif
176
177 chan_alsa.o: $(ALSA_SRC)
178
179
180 chan_alsa.so: chan_alsa.o
181         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
182
183 chan_nbs.so: chan_nbs.o
184         $(CC) $(SOLINK) -o $@ $< -lnbs
185
186 chan_vpb.o: chan_vpb.c
187         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
188
189 chan_vpb.so: chan_vpb.o
190          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
191
192 chan_h323.so: chan_h323.o h323/libchanh323.a
193         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
194
195
196 #chan_modem.so : chan_modem.o
197 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
198
199 install: all
200         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
201         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
202
203 depend: .depend
204
205 .depend:
206         ../mkdep $(CFLAGS) `ls *.c`
207
208 env:
209         env
210