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 RESAMPLE_OBJS:=libresample/src/resample.o libresample/src/resamplesubs.o libresample/src/filterkit.o
22 OBJS= tcptls.o io.o sched.o logger.o frame.o loader.o config.o channel.o \
23 translate.o file.o pbx.o cli.o md5.o term.o \
24 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
25 cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
26 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
27 astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
28 utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
29 netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
30 cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
31 strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o \
32 astobj2.o hashtab.o global_datastores.o $(RESAMPLE_OBJS) version.o
34 # we need to link in the objects statically, not as a library, because
35 # otherwise modules will not have them available if none of the static
37 OBJS+=stdtime/localtime.o
39 # At the moment say.o is an optional component which can be overridden
43 AST_LIBS += $(SSL_LIB)
44 AST_LIBS += $(BKTR_LIB)
46 ifeq ($(POLL_AVAILABLE),)
50 ifeq ($(wildcard /usr/include/dlfcn.h),)
54 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc ),)
55 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
61 AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv
63 AST_LIBS+=$(EDITLINE_LIB) -lm
66 ifneq ($(findstring darwin,$(OSARCH)),)
68 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
72 # These are used for all but Darwin
73 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
74 ASTLINK+=-Wl,--export-dynamic
76 ASTLINK+=${GC_LDFLAGS}
78 ifneq ($(findstring BSD,$(OSARCH)),)
79 LDFLAGS+=-L/usr/local/lib
83 ifeq ($(OSARCH),FreeBSD)
84 # -V is understood by BSD Make, not by GNU make.
85 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
86 AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
90 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
91 AST_LIBS+=-lminires -ldl
92 ASTLINK+= -shared -Wl,--out-implib,libasterisk.a
94 ifeq ($(OSARCH),NetBSD)
95 AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
98 ifeq ($(OSARCH),OpenBSD)
99 AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
102 ifeq ($(OSARCH),SunOS)
103 AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
107 CHECK_SUBDIR: # do nothing, just make sure that we recurse in the subdir/
109 editline/libedit.a: CHECK_SUBDIR
110 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)
111 $(MAKE) -C editline libedit.a
113 db1-ast/libdb1.a: CHECK_SUBDIR
114 CFLAGS="$(ASTCFLAGS)" LDFLAGS="$(ASTLDFLAGS)" $(MAKE) -C db1-ast libdb1.a
116 ast_expr2.c ast_expr2.h:
117 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
120 flex -o $@ --full ast_expr2.fl # moved the correction of yyfree into the flex input file itself.
121 sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' ast_expr2f.c > zz
124 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
125 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
126 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
127 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm
128 rm ast_expr2.o ast_expr2f.o
130 channel.o: ASTCFLAGS+=$(ZAPTEL_INCLUDE)
132 AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
133 AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
134 AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
135 OBJS:=$(sort $(OBJS))
137 ifneq ($(wildcard ../channels/h323/Makefile.ast),)
138 include ../channels/h323/Makefile.ast
144 minimime/libmmime.a: CHECK_SUBDIR
145 @cd minimime && $(MAKE) libmmime.a
147 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
148 MAIN_TGT:=asterisk.dll
150 mv cygload.exe asterisk.exe
152 cygload: asterisk.dll
157 $(MAIN_TGT): $(OBJS) editline/libedit.a db1-ast/libdb1.a minimime/libmmime.a $(AST_EMBED_LDSCRIPTS)
158 @$(CC) -c -o buildinfo.o $(ASTCFLAGS) buildinfo.c
159 $(ECHO_PREFIX) echo " [LD] $^ -> $@"
160 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
161 $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS)
163 $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS)
165 @$(ASTTOPDIR)/build_tools/strip_nonapi $@
170 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
171 @$(MAKE) -C db1-ast clean
172 @$(MAKE) -C stdtime clean
173 @$(MAKE) -C minimime clean
174 rm -f libresample/src/*.o