Makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. LDLIBS= -lgnutls $(shell pkg-config --libs glib-2.0 gobject-2.0 nice)
  10. INCLUDES=-Iinclude/rtc -I$(USRSCTP_DIR)/usrsctplib $(shell pkg-config --cflags glib-2.0 gobject-2.0 nice)
  11. USRSCTP_DIR:=usrsctp
  12. SRCS=$(shell printf "%s " src/*.cpp)
  13. OBJS=$(subst .cpp,.o,$(SRCS))
  14. all: $(NAME).a $(NAME).so tests
  15. src/%.o: src/%.cpp
  16. $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -MMD -MP -o $@ -c $<
  17. test/%.o: test/%.cpp
  18. $(CXX) $(CXXFLAGS) $(CPPFLAGS) -Iinclude -MMD -MP -o $@ -c $<
  19. -include $(subst .cpp,.d,$(SRCS))
  20. $(NAME).a: $(OBJS)
  21. $(AR) crf $@ $(OBJS)
  22. $(NAME).so: libusrsctp.a $(OBJS)
  23. $(CXX) $(LDFLAGS) -shared -o $@ $(OBJS) $(LDLIBS) libusrsctp.a
  24. tests: $(NAME).a test/main.o
  25. $(CXX) $(LDFLAGS) -o $@ test/main.o $(LDLIBS) $(NAME).a libusrsctp.a
  26. clean:
  27. -$(RM) include/rtc/*.d *.d
  28. -$(RM) src/*.o src/*.d
  29. -$(RM) test/*.o test/*.d
  30. dist-clean: clean
  31. -$(RM) $(NAME).a
  32. -$(RM) $(NAME).so
  33. -$(RM) libusrsctp.a
  34. -$(RM) tests
  35. -$(RM) include/*~
  36. -$(RM) src/*~
  37. -$(RM) test/*~
  38. -cd $(USRSCTP_DIR) && make clean
  39. libusrsctp.a:
  40. cd $(USRSCTP_DIR) && \
  41. ./bootstrap && \
  42. ./configure --enable-static --disable-debug CFLAGS="$(CPPFLAGS)" && \
  43. make
  44. cp $(USRSCTP_DIR)/usrsctplib/.libs/libusrsctp.a .