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