clean up, use make functions instead of subshells, remove unused stuff
[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/linux/if_wanpipe.h),)
75   CFLAGS+=-DOLD_SANGOMA_API
76 endif
77
78 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/alsa/asoundlib.h),)
79   CHANNEL_LIBS+=chan_alsa.so
80 endif
81
82 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libpri.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libpri.so.1),)
83   CFLAGS+=-DZAPATA_PRI
84   ZAPPRI=-lpri
85 endif
86
87 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libmfcr2.so.1)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/lib/libmfcr2.so.1),)
88   CFLAGS+=-DZAPATA_R2
89   ZAPR2=-lmfcr2
90 endif
91
92 ALSA_SRC=chan_alsa.c
93
94 ifneq ($(wildcard alsa-monitor.h),)
95   CFLAGS+=-DALSA_MONITOR
96   ALSA_SRC+=alsa-monitor.h
97 endif
98
99 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
100   CFLAGS+=-DIAX_TRUNKING
101   CHANNEL_LIBS+=chan_zap.so
102 endif
103
104 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
105   CHANNEL_LIBS+=chan_vpb.so
106   CFLAGS+=-DLINUX
107 endif
108
109 CFLAGS+=-DCRYPTO
110 CFLAGS+=-fPIC
111
112 CFLAGS+=#-DVOFRDUMPER
113
114 ZAPDIR=/usr/lib
115
116 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/nbs.h),)
117   CHANNEL_LIBS+=chan_nbs.so
118 endif
119
120 ifndef OPENH323DIR
121   OPENH323DIR=$(HOME)/openh323
122 endif
123
124 ifndef PWLIBDIR
125   PWLIBDIR=$(HOME)/pwlib
126 endif
127
128 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
129
130 all: depend $(CHANNEL_LIBS) 
131
132 clean:
133         rm -f *.so *.o .depend
134         rm -f busy.h ringtone.h gentone gentone-ulaw
135
136 %.so : %.o
137         $(CC) $(SOLINK) -o $@ $<
138
139 ifneq ($(wildcard .depend),)
140   include .depend
141 endif
142
143 ifneq ($(wildcard h323/Makefile.ast),)
144   include h323/Makefile.ast
145 endif
146
147 gentone: gentone.c
148         $(HOST_CC) -o gentone gentone.c -lm
149
150 gentone-ulaw: gentone-ulaw.c
151         $(HOST_CC) -o gentone-ulaw gentone-ulaw.c -lm
152
153 busy.h: gentone
154         ./gentone busy 480 620
155
156 ringtone.h: gentone
157         ./gentone ringtone 440 480
158
159 chan_oss.o: chan_oss.c  busy.h ringtone.h
160
161 ifeq (${OSARCH},OpenBSD)
162 chan_oss.so: chan_oss.o
163         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
164 endif
165 ifeq (${OSARCH},NetBSD)
166 chan_oss.so: chan_oss.o
167         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
168 endif
169
170 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
171         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o iax2-provision.o
172
173 chan_zap.o: chan_zap.c
174         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
175
176 chan_zap.so: chan_zap.o
177         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
178
179 chan_sip.so: chan_sip.o
180         $(CC) $(SOLINK) -o $@ chan_sip.o
181
182 chan_alsa.o: $(ALSA_SRC)
183
184 chan_alsa.so: chan_alsa.o
185         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
186
187 chan_nbs.so: chan_nbs.o
188         $(CC) $(SOLINK) -o $@ $< -lnbs
189
190 chan_vpb.o: chan_vpb.c
191         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
192
193 chan_vpb.so: chan_vpb.o
194          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
195
196 ifeq (${OSARCH},Linux)
197 chan_h323.so: chan_h323.o h323/libchanh323.a h323/Makefile.ast
198         $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) -lstdc++
199 else
200 chan_h323.so: chan_h323.o h323/libchanh323.a
201         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
202 endif
203
204
205 #chan_modem.so : chan_modem.o
206 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
207
208 install: all
209         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
210         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
211
212 depend: .depend
213
214 .depend:
215         ../build_tools/mkdep $(CFLAGS) `ls *.c`
216
217 env:
218         env
219