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