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