library.mak 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. include $(SRC_PATH)/common.mak
  2. LIBVERSION := $(lib$(NAME)_VERSION)
  3. LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
  4. LIBMINOR := $(lib$(NAME)_VERSION_MINOR)
  5. INCINSTDIR := $(INCDIR)/lib$(NAME)
  6. INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
  7. all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME)
  8. all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)
  9. $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
  10. $(COMPILE_C)
  11. $(SUBDIR)%-test.o: $(SUBDIR)%.c
  12. $(COMPILE_C)
  13. $(SUBDIR)%-test.i: $(SUBDIR)%-test.c
  14. $(CC) $(CCFLAGS) $(CC_E) $<
  15. $(SUBDIR)%-test.i: $(SUBDIR)%.c
  16. $(CC) $(CCFLAGS) $(CC_E) $<
  17. $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
  18. $(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
  19. $(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<
  20. -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
  21. LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS)
  22. $(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
  23. $(TESTOBJS) $(TESTOBJS:.o=.i): CPPFLAGS += -DTEST
  24. $(SUBDIR)$(LIBNAME): $(OBJS)
  25. $(RM) $@
  26. $(AR) $(ARFLAGS) $(AR_O) $^
  27. $(RANLIB) $@
  28. install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
  29. install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
  30. install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
  31. define RULES
  32. $(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
  33. $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
  34. $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
  35. $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS)
  36. $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
  37. $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
  38. $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver
  39. $(SLIB_CREATE_DEF_CMD)
  40. $$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
  41. $(SLIB_EXTRA_CMD)
  42. ifdef SUBDIR
  43. $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
  44. endif
  45. clean::
  46. $(RM) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
  47. $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
  48. distclean:: clean
  49. $(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
  50. install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
  51. $(Q)mkdir -p "$(SHLIBDIR)"
  52. $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
  53. $$(STRIP) "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
  54. $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),(cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F));)
  55. $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)")
  56. $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
  57. $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
  58. install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
  59. $(Q)mkdir -p "$(LIBDIR)"
  60. $$(INSTALL) -m 644 $$< "$(LIBDIR)"
  61. $(LIB_INSTALL_EXTRA_CMD)
  62. install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
  63. $(Q)mkdir -p "$(INCINSTDIR)"
  64. $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
  65. install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc
  66. $(Q)mkdir -p "$(LIBDIR)/pkgconfig"
  67. $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
  68. uninstall-libs::
  69. -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
  70. "$(SHLIBDIR)/$(SLIBNAME)" \
  71. "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
  72. -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%")
  73. -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%")
  74. -$(RM) "$(LIBDIR)/$(LIBNAME)"
  75. uninstall-headers::
  76. $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS))
  77. $(RM) "$(LIBDIR)/pkgconfig/lib$(FULLNAME).pc"
  78. -rmdir "$(INCINSTDIR)"
  79. endef
  80. $(eval $(RULES))
  81. $(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
  82. $(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME)
  83. testprogs: $(TESTPROGS)