1include $(SRC_PATH)/ffbuild/common.mak 2 3ifeq (,$(filter %clean config,$(MAKECMDGOALS))) 4-include $(SUBDIR)lib$(NAME).version 5endif 6 7LIBVERSION := $(lib$(NAME)_VERSION) 8LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR) 9LIBMINOR := $(lib$(NAME)_VERSION_MINOR) 10INCINSTDIR := $(INCDIR)/lib$(NAME) 11 12INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%) 13 14all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(FULLNAME).pc 15all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(FULLNAME).pc 16 17LIBOBJS := $(OBJS) $(SHLIBOBJS) $(STLIBOBJS) $(SUBDIR)%.h.o $(TESTOBJS) 18$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H 19 20ifdef CONFIG_SHARED 21# In case both shared libs and static libs are enabled, it can happen 22# that a user might want to link e.g. libavformat statically, but 23# libavcodec and the other libs dynamically. In this case 24# libavformat won't be able to access libavcodec's internal symbols, 25# so that they have to be duplicated into the archive just like 26# for purely shared builds. 27# Test programs are always statically linked against their library 28# to be able to access their library's internals, even with shared builds. 29# Yet linking against dependend libraries still uses dynamic linking. 30# This means that we are in the scenario described above. 31# In case only static libs are used, the linker will only use 32# one of these copies; this depends on the duplicated object files 33# containing exactly the same symbols. 34OBJS += $(SHLIBOBJS) 35endif 36$(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS) 37 $(RM) $@ 38 $(AR) $(ARFLAGS) $(AR_O) $^ 39 $(RANLIB) $@ 40 41install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig 42 43install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static 44install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared 45 46define RULES 47$(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB)) 48$(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME) 49 50$(LIBOBJS): CPPFLAGS += -DBUILDING_$(NAME) 51 52$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o 53 $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS) 54 55$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h $(SUBDIR)version_major.h | $(SUBDIR) 56 $$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$^ > $$@ 57 58$(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)version.h ffbuild/config.sh | $(SUBDIR) 59 $$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" 60 61$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) 62 $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ 63 64$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) 65 $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME) 66 67$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SHLIBOBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver 68 $(SLIB_CREATE_DEF_CMD) 69 $$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS) 70 $(SLIB_EXTRA_CMD) 71 72ifdef SUBDIR 73$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS) 74endif 75 76clean:: 77 $(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \ 78 $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%) 79 80install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME) 81 $(Q)mkdir -p "$(SHLIBDIR)" 82 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)" 83 $$(STRIP) "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)" 84 $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),(cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F));) 85 $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)") 86 $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)") 87 $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)") 88 89install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME) 90 $(Q)mkdir -p "$(LIBDIR)" 91 $$(INSTALL) -m 644 $$< "$(LIBDIR)" 92 $(LIB_INSTALL_EXTRA_CMD) 93 94install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS)) 95 $(Q)mkdir -p "$(INCINSTDIR)" 96 $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)" 97 98install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc 99 $(Q)mkdir -p "$(PKGCONFIGDIR)" 100 $$(INSTALL) -m 644 $$^ "$(PKGCONFIGDIR)" 101 102uninstall-libs:: 103 -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \ 104 "$(SHLIBDIR)/$(SLIBNAME)" \ 105 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)" 106 -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%") 107 -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%") 108 -$(RM) "$(LIBDIR)/$(LIBNAME)" 109 110uninstall-headers:: 111 $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS)) 112 -rmdir "$(INCINSTDIR)" 113 114uninstall-pkgconfig:: 115 $(RM) "$(PKGCONFIGDIR)/lib$(FULLNAME).pc" 116endef 117 118$(eval $(RULES)) 119 120$(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME) 121$(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME) 122 123testprogs: $(TESTPROGS) 124