Makefile 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # By default, the test application includes main.o.
  2. # OS make file may override this with os-specific files
  3. export PJNATH_TEST_OBJS = main.o
  4. include ../../build.mak
  5. include ../../version.mak
  6. include $(PJDIR)/build/common.mak
  7. export LIBDIR := ../lib
  8. export BINDIR := ../bin
  9. RULES_MAK := $(PJDIR)/build/rules.mak
  10. PJLIB_LIB:=../../pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
  11. PJLIB_UTIL_LIB:=../../pjlib-util/lib/libpjlib-util-$(TARGET_NAME)$(LIBEXT)
  12. export PJNATH_LIB:=libpjnath-$(TARGET_NAME)$(LIBEXT)
  13. ifeq ($(PJ_SHARED_LIBRARIES),)
  14. else
  15. export PJNATH_SONAME := libpjnath.$(SHLIB_SUFFIX)
  16. export PJNATH_SHLIB := $(PJNATH_SONAME).$(PJ_VERSION_MAJOR)
  17. endif
  18. ###############################################################################
  19. # Gather all flags.
  20. #
  21. export _CFLAGS := $(CC_CFLAGS) $(OS_CFLAGS) $(HOST_CFLAGS) $(M_CFLAGS) \
  22. $(CFLAGS) $(CC_INC)../include $(CC_INC)../../pjlib/include \
  23. $(CC_INC)../../pjlib-util/include
  24. export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
  25. $(HOST_CXXFLAGS) $(CXXFLAGS)
  26. export _LDFLAGS := $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
  27. $(APP_LDFLAGS) $(LDFLAGS)
  28. ###############################################################################
  29. # Defines for building PJNATH library
  30. #
  31. export PJNATH_SRCDIR = ../src/pjnath
  32. export PJNATH_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
  33. errno.o ice_session.o ice_strans.o nat_detect.o stun_auth.o \
  34. stun_msg.o stun_msg_dump.o stun_session.o stun_sock.o \
  35. stun_transaction.o turn_session.o turn_sock.o upnp.o
  36. export PJNATH_CFLAGS += $(_CFLAGS)
  37. export PJNATH_CXXFLAGS += $(_CXXFLAGS)
  38. export PJNATH_LDFLAGS += $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
  39. ###############################################################################
  40. # Defines for building test application
  41. #
  42. export PJNATH_TEST_SRCDIR = ../src/pjnath-test
  43. export PJNATH_TEST_OBJS += ice_test.o stun.o sess_auth.o server.o concur_test.o \
  44. stun_sock_test.o turn_sock_test.o test.o
  45. export PJNATH_TEST_CFLAGS += $(_CFLAGS)
  46. export PJNATH_TEST_CXXFLAGS += $(_CXXFLAGS)
  47. export PJNATH_TEST_LDFLAGS += $(PJNATH_LDLIB) $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
  48. ifeq ($(EXCLUDE_APP),0)
  49. export PJNATH_TEST_EXE:=pjnath-test-$(TARGET_NAME)$(HOST_EXE)
  50. endif
  51. ###############################################################################
  52. # Defines for building TURN client application
  53. #
  54. export PJTURN_CLIENT_SRCDIR = ../src/pjturn-client
  55. export PJTURN_CLIENT_OBJS += client_main.o
  56. export PJTURN_CLIENT_CFLAGS += $(_CFLAGS)
  57. export PJTURN_CLIENT_CXXFLAGS += $(_CXXFLAGS)
  58. export PJTURN_CLIENT_LDFLAGS += $(PJNATH_LDLIB) $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
  59. ifeq ($(EXCLUDE_APP),0)
  60. export PJTURN_CLIENT_EXE:=pjturn-client-$(TARGET_NAME)$(HOST_EXE)
  61. endif
  62. ###############################################################################
  63. # Defines for building TURN server application
  64. #
  65. export PJTURN_SRV_SRCDIR = ../src/pjturn-srv
  66. export PJTURN_SRV_OBJS += allocation.o auth.o listener_udp.o \
  67. listener_tcp.o server.o main.o
  68. export PJTURN_SRV_CFLAGS += $(_CFLAGS)
  69. export PJTURN_SRV_CXXFLAGS += $(_CXXFLAGS)
  70. export PJTURN_SRV_LDFLAGS += $(PJNATH_LDLIB) $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
  71. ifeq ($(EXCLUDE_APP),0)
  72. export PJTURN_SRV_EXE:=pjturn-srv-$(TARGET_NAME)$(HOST_EXE)
  73. endif
  74. export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
  75. ###############################################################################
  76. # Main entry
  77. TARGETS := $(PJNATH_LIB) $(PJNATH_SONAME)
  78. TARGETS_EXE := $(PJNATH_TEST_EXE) $(PJTURN_CLIENT_EXE) $(PJTURN_SRV_EXE)
  79. all: $(TARGETS) $(TARGETS_EXE)
  80. lib: $(TARGETS)
  81. doc:
  82. cd .. && rm -rf docs/$(PJ_VERSION) && doxygen docs/doxygen.cfg
  83. @if [ -n "$(WWWDIR)" ] && ! [ -d "$(WWWDIR)/docs/$(PJ_VERSION)/pjnath/docs/html" ] ; then \
  84. echo "Creating docs/$(PJ_VERSION)/pjnath/docs/html" ; \
  85. mkdir -p $(WWWDIR)/docs/$(PJ_VERSION)/pjnath/docs/html ; \
  86. fi
  87. @if [ -n "$(WWWDIR)" ] && [ -d "$(WWWDIR)/docs/$(PJ_VERSION)/pjnath/docs/html" ] ; then \
  88. echo "Copying docs/$(PJ_VERSION) to $(WWWDIR)/docs/$(PJ_VERSION)/pjnath/docs/html.." ; \
  89. cp -v -a ../docs/$(PJ_VERSION)/html/* $(WWWDIR)/docs/$(PJ_VERSION)/pjnath/docs/html/ ; \
  90. fi
  91. dep: depend
  92. distclean: realclean
  93. .PHONY: all dep depend clean realclean distclean
  94. .PHONY: $(TARGETS)
  95. .PHONY: $(PJNATH_LIB) $(PJNATH_SONAME)
  96. .PHONY: $(PJNATH_TEST_EXE) $(PJTURN_CLIENT_EXE) $(PJTURN_SRV_EXE)
  97. pjnath: $(PJNATH_LIB)
  98. $(PJNATH_SONAME): $(PJNATH_LIB)
  99. $(PJNATH_LIB) $(PJNATH_SONAME): $(PJLIB_LIB) $(PJLIB_SONAME) $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
  100. $(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  101. pjnath-test: $(PJNATH_TEST_EXE)
  102. $(PJNATH_TEST_EXE): $(PJNATH_LIB) $(PJNATH_SONAME)
  103. $(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
  104. pjturn-client: $(PJTURN_CLIENT_EXE)
  105. $(PJTURN_CLIENT_EXE): $(PJNATH_LIB) $(PJNATH_SONAME)
  106. $(MAKE) -f $(RULES_MAK) APP=PJTURN_CLIENT app=pjturn-client $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
  107. pjturn-srv: $(PJTURN_SRV_EXE)
  108. $(PJTURN_SRV_EXE): $(PJNATH_LIB) $(PJNATH_SONAME)
  109. $(MAKE) -f $(RULES_MAK) APP=PJTURN_SRV app=pjturn-srv $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
  110. .PHONY: pjnath.ko
  111. pjnath.ko:
  112. echo Making $@
  113. $(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  114. .PHONY: pjnath-test.ko
  115. pjnath-test.ko:
  116. $(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  117. clean:
  118. $(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $@
  119. $(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $@
  120. $(MAKE) -f $(RULES_MAK) APP=PJTURN_CLIENT app=pjturn-client $@
  121. $(MAKE) -f $(RULES_MAK) APP=PJTURN_SRV app=pjturn-srv $@
  122. realclean:
  123. $(subst @@,$(subst /,$(HOST_PSEP),.pjnath-$(TARGET_NAME).depend),$(HOST_RMR))
  124. $(subst @@,$(subst /,$(HOST_PSEP),.pjnath-test-$(TARGET_NAME).depend),$(HOST_RMR))
  125. $(subst @@,$(subst /,$(HOST_PSEP),.pjturn-client-$(TARGET_NAME).depend),$(HOST_RMR))
  126. $(subst @@,$(subst /,$(HOST_PSEP),.pjturn-srv-$(TARGET_NAME).depend),$(HOST_RMR))
  127. $(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $@
  128. $(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $@
  129. $(MAKE) -f $(RULES_MAK) APP=PJTURN_CLIENT app=pjturn-client $@
  130. $(MAKE) -f $(RULES_MAK) APP=PJTURN_SRV app=pjturn-srv $@
  131. depend:
  132. $(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $@
  133. $(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $@
  134. $(MAKE) -f $(RULES_MAK) APP=PJTURN_CLIENT app=pjturn-client $@
  135. $(MAKE) -f $(RULES_MAK) APP=PJTURN_SRV app=pjturn-srv $@
  136. echo '$(BINDIR)/$(PJNATH_TEST_EXE): $(LIBDIR)/$(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjnath-test-$(TARGET_NAME).depend
  137. echo '$(BINDIR)/$(PJTURN_CLIENT_EXE): $(LIBDIR)/$(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjturn-client-$(TARGET_NAME).depend
  138. echo '$(BINDIR)/$(PJTURN_SRV_EXE): $(LIBDIR)/$(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjturn-srv-$(TARGET_NAME).depend