Merge changes from team/russell/issue_9520
[asterisk-bristuff.git] / main / Makefile
blob6cf1c5e8312f7caa7eb93c05da0dee77c65ca491
2 # Asterisk -- A telephony toolkit for Linux.
3 #
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
16 all: asterisk
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 astobj2.o global_datastores.o \
30 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
34 # objects use it.
35 OBJS+=stdtime/localtime.o
37 # At the moment say.o is an optional component which can be overridden
38 # by a module.
39 OBJS+=say.o
41 ifneq ($(findstring darwin,$(OSARCH)),)
42 OBJS+=poll.o
43 ASTCFLAGS+=-DPOLLCOMPAT
44 else
45 ifeq ($(wildcard /usr/include/sys/poll.h),)
46 OBJS+=poll.o
47 ASTCFLAGS+=-DPOLLCOMPAT
48 endif
49 endif
51 ifeq ($(wildcard /usr/include/dlfcn.h),)
52 OBJS+=dlfcn.o
53 endif
55 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc ),)
56 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
57 AST_LIBS+=-ldl
58 endif
59 ifneq (x$(CAP_LIB),x)
60 AST_LIBS+=$(CAP_LIB)
61 endif
62 AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv
63 else
64 AST_LIBS+=$(EDITLINE_LIB) -lm
65 endif
67 ifneq ($(findstring darwin,$(OSARCH)),)
68 AST_LIBS+=-lresolv
69 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
70 ASTLINK=-Wl,-dynamic
71 endif
72 else
73 # These are used for all but Darwin
74 ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
75 ASTLINK+=-Wl,--export-dynamic
76 else
77 ASTLINK+=${GC_LDFLAGS}
78 endif
79 ifneq ($(findstring BSD,$(OSARCH)),)
80 LDFLAGS+=-L/usr/local/lib
81 endif
82 endif
84 ifeq ($(OSARCH),FreeBSD)
85 AST_LIBS+=-lcrypto
86 endif
88 ifeq ($(OSARCH),NetBSD)
89 AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
90 endif
92 ifeq ($(OSARCH),OpenBSD)
93 AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
94 endif
96 ifeq ($(OSARCH),SunOS)
97 AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
98 ASTLINK=
99 endif
101 editline/libedit.a:
102 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)
103 $(MAKE) -C editline libedit.a
105 db1-ast/libdb1.a:
106 CFLAGS="$(subst $(ASTTOPDIR),../../,$(ASTCFLAGS))" LDFLAGS="$(ASTLDFLAGS)" $(MAKE) -C db1-ast libdb1.a
108 ast_expr2.c ast_expr2.h:
109 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
111 ast_expr2f.c:
112 flex -o $@ --full ast_expr2.fl # moved the correction of yyfree into the flex input file itself.
113 sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' ast_expr2f.c > zz
114 mv zz ast_expr2f.c
116 ast_expr2f.o: ASTCFLAGS+=-Wno-unused
118 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
119 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
120 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
121 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o
122 rm ast_expr2.o ast_expr2f.o
124 channel.o: ASTCFLAGS+=$(ZAPTEL_INCLUDE)
125 asterisk.o: ASTCFLAGS+=$(ZAPTEL_INCLUDE)
127 stdtime/localtime.o: ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW)
129 AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
130 AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
131 AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
132 OBJS:=$(sort $(OBJS))
134 ifneq ($(wildcard ../channels/h323/Makefile.ast),)
135 include ../channels/h323/Makefile.ast
136 else
137 H323LDFLAGS=
138 H323LDLIBS=
139 endif
141 asterisk: $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
142 @$(ASTTOPDIR)/build_tools/make_build_h > $(ASTTOPDIR)/include/asterisk/build.h.tmp
143 @if cmp -s $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; then echo ; else \
144 mv $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; \
146 @rm -f $(ASTTOPDIR)/include/asterisk/build.h.tmp
147 @$(CC) -c -o buildinfo.o $(ASTCFLAGS) buildinfo.c
148 $(ECHO_PREFIX) echo " [LD] $^ -> $@"
149 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
150 $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS)
151 else
152 $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS)
153 endif
154 $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/strip_nonapi $@ || rm $@
156 clean::
157 rm -f asterisk
158 rm -f db1-ast/.*.d
159 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
160 @$(MAKE) -C db1-ast clean
161 @$(MAKE) -C stdtime clean