Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # By default, the test application includes main.o.
  2. # OS make file may override this with os-specific files
  3. export UTIL_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:=$(PJDIR)/pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
  11. export PJLIB_UTIL_LIB := libpjlib-util-$(TARGET_NAME)$(LIBEXT)
  12. ifeq ($(PJ_SHARED_LIBRARIES),)
  13. else
  14. export PJLIB_UTIL_SONAME := libpjlib-util.$(SHLIB_SUFFIX)
  15. export PJLIB_UTIL_SHLIB := $(PJLIB_UTIL_SONAME).$(PJ_VERSION_MAJOR)
  16. endif
  17. ###############################################################################
  18. # Gather all flags.
  19. #
  20. export _CFLAGS := $(CC_CFLAGS) $(OS_CFLAGS) $(HOST_CFLAGS) $(M_CFLAGS) \
  21. $(CFLAGS) $(CC_INC)../include $(CC_INC)../../pjlib/include
  22. export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
  23. $(HOST_CXXFLAGS) $(CXXFLAGS)
  24. export _LDFLAGS := $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
  25. $(APP_LDFLAGS) $(LDFLAGS)
  26. ###############################################################################
  27. # Defines for building PJLIB-UTIL library
  28. #
  29. export PJLIB_UTIL_SRCDIR = ../src/pjlib-util
  30. export PJLIB_UTIL_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
  31. base64.o cli.o cli_console.o cli_telnet.o crc32.o errno.o dns.o \
  32. dns_dump.o dns_server.o getopt.o hmac_md5.o hmac_sha1.o \
  33. http_client.o json.o md5.o pcap.o resolver.o scanner.o sha1.o \
  34. srv_resolver.o string.o stun_simple.o \
  35. stun_simple_client.o xml.o
  36. export PJLIB_UTIL_CFLAGS += $(_CFLAGS)
  37. export PJLIB_UTIL_CXXFLAGS += $(_CXXFLAGS)
  38. export PJLIB_UTIL_LDFLAGS += $(PJLIB_LDLIB) $(_LDFLAGS)
  39. ###############################################################################
  40. # Defines for building test application
  41. #
  42. export UTIL_TEST_SRCDIR = ../src/pjlib-util-test
  43. export UTIL_TEST_OBJS += xml.o encryption.o stun.o resolver_test.o test.o \
  44. json_test.o http_client.o
  45. export UTIL_TEST_CFLAGS += $(_CFLAGS)
  46. export UTIL_TEST_CXXFLAGS += $(_CXXFLAGS)
  47. export UTIL_TEST_LDFLAGS += $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
  48. ifeq ($(EXCLUDE_APP),0)
  49. export UTIL_TEST_EXE:=pjlib-util-test-$(TARGET_NAME)$(HOST_EXE)
  50. endif
  51. export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
  52. ###############################################################################
  53. # Main entry
  54. TARGETS := $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
  55. TARGETS_EXE := $(UTIL_TEST_EXE)
  56. all: $(TARGETS) $(TARGETS_EXE)
  57. lib: $(TARGETS)
  58. doc:
  59. cd .. && rm -rf docs/$(PJ_VERSION) && doxygen docs/doxygen.cfg
  60. @if [ -n "$(WWWDIR)" ] && ! [ -d "$(WWWDIR)/docs/$(PJ_VERSION)/pjlib-util/docs/html" ] ; then \
  61. echo "Creating docs/$(PJ_VERSION)/pjlib-util/docs/html" ; \
  62. mkdir -p $(WWWDIR)/docs/$(PJ_VERSION)/pjlib-util/docs/html ; \
  63. fi
  64. @if [ -n "$(WWWDIR)" ] && [ -d "$(WWWDIR)/docs/$(PJ_VERSION)/pjlib-util/docs/html" ] ; then \
  65. echo "Copying docs/$(PJ_VERSION) to $(WWWDIR)/docs/$(PJ_VERSION)/pjlib-util/docs/html.." ; \
  66. cp -v -a ../docs/$(PJ_VERSION)/html/* $(WWWDIR)/docs/$(PJ_VERSION)/pjlib-util/docs/html/ ; \
  67. fi
  68. dep: depend
  69. distclean: realclean
  70. .PHONY: all dep depend clean realclean distclean
  71. .PHONY: $(TARGETS)
  72. .PHONY: $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
  73. .PHONY: $(UTIL_TEST_EXE)
  74. pjlib-util: $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
  75. $(PJLIB_UTIL_SONAME): $(PJLIB_UTIL_LIB)
  76. $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME): $(PJLIB_LIB) $(PJLIB_SONAME)
  77. $(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  78. pjlib-util-test: $(UTIL_TEST_EXE)
  79. $(UTIL_TEST_EXE): $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
  80. $(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
  81. .PHONY: pjlib-util.ko
  82. pjlib-util.ko:
  83. echo Making $@
  84. $(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  85. .PHONY: pjlib-util-test.ko
  86. pjlib-util-test.ko:
  87. $(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
  88. clean:
  89. $(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $@
  90. $(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $@
  91. realclean:
  92. $(subst @@,$(subst /,$(HOST_PSEP),.pjlib-util-$(TARGET_NAME).depend),$(HOST_RMR))
  93. $(subst @@,$(subst /,$(HOST_PSEP),.pjlib-util-test-$(TARGET_NAME).depend),$(HOST_RMR))
  94. $(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $@
  95. $(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $@
  96. depend:
  97. $(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $@
  98. $(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $@
  99. echo '$(BINDIR)/$(UTIL_TEST_EXE): $(LIBDIR)/$(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjlib-util-test-$(TARGET_NAME).depend; \