correct cygwin detection (issue #5328)
[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 chan_alsa.o: chan_alsa.c busy.h ringtone.h
164
165 ifeq (${OSARCH},OpenBSD)
166 chan_oss.so: chan_oss.o
167         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
168 endif
169 ifeq (${OSARCH},NetBSD)
170 chan_oss.so: chan_oss.o
171         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
172 endif
173
174 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
175         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o iax2-provision.o
176
177 chan_zap.o: chan_zap.c
178         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
179
180 chan_zap.so: chan_zap.o
181         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
182
183 chan_sip.so: chan_sip.o
184         $(CC) $(SOLINK) -o $@ chan_sip.o
185
186 chan_alsa.o: $(ALSA_SRC)
187
188 chan_alsa.so: chan_alsa.o
189         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
190
191 chan_nbs.so: chan_nbs.o
192         $(CC) $(SOLINK) -o $@ $< -lnbs
193
194 chan_vpb.o: chan_vpb.c
195         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
196
197 chan_vpb.so: chan_vpb.o
198          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
199
200 ifeq (${OSARCH},Linux)
201 chan_h323.so: chan_h323.o h323/libchanh323.a h323/Makefile.ast
202         $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) -lstdc++
203 else
204 chan_h323.so: chan_h323.o h323/libchanh323.a
205         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
206 endif
207
208
209 #chan_modem.so : chan_modem.o
210 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
211
212 install: all
213         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
214         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
215
216 depend: .depend
217
218 .depend:
219         ../build_tools/mkdep $(CFLAGS) `ls *.c`
220
221 env:
222         env
223