4ba56d8ab7
Since 9e857e1f8a, library.mak generates a
response file containing the list of input object files. This was done
to avoid hitting the 8192 character command line limit on Windows
shells.
However, that particular solution still relies on emitting a
very long `echo` command that gets delegated to a subshell. This means
that, for example, running `make` within problematic shells like Git
Bash could still hit the command line length limit when this `echo` step
is ran. Other MSYS2 shells are not affected, meaning the previous
workaround only helped when running in an MSYS2 environment, but broke
when using Git Bash, e.g. for MSVC. This primarily affected `libavcodec`
due to the sheer volume of files contained within.
To avoid this problem, this commit changes the object emission step to
use GNU make's `file` builtin to write the list of object files. `file`
itself was introduced in GNU Make 4.0, but FFmpeg still supports old
versions--notably Apple's ancient Make 3.81--so for older make versions
that don't support this, the old echo subshell is used. This tradeoff
should be fine since it's trivial to grab a new-enough Make on Windows,
and other platforms that may be stuck with ancient Make versions
shouldn't have nearly as restrictive command line limits.
Signed-off-by: crueter <crueter@eden-emu.dev>
156 lines
5.4 KiB
Makefile
156 lines
5.4 KiB
Makefile
include $(SRC_PATH)/ffbuild/common.mak
|
|
|
|
ifeq (,$(filter %clean config,$(MAKECMDGOALS)))
|
|
-include $(SUBDIR)lib$(NAME).version
|
|
endif
|
|
|
|
LIBVERSION := $(lib$(NAME)_VERSION)
|
|
LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
|
|
LIBMINOR := $(lib$(NAME)_VERSION_MINOR)
|
|
INCINSTDIR := $(INCDIR)/lib$(NAME)
|
|
|
|
INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
|
|
|
|
all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(FULLNAME).pc
|
|
all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(FULLNAME).pc
|
|
|
|
# Make <4.0 does not support the built-in file function;
|
|
# versions that do support it should use it, as it's
|
|
# faster and isn't bound by command line length limits.
|
|
ifeq (4.0,$(firstword $(sort 4.0 $(MAKE_VERSION))))
|
|
HAVE_BUILTIN_FILE := yes
|
|
else
|
|
HAVE_BUILTIN_FILE := no
|
|
endif
|
|
|
|
LIBOBJS := $(OBJS) $(SHLIBOBJS) $(STLIBOBJS) $(SUBDIR)%.h.o $(TESTOBJS)
|
|
$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
|
|
|
|
ifdef CONFIG_SHARED
|
|
# In case both shared libs and static libs are enabled, it can happen
|
|
# that a user might want to link e.g. libavformat statically, but
|
|
# libavcodec and the other libs dynamically. In this case
|
|
# libavformat won't be able to access libavcodec's internal symbols,
|
|
# so that they have to be duplicated into the archive just like
|
|
# for purely shared builds.
|
|
# Test programs are always statically linked against their library
|
|
# to be able to access their library's internals, even with shared builds.
|
|
# Yet linking against dependent libraries still uses dynamic linking.
|
|
# This means that we are in the scenario described above.
|
|
# In case only static libs are used, the linker will only use
|
|
# one of these copies; this depends on the duplicated object files
|
|
# containing exactly the same symbols.
|
|
OBJS += $(SHLIBOBJS)
|
|
endif
|
|
$(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
|
|
$(RM) $@
|
|
ifeq ($(RESPONSE_FILES),yes)
|
|
ifeq ($(HAVE_BUILTIN_FILE),yes)
|
|
$(file >$@.objs,$^)
|
|
else
|
|
$(Q)echo $^ > $@.objs
|
|
endif
|
|
$(AR) $(ARFLAGS) $(AR_O) @$@.objs
|
|
else
|
|
$(AR) $(ARFLAGS) $(AR_O) $^
|
|
endif
|
|
$(RANLIB) $@
|
|
-$(RM) $@.objs
|
|
|
|
install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
|
|
|
|
install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
|
|
install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
|
|
|
|
define RULES
|
|
$(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
|
|
$(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
|
|
|
|
$(NAME)LINK_EXE_ARGS = $(LDFLAGS) $(LDEXEFLAGS)
|
|
$(NAME)LINK_SO_ARGS = $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS)
|
|
$(NAME)LINK_EXTRA = $(FFEXTRALIBS)
|
|
|
|
$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
|
|
$$(call LINK,$$(call $(NAME)LINK_EXE_ARGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $$(call $(NAME)LINK_EXTRA) $$(EXTRALIBS-$$(*F)) $$(ELIBS))
|
|
|
|
$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h $(SUBDIR)version_major.h | $(SUBDIR)
|
|
$$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$^ > $$@
|
|
|
|
$(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)version.h ffbuild/config.sh | $(SUBDIR)
|
|
$$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)"
|
|
|
|
$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS)
|
|
$$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@
|
|
|
|
$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
|
|
$(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
|
|
|
|
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SHLIBOBJS) $(SUBDIR)lib$(NAME).ver
|
|
$(SLIB_CREATE_DEF_CMD)
|
|
ifeq ($(RESPONSE_FILES),yes)
|
|
ifeq ($(HAVE_BUILTIN_FILE),yes)
|
|
$$(file >$$@.objs,$$(filter %.o,$$^))
|
|
else
|
|
$(Q)echo $$(filter %.o,$$^) > $$@.objs
|
|
endif
|
|
|
|
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) @$$@.objs $$(call $(NAME)LINK_EXTRA))
|
|
else
|
|
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) $$(filter %.o,$$^) $$(call $(NAME)LINK_EXTRA))
|
|
endif
|
|
$(SLIB_EXTRA_CMD)
|
|
-$(RM) $$@.objs
|
|
|
|
ifdef SUBDIR
|
|
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
|
|
endif
|
|
|
|
clean::
|
|
$(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
|
|
$(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%)
|
|
|
|
install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
|
|
$(Q)mkdir -p "$(SHLIBDIR)"
|
|
$$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
|
|
$$(STRIP) "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
|
|
$(Q)$(foreach F,$(SLIB_INSTALL_LINKS),(cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F));)
|
|
$(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)")
|
|
$(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
|
|
$(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
|
|
|
|
install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
|
|
$(Q)mkdir -p "$(LIBDIR)"
|
|
$$(INSTALL) -m 644 $$< "$(LIBDIR)"
|
|
$(LIB_INSTALL_EXTRA_CMD)
|
|
|
|
install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
|
|
$(Q)mkdir -p "$(INCINSTDIR)"
|
|
$$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
|
|
|
|
install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc
|
|
$(Q)mkdir -p "$(PKGCONFIGDIR)"
|
|
$$(INSTALL) -m 644 $$^ "$(PKGCONFIGDIR)"
|
|
|
|
uninstall-libs::
|
|
-$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
|
|
"$(SHLIBDIR)/$(SLIBNAME)" \
|
|
"$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
|
|
-$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%")
|
|
-$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%")
|
|
-$(RM) "$(LIBDIR)/$(LIBNAME)"
|
|
|
|
uninstall-headers::
|
|
$(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS))
|
|
-rmdir "$(INCINSTDIR)"
|
|
|
|
uninstall-pkgconfig::
|
|
$(RM) "$(PKGCONFIGDIR)/lib$(FULLNAME).pc"
|
|
endef
|
|
|
|
$(eval $(RULES))
|
|
|
|
$(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
|
|
$(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME)
|
|
|
|
testprogs: $(TESTPROGS)
|