summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2018-03-06 14:40:20 +1100
committerMatthew Waters <matthew@centricular.com>2018-03-06 15:08:32 +1100
commite2bce0f3ec07d86e980cb85233c4f7fb819698c5 (patch)
tree4178dbed5b4bf236489a09bf497d85e6047b8a4a
parentaf8cc8ab890d9c4ec83ad4369ce8e8801ef560f6 (diff)
downloadgst-libav-e2bce0f3ec07d86e980cb85233c4f7fb819698c5.tar.gz
build: prefer using *.la references when creating our own libtool files
Otherwise we will reference the dependant libraries with -lfoo rather than /path/to/libfoo.la which breaks with the Android-based .la parser which simply passes through all -l libraries. https://bugzilla.gnome.org/show_bug.cgi?id=786403
-rw-r--r--gst-libs/ext/Makefile.am27
1 files changed, 26 insertions, 1 deletions
diff --git a/gst-libs/ext/Makefile.am b/gst-libs/ext/Makefile.am
index 9d5e53c..6cdc048 100644
--- a/gst-libs/ext/Makefile.am
+++ b/gst-libs/ext/Makefile.am
@@ -16,6 +16,31 @@ EXTRA_DIST=Makefile.am
MAINTAINERCLEANDIRS = $(DIST_SUBDIRS)
LIB_LIST=libavutil libswresample libavcodec libavformat libavfilter
+# attempt to generate .la references from -l and a list of -L
+# $1 is the argument to filter, -l, -L, -I, etc
+# $2 is the list to filter
+define filter_arg
+ $(foreach item,$(filter $(1)%,$(2)),$(patsubst $(1)%,%,$(item)))
+endef
+
+# $1 library to find
+# $2 directories to search
+define find_la
+ $(firstword $(wildcard $(foreach path,$(call filter_arg,-L,$(2)), $(path)/lib$(strip $(call filter_arg,-l,$(1))).la)))
+endef
+
+# $(call find_la,...) and if a library is found use that, otherwise, return the
+# original lib unchanged
+define find_la_or_original
+ $(if $(strip $(call find_la,$1,$2)),$(call find_la,$1,$2),$(1))
+endef
+
+# $1 the libraries to look for (including -l) e.g. -lbz2 -lz
+# $2 LDFLAGS containing -L arguments
+define find_library_la
+ $(foreach lib,$(1),$(call find_la_or_original,$(lib),$(2)))
+endef
+
define create_la
echo " GEN $1.la" && \
(echo "# $1.la - a libtool library file" && \
@@ -24,7 +49,7 @@ echo " GEN $1.la" && \
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 "dependency_libs=' -L$(libdir) $(if $2,$(foreach dep,$2,$(abs_builddir)/$(dep).la)) $(call find_library_la,$3 $(LIBM),$(LDFLAGS)) '" && \
echo "weak_library_names=''" && \
echo "current=" && \
echo "age=" && \