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