2
0

Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # libdatachannel
  2. NAME=libdatachannel
  3. CXX=$(CROSS)g++
  4. AR=$(CROSS)ar
  5. RM=rm -f
  6. CXXFLAGS=-std=c++17
  7. CPPFLAGS=-O2 -pthread -fPIC -Wall
  8. LDFLAGS=-pthread
  9. LIBS=
  10. LOCALLIBS=libusrsctp.a
  11. USRSCTP_DIR=deps/usrsctp
  12. JUICE_DIR=deps/libjuice
  13. PLOG_DIR=deps/plog
  14. INCLUDES=-Iinclude/rtc -I$(PLOG_DIR)/include -I$(USRSCTP_DIR)/usrsctplib
  15. LDLIBS=
  16. USE_GNUTLS ?= 0
  17. ifneq ($(USE_GNUTLS), 0)
  18. CPPFLAGS+=-DUSE_GNUTLS=1
  19. LIBS+=gnutls
  20. else
  21. CPPFLAGS+=-DUSE_GNUTLS=0
  22. LIBS+=openssl
  23. endif
  24. USE_NICE ?= 0
  25. ifneq ($(USE_NICE), 0)
  26. CPPFLAGS+=-DUSE_NICE=1
  27. LIBS+=glib-2.0 gobject-2.0 nice
  28. else
  29. CPPFLAGS+=-DUSE_NICE=0
  30. INCLUDES+=-I$(JUICE_DIR)/include
  31. LOCALLIBS+=libjuice.a
  32. ifneq ($(USE_GNUTLS), 0)
  33. LIBS+=nettle
  34. endif
  35. endif
  36. USE_SRTP ?= 0
  37. ifneq ($(USE_SRTP), 0)
  38. CPPFLAGS+=-DRTC_ENABLE_MEDIA=1
  39. LIBS+=srtp
  40. else
  41. CPPFLAGS+=-DRTC_ENABLE_MEDIA=0
  42. endif
  43. NO_WEBSOCKET ?= 0
  44. ifeq ($(NO_WEBSOCKET), 0)
  45. CPPFLAGS+=-DRTC_ENABLE_WEBSOCKET=1
  46. else
  47. CPPFLAGS+=-DRTC_ENABLE_WEBSOCKET=0
  48. endif
  49. INCLUDES+=$(shell pkg-config --cflags $(LIBS))
  50. LDLIBS+=$(LOCALLIBS) $(shell pkg-config --libs $(LIBS))
  51. SRCS=$(shell printf "%s " src/*.cpp)
  52. OBJS=$(subst .cpp,.o,$(SRCS))
  53. TEST_SRCS=$(shell printf "%s " test/*.cpp)
  54. TEST_OBJS=$(subst .cpp,.o,$(TEST_SRCS))
  55. all: $(NAME).a $(NAME).so tests
  56. src/%.o: src/%.cpp
  57. $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -MMD -MP -o $@ -c $<
  58. test/%.o: test/%.cpp
  59. $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -Iinclude -Isrc -MMD -MP -o $@ -c $<
  60. -include $(subst .cpp,.d,$(SRCS))
  61. $(NAME).a: $(OBJS)
  62. $(AR) crf $@ $(OBJS)
  63. $(NAME).so: $(LOCALLIBS) $(OBJS)
  64. $(CXX) $(LDFLAGS) -shared -o $@ $(OBJS) $(LDLIBS)
  65. tests: $(NAME).a $(TEST_OBJS)
  66. $(CXX) $(LDFLAGS) -o $@ $(TEST_OBJS) $(NAME).a $(LDLIBS)
  67. clean:
  68. -$(RM) include/rtc/*.d *.d
  69. -$(RM) src/*.o src/*.d
  70. -$(RM) test/*.o test/*.d
  71. dist-clean: clean
  72. -$(RM) $(NAME).a
  73. -$(RM) $(NAME).so
  74. -$(RM) libusrsctp.a
  75. -$(RM) libjuice.a
  76. -$(RM) tests
  77. -$(RM) include/*~
  78. -$(RM) src/*~
  79. -$(RM) test/*~
  80. -cd $(USRSCTP_DIR) && make clean
  81. -cd $(JUICE_DIR) && make clean
  82. libusrsctp.a:
  83. cd $(USRSCTP_DIR) && \
  84. ./bootstrap && \
  85. ./configure --enable-static --disable-debug CFLAGS="$(CPPFLAGS) -Wno-error=format-truncation" && \
  86. make
  87. cp $(USRSCTP_DIR)/usrsctplib/.libs/libusrsctp.a .
  88. libjuice.a:
  89. ifneq ($(USE_GNUTLS), 0)
  90. cd $(JUICE_DIR) && make USE_NETTLE=1
  91. else
  92. cd $(JUICE_DIR) && make USE_NETTLE=0
  93. endif
  94. cp $(JUICE_DIR)/libjuice.a .