| 1 | # |
|---|
| 2 | # Asterisk -- A telephony toolkit for Linux. |
|---|
| 3 | # |
|---|
| 4 | # Makefile to build main Asterisk binary |
|---|
| 5 | # |
|---|
| 6 | # Copyright (C) 1999-2006, Digium, Inc. |
|---|
| 7 | # |
|---|
| 8 | # Mark Spencer <markster@digium.com> |
|---|
| 9 | # |
|---|
| 10 | # This program is free software, distributed under the terms of |
|---|
| 11 | # the GNU General Public License |
|---|
| 12 | # |
|---|
| 13 | |
|---|
| 14 | -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts.embed_rules $(ASTTOPDIR)/makeopts |
|---|
| 15 | |
|---|
| 16 | all: asterisk |
|---|
| 17 | |
|---|
| 18 | include $(ASTTOPDIR)/Makefile.moddir_rules |
|---|
| 19 | |
|---|
| 20 | # Must include the extra ast_expr2.c, ast_expr2f.c, in case they need to be regenerated (because to force regeneration, we delete them) |
|---|
| 21 | SRC=$(wildcard *.c) ast_expr2.c ast_expr2f.c |
|---|
| 22 | OBJSFILTER=fskmodem_int.o fskmodem_float.o cygload.o buildinfo.o |
|---|
| 23 | OBJS=$(filter-out $(OBJSFILTER),$(SRC:.c=.o)) |
|---|
| 24 | |
|---|
| 25 | # we need to link in the objects statically, not as a library, because |
|---|
| 26 | # otherwise modules will not have them available if none of the static |
|---|
| 27 | # objects use it. |
|---|
| 28 | OBJS+=stdtime/localtime.o |
|---|
| 29 | ifneq ($(firstword $(subst :, ,$(WEAKREF))),1) |
|---|
| 30 | OBJS+=../res/res_adsi.o |
|---|
| 31 | endif |
|---|
| 32 | |
|---|
| 33 | AST_LIBS += $(OPENSSL_LIB) |
|---|
| 34 | AST_LIBS += $(BKTR_LIB) |
|---|
| 35 | AST_LIBS += $(LIBXML2_LIB) |
|---|
| 36 | |
|---|
| 37 | ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-gnueabi ),) |
|---|
| 38 | ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) |
|---|
| 39 | AST_LIBS+=-ldl |
|---|
| 40 | endif |
|---|
| 41 | ifneq (x$(CAP_LIB),x) |
|---|
| 42 | AST_LIBS+=$(CAP_LIB) |
|---|
| 43 | endif |
|---|
| 44 | AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv |
|---|
| 45 | else |
|---|
| 46 | AST_LIBS+=$(EDITLINE_LIB) -lm |
|---|
| 47 | endif |
|---|
| 48 | |
|---|
| 49 | ifneq ($(findstring BETTER_BACKTRACES,$(MENUSELECT_CFLAGS)),) |
|---|
| 50 | AST_LIBS+=$(BFD_LIB) |
|---|
| 51 | endif |
|---|
| 52 | |
|---|
| 53 | ifneq ($(findstring darwin,$(OSARCH)),) |
|---|
| 54 | AST_LIBS+=-lresolv |
|---|
| 55 | ASTLINK=-Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace |
|---|
| 56 | ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6) |
|---|
| 57 | ASTLINK+=/usr/lib/bundle1.o |
|---|
| 58 | endif |
|---|
| 59 | else |
|---|
| 60 | # These are used for all but Darwin |
|---|
| 61 | ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) |
|---|
| 62 | ASTLINK+=-Wl,--export-dynamic |
|---|
| 63 | else |
|---|
| 64 | ASTLINK+=${GC_LDFLAGS} |
|---|
| 65 | endif |
|---|
| 66 | ifneq ($(findstring BSD,$(OSARCH)),) |
|---|
| 67 | LDFLAGS+=-L/usr/local/lib |
|---|
| 68 | endif |
|---|
| 69 | endif |
|---|
| 70 | |
|---|
| 71 | ifeq ($(OSARCH),FreeBSD) |
|---|
| 72 | # -V is understood by BSD Make, not by GNU make. |
|---|
| 73 | BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk) |
|---|
| 74 | AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi) |
|---|
| 75 | AST_LIBS+=-lcrypto |
|---|
| 76 | endif |
|---|
| 77 | |
|---|
| 78 | ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) |
|---|
| 79 | AST_LIBS+=-lminires -ldl |
|---|
| 80 | ASTLINK+= -shared -Wl,--out-implib,libasterisk.a |
|---|
| 81 | endif |
|---|
| 82 | ifeq ($(OSARCH),NetBSD) |
|---|
| 83 | AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB) |
|---|
| 84 | endif |
|---|
| 85 | |
|---|
| 86 | ifeq ($(OSARCH),OpenBSD) |
|---|
| 87 | AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB) |
|---|
| 88 | endif |
|---|
| 89 | |
|---|
| 90 | ifeq ($(OSARCH),SunOS) |
|---|
| 91 | AST_LIBS+=-lpthread -ldl -lrt -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib |
|---|
| 92 | ASTLINK= |
|---|
| 93 | endif |
|---|
| 94 | |
|---|
| 95 | ifneq ($(findstring USE_HOARD_ALLOCATOR,$(MENUSELECT_CFLAGS)),) |
|---|
| 96 | ifneq ($(HOARD_LIB),) |
|---|
| 97 | AST_LIBS+=$(HOARD_LIB) |
|---|
| 98 | endif |
|---|
| 99 | endif |
|---|
| 100 | |
|---|
| 101 | ifeq ($(GNU_LD),1) |
|---|
| 102 | ASTLINK+=-Wl,--version-script,asterisk.exports |
|---|
| 103 | ifeq ($(HAVE_DYNAMIC_LIST),1) |
|---|
| 104 | ASTLINK+=-Wl,--dynamic-list,asterisk.dynamics |
|---|
| 105 | endif |
|---|
| 106 | endif |
|---|
| 107 | |
|---|
| 108 | CHECK_SUBDIR: # do nothing, just make sure that we recurse in the subdir/ |
|---|
| 109 | |
|---|
| 110 | editline/libedit.a: CHECK_SUBDIR |
|---|
| 111 | cd editline && test -f config.h || CFLAGS="$(PTHREAD_CFLAGS) $(subst $(ASTTOPDIR),../../,$(_ASTCFLAGS:-Werror=) $(ASTCFLAGS))" LDFLAGS="$(_ASTLDFLAGS) $(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 |
|---|
| 113 | |
|---|
| 114 | db1-ast/libdb1.a: CHECK_SUBDIR |
|---|
| 115 | _ASTCFLAGS="$(_ASTCFLAGS) -Wno-strict-aliasing" ASTCFLAGS="$(ASTCFLAGS)" $(MAKE) -C db1-ast libdb1.a |
|---|
| 116 | |
|---|
| 117 | ifneq ($(findstring REBUILD_PARSERS,$(MENUSELECT_CFLAGS)),) |
|---|
| 118 | ast_expr2.c ast_expr2.h: ast_expr2.y |
|---|
| 119 | else |
|---|
| 120 | ast_expr2.c ast_expr2.h: |
|---|
| 121 | endif |
|---|
| 122 | $(ECHO_PREFIX) echo " [BISON] $< -> $@" |
|---|
| 123 | $(CMD_PREFIX) $(BISON) -o $@ -d --name-prefix=ast_yy ast_expr2.y |
|---|
| 124 | |
|---|
| 125 | ifneq ($(findstring REBUILD_PARSERS,$(MENUSELECT_CFLAGS)),) |
|---|
| 126 | ast_expr2f.c: ast_expr2.fl |
|---|
| 127 | else |
|---|
| 128 | ast_expr2f.c: |
|---|
| 129 | endif |
|---|
| 130 | $(ECHO_PREFIX) echo " [FLEX] $< -> $@" |
|---|
| 131 | $(CMD_PREFIX) $(FLEX) -o $@ ast_expr2.fl |
|---|
| 132 | $(CMD_PREFIX) sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' $@ > $@.fix |
|---|
| 133 | $(CMD_PREFIX) echo "#include \"asterisk.h\"" > $@ |
|---|
| 134 | $(CMD_PREFIX) echo >> $@ |
|---|
| 135 | $(CMD_PREFIX) cat $@.fix >> $@ |
|---|
| 136 | $(CMD_PREFIX) rm $@.fix |
|---|
| 137 | |
|---|
| 138 | ast_expr2f.o: _ASTCFLAGS+=-Wno-unused |
|---|
| 139 | |
|---|
| 140 | testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h |
|---|
| 141 | $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c |
|---|
| 142 | $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c |
|---|
| 143 | $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm |
|---|
| 144 | rm ast_expr2.o ast_expr2f.o |
|---|
| 145 | |
|---|
| 146 | ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),) |
|---|
| 147 | http.o: _ASTCFLAGS+=$(GMIME_INCLUDE) |
|---|
| 148 | endif |
|---|
| 149 | |
|---|
| 150 | stdtime/localtime.o: _ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral |
|---|
| 151 | |
|---|
| 152 | AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS)) |
|---|
| 153 | AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep))) |
|---|
| 154 | AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep))) |
|---|
| 155 | OBJS:=$(sort $(OBJS)) |
|---|
| 156 | |
|---|
| 157 | ifneq ($(wildcard ../channels/h323/Makefile.ast),) |
|---|
| 158 | include ../channels/h323/Makefile.ast |
|---|
| 159 | else |
|---|
| 160 | H323LDFLAGS= |
|---|
| 161 | H323LDLIBS= |
|---|
| 162 | endif |
|---|
| 163 | |
|---|
| 164 | ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) |
|---|
| 165 | MAIN_TGT:=asterisk.dll |
|---|
| 166 | asterisk: cygload |
|---|
| 167 | mv cygload.exe asterisk.exe |
|---|
| 168 | |
|---|
| 169 | cygload: asterisk.dll |
|---|
| 170 | else |
|---|
| 171 | MAIN_TGT:=asterisk |
|---|
| 172 | endif |
|---|
| 173 | |
|---|
| 174 | ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),) |
|---|
| 175 | GMIMELDFLAGS+=$(GMIME_LIB) |
|---|
| 176 | endif |
|---|
| 177 | |
|---|
| 178 | $(OBJS): _ASTCFLAGS+=-DAST_MODULE=\"core\" |
|---|
| 179 | |
|---|
| 180 | $(MAIN_TGT): $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) |
|---|
| 181 | @$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS) |
|---|
| 182 | $(ECHO_PREFIX) echo " [LD] $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) -> $@" |
|---|
| 183 | ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),) |
|---|
| 184 | $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS) |
|---|
| 185 | else |
|---|
| 186 | $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS) |
|---|
| 187 | endif |
|---|
| 188 | |
|---|
| 189 | ifeq ($(GNU_LD),1) |
|---|
| 190 | $(MAIN_TGT): asterisk.exports |
|---|
| 191 | asterisk.exports: asterisk.exports.in |
|---|
| 192 | $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/make_linker_version_script asterisk $(LINKER_SYMBOL_PREFIX) |
|---|
| 193 | endif |
|---|
| 194 | |
|---|
| 195 | clean:: |
|---|
| 196 | rm -f asterisk |
|---|
| 197 | rm -f db1-ast/.*.d |
|---|
| 198 | rm -f asterisk.exports |
|---|
| 199 | @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi |
|---|
| 200 | @$(MAKE) -C db1-ast clean |
|---|
| 201 | @$(MAKE) -C stdtime clean |
|---|
| 202 | rm -f libresample/src/*.o |
|---|