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