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