2 # Asterisk -- A telephony toolkit for Linux.
4 # Makefile to build main Asterisk binary
6 # Copyright (C) 1999-2006, Digium, Inc.
8 # Mark Spencer <markster@digium.com>
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
14 -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts.embed_rules
18 include $(ASTTOPDIR)/Makefile.moddir_rules
21 OBJSFILTER=fskmodem_int.o fskmodem_float.o cygload.o buildinfo.o
22 OBJS=$(filter-out $(OBJSFILTER),$(SRC:.c=.o))
24 # we need to link in the objects statically, not as a library, because
25 # otherwise modules will not have them available if none of the static
27 OBJS+=stdtime/localtime.o
29 # At the moment say.o is an optional component which can be overridden
33 AST_LIBS += $(OPENSSL_LIB)
34 AST_LIBS += $(BKTR_LIB)
35 AST_LIBS += $(LIBXML2_LIB)
37 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-gnueabi ),)
38 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
44 AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv
46 AST_LIBS+=$(EDITLINE_LIB) -lm
49 ifneq ($(findstring darwin,$(OSARCH)),)
51 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
55 # These are used for all but Darwin
56 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
57 ASTLINK+=-Wl,--export-dynamic
59 ASTLINK+=${GC_LDFLAGS}
61 ifneq ($(findstring BSD,$(OSARCH)),)
62 LDFLAGS+=-L/usr/local/lib
66 ifeq ($(OSARCH),FreeBSD)
67 # -V is understood by BSD Make, not by GNU make.
68 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
69 AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
73 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
74 AST_LIBS+=-lminires -ldl
75 ASTLINK+= -shared -Wl,--out-implib,libasterisk.a
77 ifeq ($(OSARCH),NetBSD)
78 AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
81 ifeq ($(OSARCH),OpenBSD)
82 AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
85 ifeq ($(OSARCH),SunOS)
86 AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
90 ifneq ($(findstring USE_HOARD_ALLOCATOR,$(MENUSELECT_CFLAGS)),)
92 AST_LIBS+=$(HOARD_LIB)
97 ASTLINK+=-Wl,--version-script,asterisk.exports
100 CHECK_SUBDIR: # do nothing, just make sure that we recurse in the subdir/
102 editline/libedit.a: CHECK_SUBDIR
103 cd editline && test -f config.h || CFLAGS="$(PTHREAD_CFLAGS) $(subst $(ASTTOPDIR),../../,$(ASTCFLAGS:-Werror=))" LDFLAGS="$(ASTLDFLAGS)" ./configure --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) --with-ncurses=$(NCURSES_DIR) --with-curses=$(CURSES_DIR) --with-termcap=$(TERMCAP_DIR) --with-tinfo=$(TINFO_DIR)
104 $(MAKE) -C editline libedit.a
106 db1-ast/libdb1.a: CHECK_SUBDIR
107 CFLAGS="$(subst $(ASTTOPDIR),../../,$(ASTCFLAGS))" LDFLAGS="$(ASTLDFLAGS)" $(MAKE) -C db1-ast libdb1.a
109 ast_expr2.c ast_expr2.h:
110 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
113 flex -o $@ ast_expr2.fl
114 sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' $@ > $@.fix
115 echo "#include \"asterisk.h\"" > $@
120 ast_expr2f.o: ASTCFLAGS+=-Wno-unused
122 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
123 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
124 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
125 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm
126 rm ast_expr2.o ast_expr2f.o
128 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
129 http.o: ASTCFLAGS+=$(GMIME_INCLUDE)
132 stdtime/localtime.o: ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral
134 AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
135 AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
136 AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
137 OBJS:=$(sort $(OBJS))
139 ifneq ($(wildcard ../channels/h323/Makefile.ast),)
140 include ../channels/h323/Makefile.ast
146 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
147 MAIN_TGT:=asterisk.dll
149 mv cygload.exe asterisk.exe
151 cygload: asterisk.dll
156 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
157 GMIMELDFLAGS+=$(GMIME_LIB)
160 $(MAIN_TGT): $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) asterisk.exports
161 @$(CC) -c -o buildinfo.o $(ASTCFLAGS) buildinfo.c
162 $(ECHO_PREFIX) echo " [LD] $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) -> $@"
163 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
164 $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS)
166 $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS)
172 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
173 @$(MAKE) -C db1-ast clean
174 @$(MAKE) -C stdtime clean
175 rm -f libresample/src/*.o