Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # libdatachannel
  2. NAME=libdatachannel
  3. CXX=$(CROSS)g++
  4. AR=$(CROSS)ar
  5. RM=rm -f
  6. CPPFLAGS=-O2 -pthread -fPIC -Wall -Wno-address-of-packed-member
  7. CXXFLAGS=-std=c++17
  8. LDFLAGS=-pthread
  9. LIBS=glib-2.0 gobject-2.0 nice
  10. USRSCTP_DIR=usrsctp
  11. USE_GNUTLS ?= 0
  12. ifneq ($(USE_GNUTLS), 0)
  13. CPPFLAGS+= -DUSE_GNUTLS=1
  14. LIBS+= gnutls
  15. else
  16. CPPFLAGS+= -DUSE_GNUTLS=0
  17. LIBS+= openssl
  18. endif
  19. LDLIBS= $(shell pkg-config --libs $(LIBS))
  20. INCLUDES=-Iinclude/rtc -I$(USRSCTP_DIR)/usrsctplib $(shell pkg-config --cflags $(LIBS))
  21. SRCS=$(shell printf "%s " src/*.cpp)
  22. OBJS=$(subst .cpp,.o,$(SRCS))
  23. all: $(NAME).a $(NAME).so tests
  24. src/%.o: src/%.cpp
  25. $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -MMD -MP -o $@ -c $<
  26. test/%.o: test/%.cpp
  27. $(CXX) $(CXXFLAGS) $(CPPFLAGS) -Iinclude -MMD -MP -o $@ -c $<
  28. -include $(subst .cpp,.d,$(SRCS))
  29. $(NAME).a: $(OBJS)
  30. $(AR) crf $@ $(OBJS)
  31. $(NAME).so: libusrsctp.a $(OBJS)
  32. $(CXX) $(LDFLAGS) -shared -o $@ $(OBJS) $(LDLIBS) libusrsctp.a
  33. tests: $(NAME).a test/main.o
  34. $(CXX) $(LDFLAGS) -o $@ test/main.o $(LDLIBS) $(NAME).a libusrsctp.a
  35. clean:
  36. -$(RM) include/rtc/*.d *.d
  37. -$(RM) src/*.o src/*.d
  38. -$(RM) test/*.o test/*.d
  39. dist-clean: clean
  40. -$(RM) $(NAME).a
  41. -$(RM) $(NAME).so
  42. -$(RM) libusrsctp.a
  43. -$(RM) tests
  44. -$(RM) include/*~
  45. -$(RM) src/*~
  46. -$(RM) test/*~
  47. -cd $(USRSCTP_DIR) && make clean
  48. libusrsctp.a:
  49. cd $(USRSCTP_DIR) && \
  50. ./bootstrap && \
  51. ./configure --enable-static --disable-debug CFLAGS="$(CPPFLAGS)" && \
  52. make
  53. cp $(USRSCTP_DIR)/usrsctplib/.libs/libusrsctp.a .