You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.4KB

  1. #
  2. # common bits used by all libraries
  3. #
  4. SRC_DIR = $(SRC_PATH)/lib$(NAME)
  5. VPATH = $(SRC_DIR)
  6. SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
  7. OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
  8. STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
  9. SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
  10. EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
  11. all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
  12. $(LIB): $(STATIC_OBJS)
  13. rm -f $@
  14. $(AR) rc $@ $^ $(EXTRAOBJS)
  15. $(RANLIB) $@
  16. $(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
  17. ln -sf $^ $@
  18. $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
  19. $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
  20. $(SLIB_EXTRA_CMD)
  21. %.o: %.c
  22. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  23. %.o: %.S
  24. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  25. # BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
  26. %.o: %.cpp
  27. g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
  28. %: %.o $(LIB)
  29. $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
  30. depend dep: $(SRCS)
  31. $(CC) -MM $(CFLAGS) $^ 1>.depend
  32. clean::
  33. rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
  34. *.lib *.def *.dll.a *.exp
  35. distclean: clean
  36. rm -f .depend
  37. ifeq ($(BUILD_SHARED),yes)
  38. INSTLIBTARGETS += install-lib-shared
  39. endif
  40. ifeq ($(BUILD_STATIC),yes)
  41. INSTLIBTARGETS += install-lib-static
  42. endif
  43. install: install-libs install-headers
  44. install-libs: $(INSTLIBTARGETS)
  45. install-lib-shared: $(SLIBNAME)
  46. install -d "$(shlibdir)"
  47. install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
  48. "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
  49. cd "$(shlibdir)" && \
  50. ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
  51. cd "$(shlibdir)" && \
  52. ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
  53. install-lib-static: $(LIB)
  54. install -d "$(libdir)"
  55. install -m 644 $(LIB) "$(libdir)"
  56. $(LIB_INSTALL_EXTRA_CMD)
  57. install-headers:
  58. install -d "$(incdir)"
  59. install -d "$(libdir)/pkgconfig"
  60. install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
  61. install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
  62. uninstall: uninstall-libs uninstall-headers
  63. uninstall-libs:
  64. -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
  65. "$(shlibdir)/$(SLIBNAME)" \
  66. "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
  67. -rm -f "$(libdir)/$(LIB)"
  68. uninstall-headers:
  69. rm -f $(addprefix "$(incdir)/",$(HEADERS))
  70. rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
  71. .PHONY: all depend dep clean distclean install* uninstall*
  72. #
  73. # include dependency files if they exist
  74. #
  75. ifneq ($(wildcard .depend),)
  76. include .depend
  77. endif