Minor formatting change to test a mantis change ...
[asterisk-bristuff.git] / main / Makefile
blob99a4df54bf6bc44fcf1214210995e4fccc23b333
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 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 \
33 features.o taskprocessor.o
35 # we need to link in the objects statically, not as a library, because
36 # otherwise modules will not have them available if none of the static
37 # objects use it.
38 OBJS+=stdtime/localtime.o
40 # At the moment say.o is an optional component which can be overridden
41 # by a module.
42 OBJS+=say.o
44 AST_LIBS += $(SSL_LIB)
45 AST_LIBS += $(BKTR_LIB)
47 ifeq ($(POLL_AVAILABLE),)
48 OBJS+=poll.o
49 endif
51 ifeq ($(wildcard /usr/include/dlfcn.h),)
52 OBJS+=dlfcn.o
53 endif
55 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-gnueabi ),)
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 # -V is understood by BSD Make, not by GNU make.
86 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
87 AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
88 AST_LIBS+=-lcrypto
89 endif
91 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
92 AST_LIBS+=-lminires -ldl
93 ASTLINK+= -shared -Wl,--out-implib,libasterisk.a
94 endif
95 ifeq ($(OSARCH),NetBSD)
96 AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
97 endif
99 ifeq ($(OSARCH),OpenBSD)
100 AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
101 endif
103 ifeq ($(OSARCH),SunOS)
104 AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
105 ASTLINK=
106 endif
108 CHECK_SUBDIR: # do nothing, just make sure that we recurse in the subdir/
110 editline/libedit.a: CHECK_SUBDIR
111 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)
112 $(MAKE) -C editline libedit.a
114 db1-ast/libdb1.a: CHECK_SUBDIR
115 CFLAGS="$(subst $(ASTTOPDIR),../../,$(ASTCFLAGS))" LDFLAGS="$(ASTLDFLAGS)" $(MAKE) -C db1-ast libdb1.a
117 ast_expr2.c ast_expr2.h:
118 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
120 ast_expr2f.c:
121 flex -o $@ --full ast_expr2.fl # moved the correction of yyfree into the flex input file itself.
122 sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' ast_expr2f.c > zz
123 mv zz ast_expr2f.c
125 ast_expr2f.o: ASTCFLAGS+=-Wno-unused
127 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
128 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
129 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
130 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm
131 rm ast_expr2.o ast_expr2f.o
133 channel.o: ASTCFLAGS+=$(ZAPTEL_INCLUDE)
134 asterisk.o: ASTCFLAGS+=$(ZAPTEL_INCLUDE)
137 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
138 http.o: ASTCFLAGS+=$(GMIME_INCLUDE)
139 endif
141 stdtime/localtime.o: ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW)
143 AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
144 AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
145 AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
146 OBJS:=$(sort $(OBJS))
148 ifneq ($(wildcard ../channels/h323/Makefile.ast),)
149 include ../channels/h323/Makefile.ast
150 else
151 H323LDFLAGS=
152 H323LDLIBS=
153 endif
155 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
156 MAIN_TGT:=asterisk.dll
157 asterisk: cygload
158 mv cygload.exe asterisk.exe
160 cygload: asterisk.dll
161 else
162 MAIN_TGT:=asterisk
163 endif
165 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
166 GMIMELDFLAGS+=$(GMIME_LIB)
167 endif
169 $(MAIN_TGT): $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
170 @$(CC) -c -o buildinfo.o $(ASTCFLAGS) buildinfo.c
171 $(ECHO_PREFIX) echo " [LD] $^ -> $@"
172 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
173 $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS)
174 else
175 $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS)
176 endif
177 $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/strip_nonapi $@ || rm $@
179 clean::
180 rm -f asterisk
181 rm -f db1-ast/.*.d
182 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
183 @$(MAKE) -C db1-ast clean
184 @$(MAKE) -C stdtime clean
185 rm -f libresample/src/*.o