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 \
31 # we need to link in the objects statically, not as a library, because
32 # otherwise modules will not have them available if none of the static
34 OBJS+=stdtime/localtime.o
36 # At the moment say.o is an optional component which can be overridden
40 ifeq ($(wildcard /usr/include/sys/poll.h),)
44 ifeq ($(wildcard /usr/include/dlfcn.h),)
48 ifneq ($(findstring $(OSARCH), linux-gnu uclinux ),)
49 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
52 AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv
54 AST_LIBS+=$(EDITLINE_LIB) -lm
57 ifneq ($(findstring darwin,$(OSARCH)),)
59 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
62 # Mac on Intel CoreDuo does not need poll compatibility layer
65 ASTCFLAGS+=-DPOLLCOMPAT
68 # These are used for all but Darwin
69 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
70 ASTLINK+=-Wl,--export-dynamic
72 ASTLINK+=${GC_LDFLAGS}
74 ifneq ($(findstring BSD,$(OSARCH)),)
75 LDFLAGS+=-L/usr/local/lib
79 ifeq ($(OSARCH),FreeBSD)
83 ifeq ($(OSARCH),NetBSD)
84 AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
87 ifeq ($(OSARCH),OpenBSD)
88 AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
91 ifeq ($(OSARCH),SunOS)
92 AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
97 cd editline && unset CFLAGS AST_LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)
98 $(MAKE) -C editline libedit.a
101 CFLAGS="$(ASTCFLAGS)" $(MAKE) -C db1-ast libdb1.a
103 ast_expr2.c ast_expr2.h:
104 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
107 flex -o $@ --full ast_expr2.fl
109 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
110 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
111 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
112 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o
113 rm ast_expr2.o ast_expr2f.o
115 channel.o: CFLAGS+=$(ZAPTEL_INCLUDE)
117 AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
118 AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
119 AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
120 OBJS:=$(sort $(OBJS))
122 asterisk: $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
123 @$(ASTTOPDIR)/build_tools/make_build_h > $(ASTTOPDIR)/include/asterisk/build.h.tmp
124 @if cmp -s $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; then echo ; else \
125 mv $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; \
127 @rm -f $(ASTTOPDIR)/include/asterisk/build.h.tmp
128 @$(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
129 $(ECHO_PREFIX) echo " [LD] $^ -> $@"
130 $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o asterisk $(ASTLINK) $(AST_EMBED_LDFLAGS) $(LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS)
135 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
136 @$(MAKE) -C db1-ast clean
137 @$(MAKE) -C stdtime clean