Makefile 1.4 KB

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