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