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