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
20 OBJS= io.o sched.o logger.o frame.o loader.o config.o channel.o \
21 translate.o file.o pbx.o cli.o md5.o term.o \
22 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
23 cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
24 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
25 astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
26 utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
27 netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
28 cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
29 strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o \
32 # we need to link in the objects statically, not as a library, because
33 # otherwise modules will not have them available if none of the static
35 OBJS+=stdtime/localtime.o
37 # At the moment say.o is an optional component which can be overridden
41 AST_LIBS += $(SSL_LIB)
42 AST_LIBS += $(BKTR_LIB)
44 ifeq ($(POLL_AVAILABLE),)
48 ifeq ($(wildcard /usr/include/dlfcn.h),)
52 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc ),)
53 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
59 AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv
61 AST_LIBS+=$(EDITLINE_LIB) -lm
64 ifneq ($(findstring darwin,$(OSARCH)),)
66 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
70 # These are used for all but Darwin
71 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
72 ASTLINK+=-Wl,--export-dynamic
74 ASTLINK+=${GC_LDFLAGS}
76 ifneq ($(findstring BSD,$(OSARCH)),)
77 LDFLAGS+=-L/usr/local/lib
81 ifeq ($(OSARCH),FreeBSD)
82 # -V is understood by BSD Make, not by GNU make.
83 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
84 AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
88 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
89 AST_LIBS+=-lminires -ldl
90 ASTLINK+= -shared -Wl,--out-implib,asterisk.dll
92 ifeq ($(OSARCH),NetBSD)
93 AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
96 ifeq ($(OSARCH),OpenBSD)
97 AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
100 ifeq ($(OSARCH),SunOS)
101 AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
105 CHECK_SUBDIR: # do nothing, just make sure that we recurse in the subdir/
107 editline/libedit.a: CHECK_SUBDIR
108 cd editline && test -f config.h || CFLAGS="$(PTHREAD_CFLAGS) $(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)
109 $(MAKE) -C editline libedit.a
111 db1-ast/libdb1.a: CHECK_SUBDIR
112 CFLAGS="$(ASTCFLAGS)" LDFLAGS="$(ASTLDFLAGS)" $(MAKE) -C db1-ast libdb1.a
114 ast_expr2.c ast_expr2.h:
115 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
118 flex -o $@ --full ast_expr2.fl
119 sed 's@free( (char \*) ptr );@if(ptr) free( (char *) ptr );@' ast_expr2f.c > zz
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 channel.o: ASTCFLAGS+=$(ZAPTEL_INCLUDE)
130 AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
131 AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
132 AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
133 OBJS:=$(sort $(OBJS))
135 ifneq ($(wildcard ../channels/h323/Makefile.ast),)
136 include ../channels/h323/Makefile.ast
142 minimime/libmmime.a: CHECK_SUBDIR
143 @cd minimime && $(MAKE) libmmime.a
145 asterisk: $(OBJS) editline/libedit.a db1-ast/libdb1.a minimime/libmmime.a $(AST_EMBED_LDSCRIPTS)
146 @$(CC) -c -o buildinfo.o $(ASTCFLAGS) buildinfo.c
147 $(ECHO_PREFIX) echo " [LD] $^ -> $@"
148 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
149 $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS)
151 $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS)
153 @$(ASTTOPDIR)/build_tools/strip_nonapi $@
158 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
159 @$(MAKE) -C db1-ast clean
160 @$(MAKE) -C stdtime clean
161 @$(MAKE) -C minimime clean