Remove unneeded linux-gnueabi*
[asterisk/asterisk.git] / main / Makefile
1 #
2 # Asterisk -- An open source telephony toolkit.
3 #
4 # Makefile to build main Asterisk binary
5 #
6 # Copyright (C) 1999-2006, Digium, Inc.
7 #
8 # Mark Spencer <markster@digium.com>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts.embed_rules $(ASTTOPDIR)/makeopts
15
16 all: asterisk
17
18 include $(ASTTOPDIR)/Makefile.moddir_rules
19
20 # Must include the extra ast_expr2.c, ast_expr2f.c, in case they need to be regenerated (because to force regeneration, we delete them)
21 SRC:=$(wildcard *.c) ast_expr2.c ast_expr2f.c
22 ifeq ($(AST_ASTERISKSSL),yes)
23 SRC:=$(filter-out libasteriskssl.c,$(SRC))
24 endif
25 OBJSFILTER=fskmodem_int.o fskmodem_float.o cygload.o buildinfo.o
26 OBJS=$(filter-out $(OBJSFILTER),$(SRC:.c=.o))
27
28 # we need to link in the objects statically, not as a library, because
29 # otherwise modules will not have them available if none of the static
30 # objects use it.
31 OBJS+=stdtime/localtime.o
32
33 ASTSSL_LIBS:=$(OPENSSL_LIB)
34 AST_LIBS+=$(BKTR_LIB)
35 AST_LIBS+=$(LIBXML2_LIB)
36 AST_LIBS+=$(SQLITE3_LIB)
37 AST_LIBS+=$(ASTSSL_LIBS)
38 AST_LIBS+=$(JANSSON_LIB)
39
40 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc kfreebsd-gnu),)
41   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
42   AST_LIBS+=-ldl
43   endif
44   ifneq (x$(CAP_LIB),x)
45     AST_LIBS+=$(CAP_LIB)
46   endif
47   AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv -luuid
48 else
49   AST_LIBS+=$(EDITLINE_LIB) -lm
50 endif
51
52 ifneq ($(findstring BETTER_BACKTRACES,$(MENUSELECT_CFLAGS)),)
53   AST_LIBS+=$(BFD_LIB)
54 endif
55
56 ifneq ($(findstring darwin,$(OSARCH)),)
57   AST_LIBS+=-lresolv
58   ASTLINK=-Xlinker -macosx_version_min -Xlinker 10.6 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
59   ASTLINK+=/usr/lib/bundle1.o
60 else
61 # These are used for all but Darwin
62   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
63     ASTLINK+=-Wl,--export-dynamic
64   else
65     ASTLINK+=${GC_LDFLAGS}
66   endif
67   ifneq ($(findstring BSD,$(OSARCH)),)
68     LDFLAGS+=-L/usr/local/lib
69   endif
70 endif
71
72 ifeq ($(OSARCH),FreeBSD)
73   # -V is understood by BSD Make, not by GNU make.
74   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
75   AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
76   AST_LIBS+=-lcrypto
77 endif
78
79 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
80   AST_LIBS+=-lminires -ldl
81   ASTLINK+=-shared -Wl,--out-implib,libasterisk.a
82 endif
83 ifeq ($(OSARCH),NetBSD)
84   AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
85 endif
86
87 ifeq ($(OSARCH),OpenBSD)
88   AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
89 endif
90
91 ifeq ($(OSARCH),SunOS)
92   AST_LIBS+=-lpthread -ldl -lrt -lnsl -lsocket -lresolv
93   ASTSSL_LIBS+=-L/opt/ssl/lib -L/usr/local/ssl/lib
94   ASTLINK=
95 endif
96
97 ifneq ($(findstring USE_HOARD_ALLOCATOR,$(MENUSELECT_CFLAGS)),)
98   ifneq ($(HOARD_LIB),)
99     AST_LIBS+=$(HOARD_LIB)
100   endif
101 endif
102
103 ifeq ($(GNU_LD),1)
104 ASTLINK+=-Wl,--version-script,asterisk.exports
105   ifeq ($(HAVE_DYNAMIC_LIST),1)
106   ASTLINK+=-Wl,--dynamic-list,asterisk.dynamics
107   endif
108 endif
109
110 .PHONY: CHECK_SUBDIR
111 CHECK_SUBDIR:   # do nothing, just make sure that we recurse in the subdir/
112
113 editline/libedit.a: CHECK_SUBDIR
114         cd editline && test -f config.h || CFLAGS="$(PTHREAD_CFLAGS) $(subst $(ASTTOPDIR),../../,$(_ASTCFLAGS:-Werror=) $(ASTCFLAGS))" LDFLAGS="$(_ASTLDFLAGS) $(ASTLDFLAGS)" ./configure --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) --with-ncurses=$(NCURSES_DIR) --with-curses=$(CURSES_DIR) --with-termcap=$(TERMCAP_DIR) --with-tinfo=$(TINFO_DIR)
115         $(MAKE) -C editline libedit.a
116
117 ifneq ($(findstring REBUILD_PARSERS,$(MENUSELECT_CFLAGS)),)
118 ast_expr2.c ast_expr2.h: ast_expr2.y
119 else
120 ast_expr2.c ast_expr2.h:
121 endif
122         $(ECHO_PREFIX) echo "   [BISON] $< -> $@"
123         $(CMD_PREFIX) $(BISON) -o $@ -d --name-prefix=ast_yy ast_expr2.y
124
125 ifneq ($(findstring REBUILD_PARSERS,$(MENUSELECT_CFLAGS)),)
126 ast_expr2f.c: ast_expr2.fl
127 else
128 ast_expr2f.c:
129 endif
130         $(ECHO_PREFIX) echo "   [FLEX] $< -> $@"
131         $(CMD_PREFIX) $(FLEX) -o $@ ast_expr2.fl
132         $(CMD_PREFIX) sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' $@ > $@.fix
133         $(CMD_PREFIX) echo "#include \"asterisk.h\"" > $@
134         $(CMD_PREFIX) echo >> $@
135         $(CMD_PREFIX) cat $@.fix >> $@
136         $(CMD_PREFIX) rm $@.fix
137
138 ast_expr2f.o: _ASTCFLAGS+=-Wno-unused
139
140 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
141         $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
142         $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
143         $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm
144         rm ast_expr2.o ast_expr2f.o
145
146 ifneq ($(LIBEDIT_INTERNAL),no)
147 LIBEDIT_OBJ=editline/libedit.a
148 LIBEDIT_INCLUDE=-I. -Ieditline
149 endif
150
151 db.o: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
152 asterisk.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
153 cli.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
154
155 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
156 http.o: _ASTCFLAGS+=$(GMIME_INCLUDE)
157 endif
158
159 stdtime/localtime.o: _ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral
160
161 AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
162 AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
163 AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
164 OBJS:=$(sort $(OBJS))
165
166 ifneq ($(wildcard ../channels/h323/Makefile.ast),)
167   include ../channels/h323/Makefile.ast
168 else
169   H323LDFLAGS=
170   H323LDLIBS=
171 endif
172
173 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
174 MAIN_TGT:=asterisk.dll
175 asterisk: cygload
176         mv cygload.exe asterisk.exe
177
178 cygload: asterisk.dll
179 else
180 MAIN_TGT:=asterisk
181 endif
182
183 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
184 GMIMELDFLAGS+=$(GMIME_LIB)
185 endif
186
187 $(OBJS): _ASTCFLAGS+=-DAST_MODULE=\"core\"
188
189 libasteriskssl.o: _ASTCFLAGS+=$(OPENSSL_INCLUDE)
190
191 ifeq ($(AST_ASTERISKSSL),yes)
192 # The ABI *version* of the asteriskssl library; don't change this unless there truly is a
193 # non-backwards-compatible ABI change in the library
194 ASTSSL_SO_VERSION=1
195
196 ASTSSL_LDLIBS=-L. -lasteriskssl
197
198 ifeq ($(findstring darwin,$(OSARCH)),) # not Darwin
199 ASTSSL_LIB:=libasteriskssl.so
200
201 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTLDFLAGS+=-Wl,-soname=$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)
202 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\"
203 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): LIBS+=$(ASTSSL_LIBS)
204 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): SO_SUPPRESS_SYMBOLS=-Wl,--version-script,libasteriskssl.exports,--warn-common
205 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): SOLINK=$(DYLINK)
206
207 # These rules are duplicated from $(ASTTOPDIR)/Makefile.rules because the library name
208 # being built does not match the "%.so" pattern; there are also additional steps
209 # required to build a proper shared library (as opposed to the 'loadable module'
210 # type that are built by the standard rules)
211 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): libasteriskssl.o
212 ifeq ($(GNU_LD),1)
213         $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/make_linker_version_script libasteriskssl "$(LINKER_SYMBOL_PREFIX)" "$(ASTTOPDIR)"
214 endif
215         $(ECHO_PREFIX) echo "   [LD] $^ -> $@"
216         $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(CC_LDFLAGS_SO) $^ $(CC_LIBS)
217 ifneq ($(LDCONFIG),)
218         $(LDCONFIG) $(LDCONFIG_FLAGS) .
219 endif
220
221 $(ASTSSL_LIB): $(ASTSSL_LIB).$(ASTSSL_SO_VERSION)
222         $(LN) -sf $< $@
223
224 else # Darwin
225 ASTSSL_LIB:=libasteriskssl.dylib
226
227 # -install_name allows library to be found if installed somewhere other than
228 # /lib or /usr/lib
229 $(ASTSSL_LIB): _ASTLDFLAGS+=-dynamiclib -install_name $(ASTLIBDIR)/$(ASTSSL_LIB)
230 $(ASTSSL_LIB): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\"
231 $(ASTSSL_LIB): LIBS+=$(ASTSSL_LIBS)
232 $(ASTSSL_LIB): SOLINK=$(DYLINK)
233
234 # Special rules for building a shared library (not a dynamically loadable module)
235 $(ASTSSL_LIB): libasteriskssl.o
236         $(ECHO_PREFIX) echo "   [LD] $^ -> $@"
237         $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(CC_LDFLAGS_SO) $^ $(CC_LIBS)
238 endif
239
240 endif
241
242 tcptls.o: _ASTCFLAGS+=$(OPENSSL_INCLUDE)
243
244 $(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS)
245         @$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS)
246         $(ECHO_PREFIX) echo "   [LD] $(OBJS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) -> $@"
247 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
248         $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB)
249 else
250         $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB)
251 endif
252
253 ifeq ($(GNU_LD),1)
254 $(MAIN_TGT): asterisk.exports
255 asterisk.exports: asterisk.exports.in
256         $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/make_linker_version_script asterisk $(LINKER_SYMBOL_PREFIX)
257 endif
258
259 bininstall:
260         $(INSTALL) -m 755 $(MAIN_TGT) "$(DESTDIR)$(ASTSBINDIR)/"
261 ifeq ($(AST_ASTERISKSSL),yes)
262 ifeq ($(findstring darwin,$(OSARCH)),) # not Darwin
263         $(INSTALL) -m 755 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION) "$(DESTDIR)$(ASTLIBDIR)/"
264         $(LN) -sf $(ASTSSL_LIB).$(ASTSSL_SO_VERSION) "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB)"
265 else # Darwin
266         $(INSTALL) -m 755 $(ASTSSL_LIB) "$(DESTDIR)$(ASTLIBDIR)/"
267 endif
268 ifneq ($(LDCONFIG),)
269         $(LDCONFIG) $(LDCONFIG_FLAGS) "$(DESTDIR)$(ASTLIBDIR)/"
270 endif
271 endif
272         $(LN) -sf asterisk "$(DESTDIR)$(ASTSBINDIR)/rasterisk"
273
274 binuninstall:
275         rm -f "$(DESTDIR)$(ASTSBINDIR)/$(MAIN_TGT)"
276         rm -f "$(DESTDIR)$(ASTSBINDIR)/rasterisk"
277         rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)"
278 ifneq ($(LDCONFIG),)
279         $(LDCONFIG) $(LDCONFIG_FLAGS) "$(DESTDIR)$(ASTLIBDIR)/"
280 endif
281
282 clean::
283         rm -f asterisk libasteriskssl.o
284 ifeq ($(AST_ASTERISKSSL),yes)
285         rm -f $(ASTSSL_LIB) $(ASTSSL_LIB).*
286 endif
287         rm -f asterisk.exports libasteriskssl.exports
288         @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
289         @$(MAKE) -C stdtime clean
290         rm -f libresample/src/*.o