e67af19948b57bcd7c168e2dd613ba818283558f
[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 else
43 MYSQLLIB=-L/usr/lib/mysql -lmysqlclient
44 PTLIB=-lpt_linux_x86_r
45 H323LIB=-lh323_linux_x86_r
46 CHANH323LIB=-ldl
47 endif
48
49 ifneq (${OSARCH},Darwin)
50 CHANNEL_LIBS+=chan_oss.so
51 endif
52 ifeq (${OSARCH},FreeBSD)
53 SOLINK+=-L/usr/local/lib
54 CHANNEL_LIBS+=chan_oss.so
55 endif
56
57 CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
58 CHANNEL_LIBS+=$(shell [ -f /usr/local/include/ixjuser.h ] && echo chan_phone.so)
59 CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
60
61 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
62 CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
63 CHANNEL_LIBS+=$(shell [ -f /usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
64 CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
65 CFLAGS+=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
66 CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
67 ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
68 ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
69 CFLAGS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
70 CFLAGS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
71 CHANNEL_LIBS+=$(shell [ -f /usr/include/vpbapi.h ] && echo "chan_vpb.so" )
72 CFLAGS+=$(shell [ -f /usr/include/vpbapi.h ] && echo " -DLINUX")
73
74 ALSA_SRC=chan_alsa.c
75 ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
76
77 CFLAGS+=-DCRYPTO
78 CFLAGS+=-fPIC
79
80 ifeq ($(USE_MYSQL_FRIENDS),1)
81 CFLAGS+=-DMYSQL_FRIENDS
82 USE_SIP_MYSQL_FRIENDS=1
83 endif
84 ifeq ($(USE_SIP_MYSQL_FRIENDS),1)
85 CFLAGS+=-DSIP_MYSQL_FRIENDS
86 endif
87
88 CFLAGS+=#-DVOFRDUMPER
89
90 ZAPDIR=/usr/lib
91
92 CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "chan_zap.so")
93 CHANNEL_LIBS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "chan_zap.so")
94
95 CHANNEL_LIBS+=$(shell [ -f /usr/include/nbs.h ] && echo "chan_nbs.so" )
96
97 ifndef OPENH323DIR
98 OPENH323DIR=$(HOME)/openh323
99 endif
100
101 ifndef PWLIBDIR
102 PWLIBDIR=$(HOME)/pwlib
103 endif
104
105 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
106
107 all: depend $(CHANNEL_LIBS) 
108
109 clean:
110         rm -f *.so *.o .depend
111         rm -f busy.h ringtone.h gentone gentone-ulaw
112
113 %.so : %.o
114         $(CC) $(SOLINK) -o $@ $<
115
116 ifneq ($(wildcard .depend),)
117 include .depend
118 endif
119
120 gentone: gentone.c
121         $(CC) -o gentone gentone.c -lm
122
123 gentone-ulaw: gentone-ulaw.c
124         $(CC) -o gentone-ulaw gentone-ulaw.c -lm
125
126 busy.h: gentone
127         ./gentone busy 480 620
128
129 ringtone.h: gentone
130         ./gentone ringtone 440 480
131
132 chan_oss.o: chan_oss.c  busy.h ringtone.h
133
134 ifeq (${OSARCH},OpenBSD)
135 chan_oss.so: chan_oss.o
136         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
137 endif
138
139 chan_iax2.so: chan_iax2.o iax2-parser.o
140 ifeq ($(USE_MYSQL_FRIENDS),1)
141         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o $(MYSQLLIB) -lz
142 else
143         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o
144 endif
145
146 chan_iax.so: chan_iax.o
147 ifeq ($(USE_MYSQL_FRIENDS),1)
148         $(CC) $(SOLINK) -o $@ chan_iax.o $(MYSQLLIB) -lz
149 else
150         $(CC) $(SOLINK) -o $@ chan_iax.o
151 endif
152
153 chan_zap.o: chan_zap.c
154         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
155
156 chan_zap.so: chan_zap.o
157         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
158
159 chan_sip.so: chan_sip.o
160 ifeq ($(USE_SIP_MYSQL_FRIENDS),1)
161         $(CC) $(SOLINK) -o $@ chan_sip.o $(MYSQLLIB) -lz
162 else
163         $(CC) $(SOLINK) -o $@ chan_sip.o
164 endif
165
166 chan_alsa.o: $(ALSA_SRC)
167
168
169 chan_alsa.so: chan_alsa.o
170         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
171
172 chan_nbs.so: chan_nbs.o
173         $(CC) $(SOLINK) -o $@ $< -lnbs
174
175 chan_vpb.o: chan_vpb.c
176         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
177
178 chan_vpb.so: chan_vpb.o
179          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
180
181 chan_h323.so: chan_h323.o h323/libchanh323.a
182         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lpthread -lcrypto -lssl -lexpat
183
184
185 #chan_modem.so : chan_modem.o
186 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
187
188 install: all
189         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
190         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
191
192 depend: .depend
193
194 .depend:
195         ../mkdep $(CFLAGS) `ls *.c`
196
197 env:
198         env
199