Makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 -Wno-address-of-packed-member
  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_JUICE ?= 0
  25. ifneq ($(USE_JUICE), 0)
  26. CPPFLAGS+=-DUSE_JUICE=1
  27. INCLUDES+=-I$(JUICE_DIR)/include
  28. LOCALLIBS+=libjuice.a
  29. ifneq ($(USE_GNUTLS), 0)
  30. LIBS+=nettle
  31. endif
  32. else
  33. CPPFLAGS+=-DUSE_JUICE=0
  34. LIBS+=glib-2.0 gobject-2.0 nice
  35. endif
  36. INCLUDES+=$(shell pkg-config --cflags $(LIBS))
  37. LDLIBS+=$(LOCALLIBS) $(shell pkg-config --libs $(LIBS))
  38. SRCS=$(shell printf "%s " src/*.cpp)
  39. OBJS=$(subst .cpp,.o,$(SRCS))
  40. all: $(NAME).a $(NAME).so tests
  41. src/%.o: src/%.cpp
  42. $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -MMD -MP -o $@ -c $<
  43. test/%.o: test/%.cpp
  44. $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -Iinclude -Isrc -MMD -MP -o $@ -c $<
  45. -include $(subst .cpp,.d,$(SRCS))
  46. $(NAME).a: $(OBJS)
  47. $(AR) crf $@ $(OBJS)
  48. $(NAME).so: $(LOCALLIBS) $(OBJS)
  49. $(CXX) $(LDFLAGS) -shared -o $@ $(OBJS) $(LDLIBS)
  50. tests: $(NAME).a test/main.o
  51. $(CXX) $(LDFLAGS) -o $@ test/main.o $(NAME).a $(LDLIBS)
  52. clean:
  53. -$(RM) include/rtc/*.d *.d
  54. -$(RM) src/*.o src/*.d
  55. -$(RM) test/*.o test/*.d
  56. dist-clean: clean
  57. -$(RM) $(NAME).a
  58. -$(RM) $(NAME).so
  59. -$(RM) libusrsctp.a
  60. -$(RM) libjuice.a
  61. -$(RM) tests
  62. -$(RM) include/*~
  63. -$(RM) src/*~
  64. -$(RM) test/*~
  65. -cd $(USRSCTP_DIR) && make clean
  66. -cd $(JUICE_DIR) && make clean
  67. libusrsctp.a:
  68. cd $(USRSCTP_DIR) && \
  69. ./bootstrap && \
  70. ./configure --enable-static --disable-debug CFLAGS="$(CPPFLAGS)" && \
  71. make
  72. cp $(USRSCTP_DIR)/usrsctplib/.libs/libusrsctp.a .
  73. libjuice.a:
  74. ifneq ($(USE_GNUTLS), 0)
  75. cd $(JUICE_DIR) && make USE_NETTLE=1
  76. else
  77. cd $(JUICE_DIR) && make USE_NETTLE=0
  78. endif
  79. cp $(JUICE_DIR)/libjuice.a .