Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. include ../../build.mak
  2. include ../../version.mak
  3. include $(PJDIR)/build/common.mak
  4. export LIBDIR := ../lib
  5. export BINDIR := ../bin
  6. RULES_MAK := $(PJDIR)/build/rules.mak
  7. export PJLIB_LIB := libpj-$(TARGET_NAME)$(LIBEXT)
  8. ifeq ($(PJ_SHARED_LIBRARIES),)
  9. else
  10. export PJLIB_SONAME := libpj.$(SHLIB_SUFFIX)
  11. export PJLIB_SHLIB := $(PJLIB_SONAME).$(PJ_VERSION_MAJOR)
  12. endif
  13. ###############################################################################
  14. # Gather all flags.
  15. #
  16. export _CFLAGS := $(CC_CFLAGS) $(OS_CFLAGS) $(HOST_CFLAGS) $(M_CFLAGS) \
  17. $(CFLAGS) $(CC_INC)../include
  18. export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
  19. $(HOST_CXXFLAGS) $(CXXFLAGS)
  20. export _LDFLAGS := $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
  21. $(APP_LDFLAGS) $(LDFLAGS)
  22. ###############################################################################
  23. # Defines for building PJLIB library
  24. #
  25. export PJLIB_SRCDIR = ../src/pj
  26. export PJLIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
  27. activesock.o array.o config.o ctype.o errno.o except.o fifobuf.o \
  28. guid.o hash.o ip_helper_generic.o list.o lock.o log.o os_time_common.o \
  29. os_info.o pool.o pool_buf.o pool_caching.o pool_dbg.o rand.o \
  30. rbtree.o sock_common.o sock_qos_common.o \
  31. ssl_sock_common.o ssl_sock_ossl.o ssl_sock_gtls.o ssl_sock_dump.o \
  32. ssl_sock_darwin.o string.o timer.o types.o unittest.o
  33. export PJLIB_CFLAGS += $(_CFLAGS)
  34. export PJLIB_CXXFLAGS += $(_CXXFLAGS)
  35. export PJLIB_LDFLAGS += $(_LDFLAGS)
  36. ###############################################################################
  37. # Defines for building test application
  38. #
  39. export TEST_SRCDIR = ../src/pjlib-test
  40. export TEST_OBJS += activesock.o atomic.o echo_clt.o errno.o exception.o \
  41. fifobuf.o file.o hash_test.o ioq_perf.o ioq_udp.o \
  42. ioq_stress_test.o ioq_unreg.o ioq_tcp.o \
  43. list.o mutex.o os.o pool.o pool_perf.o rand.o rbtree.o \
  44. select.o sleep.o sock.o sock_perf.o ssl_sock.o \
  45. string.o test.o thread.o timer.o timestamp.o \
  46. udp_echo_srv_sync.o udp_echo_srv_ioqueue.o \
  47. unittest_test.o util.o
  48. export TEST_CFLAGS += $(_CFLAGS)
  49. export TEST_CXXFLAGS += $(_CXXFLAGS)
  50. export TEST_LDFLAGS += $(PJLIB_LDLIB) $(_LDFLAGS)
  51. ifeq ($(EXCLUDE_APP),0)
  52. export TEST_EXE := pjlib-test-$(TARGET_NAME)$(HOST_EXE)
  53. endif
  54. export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
  55. ###############################################################################
  56. # Main entry
  57. #
  58. # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
  59. #
  60. all: $(TARGETS) $(TARGETS_EXE)
  61. lib: $(TARGETS)
  62. doc:
  63. cd .. && rm -rf docs/$(PJ_VERSION) && doxygen docs/doxygen.cfg
  64. @if [ -n "$(WWWDIR)" ] && ! [ -d "$(WWWDIR)/docs/$(PJ_VERSION)/pjlib/docs/html" ] ; then \
  65. echo "Creating docs/$(PJ_VERSION)/pjlib/docs/html" ; \
  66. mkdir -p $(WWWDIR)/docs/$(PJ_VERSION)/pjlib/docs/html ; \
  67. fi
  68. @if [ -n "$(WWWDIR)" ] && [ -d "$(WWWDIR)/docs/$(PJ_VERSION)/pjlib/docs/html" ] ; then \
  69. echo "Copying docs/$(PJ_VERSION) to $(WWWDIR)/docs/$(PJ_VERSION)/pjlib/docs/html.." ; \
  70. cp -v -a ../docs/$(PJ_VERSION)/html/* $(WWWDIR)/docs/$(PJ_VERSION)/pjlib/docs/html/ ; \
  71. fi
  72. print:
  73. $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib print_lib
  74. $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test print_bin
  75. depend: ../include/pj/config_site.h
  76. $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib depend
  77. $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test depend
  78. echo '$(BINDIR)/$(TEST_EXE): $(LIBDIR)/$(PJLIB_LIB)' >> .pjlib-test-$(TARGET_NAME).depend
  79. .PHONY: all dep depend clean realclean distclean
  80. .PHONY: $(TARGETS)
  81. .PHONY: $(PJLIB_LIB) $(PJLIB_SONAME)
  82. .PHONY: $(TEST_EXE)
  83. dep: depend
  84. pjlib: $(PJLIB_LIB)
  85. $(PJLIB_LIB): ../include/pj/config_site.h
  86. $(PJLIB_SONAME): $(PJLIB_LIB)
  87. $(PJLIB_LIB) $(PJLIB_SONAME):
  88. $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  89. ../include/pj/config_site.h:
  90. touch ../include/pj/config_site.h
  91. pjlib-test: $(TEST_EXE)
  92. $(TEST_EXE): $(PJLIB_LIB) $(PJLIB_SONAME)
  93. $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
  94. .PHONY: pjlib.ko
  95. pjlib.ko:
  96. echo Making $@
  97. $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  98. .PHONY: pjlib-test.ko
  99. pjlib-test.ko:
  100. $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  101. clean:
  102. $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib clean
  103. $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test clean
  104. realclean:
  105. $(subst @@,$(subst /,$(HOST_PSEP),.pjlib-$(TARGET_NAME).depend),$(HOST_RMR))
  106. $(subst @@,$(subst /,$(HOST_PSEP),.pjlib-test-$(TARGET_NAME).depend),$(HOST_RMR))
  107. $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib realclean
  108. $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test realclean
  109. distclean: realclean
  110. gcov-report:
  111. $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib gcov-report
  112. $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test gcov-report