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