7b0d7b9701eadfdeebc2d52b47fa3dd3db3d1243
[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 chan_modem_i4l.so \
23              chan_agent.so chan_mgcp.so chan_iax2.so \
24              chan_local.so chan_skinny.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 CHANNEL_LIBS+=chan_oss.so
56 endif
57
58 CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
59 CHANNEL_LIBS+=$(shell [ -f /usr/local/include/ixjuser.h ] && echo chan_phone.so)
60 #CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
61
62 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
63 CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
64 CHANNEL_LIBS+=$(shell [ -f /usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
65 CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
66 CFLAGS+=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
67 CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
68 ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
69 ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
70 CFLAGS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
71 CFLAGS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
72 CHANNEL_LIBS+=$(shell [ -f /usr/include/vpbapi.h ] && echo "chan_vpb.so" )
73 CFLAGS+=$(shell [ -f /usr/include/vpbapi.h ] && echo " -DLINUX")
74
75 ALSA_SRC=chan_alsa.c
76 ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
77
78 CFLAGS+=-DCRYPTO
79 CFLAGS+=-fPIC
80
81 CFLAGS+=#-DVOFRDUMPER
82
83 ZAPDIR=/usr/lib
84
85 CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "chan_zap.so")
86 CHANNEL_LIBS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "chan_zap.so")
87
88 CHANNEL_LIBS+=$(shell [ -f /usr/include/nbs.h ] && echo "chan_nbs.so" )
89
90 ifndef OPENH323DIR
91 OPENH323DIR=$(HOME)/openh323
92 endif
93
94 ifndef PWLIBDIR
95 PWLIBDIR=$(HOME)/pwlib
96 endif
97
98 #CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
99
100 all: depend $(CHANNEL_LIBS) 
101
102 clean:
103         rm -f *.so *.o .depend
104         rm -f busy.h ringtone.h gentone gentone-ulaw
105
106 %.so : %.o
107         $(CC) $(SOLINK) -o $@ $<
108
109 ifneq ($(wildcard .depend),)
110 include .depend
111 endif
112
113 gentone: gentone.c
114         $(CC) -o gentone gentone.c -lm
115
116 gentone-ulaw: gentone-ulaw.c
117         $(CC) -o gentone-ulaw gentone-ulaw.c -lm
118
119 busy.h: gentone
120         ./gentone busy 480 620
121
122 ringtone.h: gentone
123         ./gentone ringtone 440 480
124
125 chan_oss.o: chan_oss.c  busy.h ringtone.h
126
127 ifeq (${OSARCH},OpenBSD)
128 chan_oss.so: chan_oss.o
129         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
130 endif
131 ifeq (${OSARCH},NetBSD)
132 chan_oss.so: chan_oss.o
133         $(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
134 endif
135
136 chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
137         $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o iax2-provision.o
138
139 chan_zap.o: chan_zap.c
140         $(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
141
142 chan_zap.so: chan_zap.o
143         $(CC) $(SOLINK) -o $@ $<  $(ZAPPRI) $(ZAPR2) -ltonezone
144
145 chan_sip.so: chan_sip.o
146         $(CC) $(SOLINK) -o $@ chan_sip.o
147
148 chan_alsa.o: $(ALSA_SRC)
149
150
151 chan_alsa.so: chan_alsa.o
152         $(CC) $(SOLINK) -o $@ $< -lasound -lm -ldl
153
154 chan_nbs.so: chan_nbs.o
155         $(CC) $(SOLINK) -o $@ $< -lnbs
156
157 chan_vpb.o: chan_vpb.c
158         $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
159
160 chan_vpb.so: chan_vpb.o
161          $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
162
163 chan_h323.so: chan_h323.o h323/libchanh323.a
164         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
165
166
167 #chan_modem.so : chan_modem.o
168 #       $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
169
170 install: all
171         for x in $(CHANNEL_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
172         if ! [ -f chan_iax.so ]; then rm -f $(DESTDIR)$(MODULES_DIR)/chan_iax.so ; fi
173
174 depend: .depend
175
176 .depend:
177         ../mkdep $(CFLAGS) `ls *.c`
178
179 env:
180         env
181