1# we have to put in a little hack here for integration to work well 2# libav can't be in SUBDIRS, because then automake will try to descend in it 3# and find conditionals it doesn't know. 4 5# so, 6# - don't put it in SUBDIRS so automake doesn't descend 7# - put it in DIST_SUBDIRS so make dist picks up the subtree 8# - add an all-local hook so it does get built 9# this also satisfies make distcheck 10 11SUBDIRS = 12DIST_SUBDIRS = libav 13TMP_DIST_DIR=libav-dist 14DIST_DIR=$(TMP_DIST_DIR)/.libav 15EXTRA_DIST=Makefile.am 16MAINTAINERCLEANDIRS = $(DIST_SUBDIRS) 17LIB_LIST=libavutil libswresample libavcodec libavformat libavfilter 18 19# attempt to generate .la references from -l and a list of -L 20# $1 is the argument to filter, -l, -L, -I, etc 21# $2 is the list to filter 22define filter_arg 23 $(foreach item,$(filter $(1)%,$(2)),$(patsubst $(1)%,%,$(item))) 24endef 25 26# $1 library to find 27# $2 directories to search 28define find_la 29 $(firstword $(wildcard $(foreach path,$(call filter_arg,-L,$(2)), $(path)/lib$(strip $(call filter_arg,-l,$(1))).la))) 30endef 31 32# $(call find_la,...) and if a library is found use that, otherwise, return the 33# original lib unchanged 34define find_la_or_original 35 $(if $(strip $(call find_la,$1,$2)),$(call find_la,$1,$2),$(1)) 36endef 37 38# $1 the libraries to look for (including -l) e.g. -lbz2 -lz 39# $2 LDFLAGS containing -L arguments 40define find_library_la 41 $(foreach lib,$(1),$(call find_la_or_original,$(lib),$(2))) 42endef 43 44define create_la 45echo " GEN $1.la" && \ 46(echo "# $1.la - a libtool library file" && \ 47 echo "# Generated by libtool (GNU libtool) 2.4.6" && \ 48 echo "dlname=''" && \ 49 echo "library_names=''" && \ 50 echo "old_library='$1.a'" && \ 51 echo "inherited_linker_flags=''" && \ 52 echo "dependency_libs=' -L$(libdir) $(if $2,$(foreach dep,$2,$(abs_builddir)/$(dep).la)) $(call find_library_la,$3 $(LIBM),$(LDFLAGS)) '" && \ 53 echo "weak_library_names=''" && \ 54 echo "current=" && \ 55 echo "age=" && \ 56 echo "revision=" && \ 57 echo "installed=no" && \ 58 echo "shouldnotlink=no" && \ 59 echo "dlopen=''" && \ 60 echo "dlpreopen=''" && \ 61 echo "libdir='$(libdir)'") > $1.la 62endef 63 64libavutil.la: 65 $(AM_V_at)$(call create_la,libavutil) 66 67libswresample.la: 68 $(AM_V_at)$(call create_la,libswresample,libavutil) 69 70libavcodec.la: 71 $(AM_V_at)$(call create_la,libavcodec,libswresample libavutil,-lz $(LZMA_LIBS)) 72 73libavformat.la: 74 $(AM_V_at)$(call create_la,libavformat,libavcodec libavutil,$(LIBM) -lz $(BZ2_LIBS)) 75 76libavfilter.la: 77 $(AM_V_at)$(call create_la,libavfilter,libavformat libavcodec libswresample libavutil) 78 79all-local: $(foreach lib,$(LIB_LIST),$(lib).la) 80 cd libav && $(MAKE) 81 $(AM_V_at)$(MKDIR_P) .libs 82 $(AM_V_at)for lib in $(LIB_LIST); do \ 83 if ! test -f .libs/$${lib}.a; then \ 84 echo " CP $${lib}"; \ 85 cp libav/$${lib}/$${lib}.a .libs/$${lib}.a; \ 86 fi; \ 87 done 88 89if GST_PLUGIN_BUILD_STATIC 90 91define install_la 92echo " INSTALL $1.la" && \ 93sed -e "s|$(abs_builddir)|$(libdir)|g" \ 94 -e "s|installed=no|installed=no|" \ 95 $1.la > $(DESTDIR)$(libdir)/$1.la 96endef 97 98# Normally DATA is built before am-local, fix it 99.libs/libavutil.a: all-local 100 101.libs/libswresample.a: all-local 102 103.libs/libavcodec.a: all-local 104 105.libs/libavformat.a: all-local 106 107.libs/libavfilter.a: all-local 108 109depsdir = $(libdir) 110nodist_deps_DATA = \ 111 .libs/libavutil.a \ 112 .libs/libswresample.a \ 113 .libs/libavcodec.a \ 114 .libs/libavformat.a \ 115 .libs/libavfilter.a 116 117install-data-hook: 118 $(AM_V_at)$(call install_la,libavutil) 119 $(AM_V_at)$(call install_la,libswresample) 120 $(AM_V_at)$(call install_la,libavcodec) 121 $(AM_V_at)$(call install_la,libavformat) 122 $(AM_V_at)$(call install_la,libavfilter) 123endif 124 125clean-local: 126 cd libav && $(MAKE) clean 127 rm -rf .libs 128 rm -f *.la 129 130dist-clean: 131 cd libav && $(MAKE) distclean 132 rm -rf libav/$(TMP_DIST_DIR) 133 rm -f Makefile 134 rm -f libav/.version 135 rm -f libav/.config 136 137distclean: dist-clean 138 139maintainer-clean: distclean 140 rm -rf $(MAINTAINERCLEANDIRS) 141 142maintainerclean: maintainer-clean 143 144dist-local: 145 GIT_DIR=$(srcdir)/libav/.git git checkout-index --prefix=$(abs_builddir)/libav/$(TMP_DIST_DIR)/libav/ -a 146 touch libav/$(TMP_DIST_DIR)/libav/config.mak 147 echo "Patching libav ./configure" 148 sed -e '/Unknown option/ {N;N;s/exit 1//; }' libav/$(TMP_DIST_DIR)/libav/configure > libav/$(TMP_DIST_DIR)/libav/configure.tmp 149 mv libav/$(TMP_DIST_DIR)/libav/configure.tmp libav/$(TMP_DIST_DIR)/libav/configure 150 chmod +x libav/$(TMP_DIST_DIR)/libav/configure 151 152distdir: dist-local 153 cp -r libav/$(TMP_DIST_DIR)/libav ${distdir} 154 cp -f $(top_srcdir)/gst-libs/ext/Makefile.am $(top_srcdir)/gst-libs/ext/Makefile.in ${distdir} 155 rm -rf libav/$(TMP_DIST_DIR) 156 157dist: dist-local 158 cd libav/$(TMP_DIST_DIR) && tar -czf libav.tar.gz libav 159 mv libav/$(TMP_DIST_DIR)/libav.tar.gz ./ 160 rm -rf libav/$(TMP_DIST_DIR) 161