Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts.embed_rules $(ASTTOPDIR)/makeopts
  14. all: asterisk
  15. include $(ASTTOPDIR)/Makefile.moddir_rules
  16. OBJS= tcptls.o io.o sched.o logger.o frame.o loader.o config.o channel.o \
  17. translate.o file.o pbx.o cli.o md5.o term.o heap.o \
  18. ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
  19. cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
  20. dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
  21. astmm.o astfd.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
  22. utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
  23. netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
  24. cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
  25. strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o \
  26. astobj2.o hashtab.o global_datastores.o version.o \
  27. features.o taskprocessor.o timing.o datastore.o poll.o ssl.o
  28. # we need to link in the objects statically, not as a library, because
  29. # otherwise modules will not have them available if none of the static
  30. # objects use it.
  31. OBJS+=stdtime/localtime.o
  32. # At the moment say.o is an optional component which can be overridden
  33. # by a module.
  34. OBJS+=say.o
  35. AST_LIBS += $(SSL_LIB)
  36. AST_LIBS += $(BKTR_LIB)
  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. ifneq ($(findstring darwin,$(OSARCH)),)
  49. AST_LIBS+=-lresolv
  50. ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
  51. ASTLINK=-Wl,-dynamic
  52. endif
  53. else
  54. # These are used for all but Darwin
  55. ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
  56. ASTLINK+=-Wl,--export-dynamic
  57. else
  58. ASTLINK+=${GC_LDFLAGS}
  59. endif
  60. ifneq ($(findstring BSD,$(OSARCH)),)
  61. LDFLAGS+=-L/usr/local/lib
  62. endif
  63. endif
  64. ifeq ($(OSARCH),FreeBSD)
  65. # -V is understood by BSD Make, not by GNU make.
  66. BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
  67. AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
  68. AST_LIBS+=-lcrypto
  69. endif
  70. ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
  71. AST_LIBS+=-lminires -ldl
  72. ASTLINK+= -shared -Wl,--out-implib,libasterisk.a
  73. endif
  74. ifeq ($(OSARCH),NetBSD)
  75. AST_LIBS+=-lpthread -lcrypto -lm -L/usr/pkg/lib $(EDITLINE_LIB)
  76. endif
  77. ifeq ($(OSARCH),OpenBSD)
  78. AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
  79. endif
  80. ifeq ($(OSARCH),SunOS)
  81. AST_LIBS+=-lpthread -ldl -lrt -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
  82. ASTLINK=
  83. endif
  84. ifneq ($(findstring USE_HOARD_ALLOCATOR,$(MENUSELECT_CFLAGS)),)
  85. ifneq ($(HOARD_LIB),)
  86. AST_LIBS+=$(HOARD_LIB)
  87. endif
  88. endif
  89. CHECK_SUBDIR: # do nothing, just make sure that we recurse in the subdir/
  90. editline/libedit.a: CHECK_SUBDIR
  91. 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)
  92. $(MAKE) -C editline libedit.a
  93. db1-ast/libdb1.a: CHECK_SUBDIR
  94. _ASTCFLAGS="$(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS) -Wno-strict-aliasing" $(MAKE) -C db1-ast libdb1.a
  95. ifneq ($(findstring REBUILD_PARSERS,$(MENUSELECT_CFLAGS)),)
  96. ast_expr2.c ast_expr2.h: ast_expr2.y
  97. else
  98. ast_expr2.c ast_expr2.h:
  99. endif
  100. $(ECHO_PREFIX) echo " [BISON] $< -> $@"
  101. $(CMD_PREFIX) $(BISON) -o $@ -d --name-prefix=ast_yy ast_expr2.y
  102. ifneq ($(findstring REBUILD_PARSERS,$(MENUSELECT_CFLAGS)),)
  103. ast_expr2f.c: ast_expr2.fl
  104. else
  105. ast_expr2f.c:
  106. endif
  107. $(ECHO_PREFIX) echo " [FLEX] $< -> $@"
  108. $(CMD_PREFIX) $(FLEX) -o $@ ast_expr2.fl
  109. $(CMD_PREFIX) sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' $@ > $@.fix
  110. $(CMD_PREFIX) echo "#include \"asterisk.h\"" > $@
  111. $(CMD_PREFIX) echo >> $@
  112. $(CMD_PREFIX) cat $@.fix >> $@
  113. $(CMD_PREFIX) rm $@.fix
  114. ast_expr2f.o: _ASTCFLAGS+=-Wno-unused
  115. testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
  116. $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
  117. $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
  118. $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm
  119. rm ast_expr2.o ast_expr2f.o
  120. ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
  121. http.o: _ASTCFLAGS+=$(GMIME_INCLUDE)
  122. endif
  123. stdtime/localtime.o: _ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral
  124. AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
  125. AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))
  126. AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep)))
  127. OBJS:=$(sort $(OBJS))
  128. ifneq ($(wildcard ../channels/h323/Makefile.ast),)
  129. include ../channels/h323/Makefile.ast
  130. else
  131. H323LDFLAGS=
  132. H323LDLIBS=
  133. endif
  134. ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
  135. MAIN_TGT:=asterisk.dll
  136. asterisk: cygload
  137. mv cygload.exe asterisk.exe
  138. cygload: asterisk.dll
  139. else
  140. MAIN_TGT:=asterisk
  141. endif
  142. ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
  143. GMIMELDFLAGS+=$(GMIME_LIB)
  144. endif
  145. $(MAIN_TGT): $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
  146. @$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS)
  147. $(ECHO_PREFIX) echo " [LD] $^ -> $@"
  148. ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
  149. $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS)
  150. else
  151. $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS)
  152. endif
  153. $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/strip_nonapi $@ || rm $@
  154. clean::
  155. rm -f asterisk
  156. rm -f db1-ast/.*.d
  157. @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
  158. @$(MAKE) -C db1-ast clean
  159. @$(MAKE) -C stdtime clean
  160. rm -f libresample/src/*.o