From 1038ae2327d0ce502bc304378afbc69602d686ed Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 11 May 2017 21:17:21 -0400 Subject: [PATCH] Generate .la for internal libav libraries This should help libtool in getting the internal linking right. Effectively, libtool can sometime get the link order wrong when presented with a mix of .la and -l arguments. These .la file are also required by the android build system and were previously created by cerbero. --- configure.ac | 14 +++---- ext/libav/Makefile.am | 30 +++------------ gst-libs/ext/Makefile.am | 96 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 108 insertions(+), 32 deletions(-) diff --git a/configure.ac b/configure.ac index 7cdf8e2..86174f3 100644 --- a/configure.ac +++ b/configure.ac @@ -314,17 +314,17 @@ else -I \$(top_builddir)/gst-libs/ext/libav \ -Wno-deprecated-declarations" - LIBAV_DEPS="\$(top_builddir)/gst-libs/ext/libav/libavformat/libavformat.a \ + LIBAV_DEPS="\$(top_builddir)/gst-libs/ext/libav/libavfilter/libavfilter.a \ + \$(top_builddir)/gst-libs/ext/libav/libavformat/libavformat.a \ \$(top_builddir)/gst-libs/ext/libav/libavcodec/libavcodec.a \ - \$(top_builddir)/gst-libs/ext/libav/libavfilter/libavfilter.a \ \$(top_builddir)/gst-libs/ext/libav/libswresample/libswresample.a \ \$(top_builddir)/gst-libs/ext/libav/libavutil/libavutil.a" - LIBAV_LIBS="-L\$(top_builddir)/gst-libs/ext/libav/libavformat -lavformat \ - -L\$(top_builddir)/gst-libs/ext/libav/libavcodec -lavcodec \ - -L\$(top_builddir)/gst-libs/ext/libav/libswresample -lswresample \ - -L\$(top_builddir)/gst-libs/ext/libav/libavutil -lavutil \ - -L\$(top_builddir)/gst-libs/ext/libav/libavfilter -lavfilter" + LIBAV_LIBS="$ac_pwd/gst-libs/ext/libavfilter.la \ + $ac_pwd/gst-libs/ext/libavformat.la \ + $ac_pwd/gst-libs/ext/libavcodec.la \ + $ac_pwd/gst-libs/ext/libswresample.la \ + $ac_pwd/gst-libs/ext/libavutil.la" dnl SWSCALE_CFLAGS="-I \$(top_srcdir)/gst-libs/ext/libav \ diff --git a/ext/libav/Makefile.am b/ext/libav/Makefile.am index df32e66..30529ae 100644 --- a/ext/libav/Makefile.am +++ b/ext/libav/Makefile.am @@ -1,17 +1,5 @@ plugin_LTLIBRARIES = libgstlibav.la -if HAVE_BZ2 - BZ2_LIBS = -lbz2 -else - BZ2_LIBS = -endif - -if HAVE_LZMA - LZMA_LIBS = -llzma -else - LZMA_LIBS = -endif - libgstlibav_la_SOURCES = gstav.c \ gstavprotocol.c \ gstavcodecmap.c \ @@ -34,23 +22,17 @@ libgstlibav_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) libgstlibav_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstaudio-$(GST_API_VERSION) -lgstvideo-$(GST_API_VERSION) \ -lgstpbutils-$(GST_API_VERSION) $(GST_BASE_LIBS) \ - $(LIBAV_LIBS) $(LIBM) $(WIN32_LIBS) -lz $(BZ2_LIBS) $(LZMA_LIBS) + $(LIBAV_LIBS) $(WIN32_LIBS) libgstlibav_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(DARWIN_LDFLAGS) if HAVE_LIBAV_UNINSTALLED libgstlibav_la_DEPENDENCIES = $(LIBAV_DEPS) -if GST_PLUGIN_BUILD_STATIC -depsdir = $(libdir) -deps_DATA = $(LIBAV_DEPS) - -libgstlibav_la = $(DESTDIR)$(plugindir)/libgstlibav.la - -install-data-hook: - $(AM_V_at)cp $(libgstlibav_la) $(libgstlibav_la).tmp - $(AM_V_GEN)sed -e "s|-L$(top_builddir)/gst-libs/ext/libav/lib[a-z]* ||g" \ - $(libgstlibav_la).tmp > $(libgstlibav_la) && rm $(libgstlibav_la).tmp -endif +# FIXME: For some reason libtool ignores libavfilter.la, add it +install-data-hook: + $(AM_V_at)cd $(DESTDIR)$(plugindir) \ + && sed -e "s|\($(libdir)/libavformat.la\)|$(libdir)/libavfilter.la \1|" \ + libgstlibav.la > libgstlibav.la.tmp && cp libgstlibav.la.tmp libgstlibav.la && rm libgstlibav.la.tmp endif diff --git a/gst-libs/ext/Makefile.am b/gst-libs/ext/Makefile.am index b125faa..ec404ff 100644 --- a/gst-libs/ext/Makefile.am +++ b/gst-libs/ext/Makefile.am @@ -14,12 +14,106 @@ TMP_DIST_DIR=libav-dist DIST_DIR=$(TMP_DIST_DIR)/.libav EXTRA_DIST=Makefile.am MAINTAINERCLEANDIRS = $(DIST_SUBDIRS) +LIB_LIST=libavutil libswresample libavcodec libavformat libavfilter -all-local: +if HAVE_BZ2 + BZ2_LIBS = -lbz2 +else + BZ2_LIBS = +endif + +if HAVE_LZMA + LZMA_LIBS = -llzma +else + LZMA_LIBS = +endif + + +define create_la +echo " GEN $1.la" && \ +(echo "# $1.la - a libtool library file" && \ + echo "# Generated by libtool (GNU libtool) 2.4.6" && \ + echo "dlname=''" && \ + echo "library_names=''" && \ + echo "old_library='$1.a'" && \ + echo "inherited_linker_flags=''" && \ + echo "dependency_libs=' -L$(libdir) $(if $2,$(foreach dep,$2,$(abs_builddir)/$(dep).la)) $3 $(LIBM) '" && \ + echo "weak_library_names=''" && \ + echo "current=" && \ + echo "age=" && \ + echo "revision=" && \ + echo "installed=no" && \ + echo "shouldnotlink=no" && \ + echo "dlopen=''" && \ + echo "dlpreopen=''" && \ + echo "libdir='$(libdir)'") > $1.la +endef + +libavutil.la: + $(AM_V_at)$(call create_la,libavutil) + +libswresample.la: + $(AM_V_at)$(call create_la,libswresample,libavutil) + +libavcodec.la: + $(AM_V_at)$(call create_la,libavcodec,libswresample libavutil,-lz $(LZMA_LIBS)) + +libavformat.la: + $(AM_V_at)$(call create_la,libavformat,libavcodec libavutil,$(LIBM) -lz $(BZ2_LIBS)) + +libavfilter.la: + $(AM_V_at)$(call create_la,libavfilter,libavformat libavcodec libswresample libavutil) + +all-local: $(foreach lib,$(LIB_LIST),$(lib).la) cd libav && $(MAKE) + $(AM_V_at)$(MKDIR_P) .libs + $(AM_V_at)for lib in $(LIB_LIST); do \ + if ! test -f .libs/$${lib}.a; then \ + echo " CP $${lib}"; \ + cp libav/$${lib}/$${lib}.a .libs/$${lib}.a; \ + fi; \ + done + +if GST_PLUGIN_BUILD_STATIC + +define install_la +echo " INSTALL $1.la" && \ +sed -e "s|$(abs_builddir)|$(libdir)|g" \ + -e "s|installed=no|installed=no|" \ + $1.la > $(DESTDIR)$(libdir)/$1.la +endef + +# Normally DATA is built before am-local, fix it +.libs/libavutil.a: all-local + +.libs/libswresample.a: all-local + +.libs/libavcodec.a: all-local + +.libs/libavformat.a: all-local + +.libs/libavfilter.a: all-local + +depsdir = $(libdir) +nodist_deps_DATA = \ + .libs/libavutil.a \ + .libs/libswresample.a \ + .libs/libavcodec.a \ + .libs/libavformat.a \ + .libs/libavfilter.a + +install-data-hook: + $(AM_V_at)$(call install_la,libavutil) + $(AM_V_at)$(call install_la,libswresample) + $(AM_V_at)$(call install_la,libavcodec) + $(AM_V_at)$(call install_la,libavformat) + $(AM_V_at)$(call install_la,libavfilter) +endif clean-local: cd libav && $(MAKE) clean + rm -rf .libs + rm -r *.la dist-clean: cd libav && $(MAKE) distclean -- 2.7.4