Fix to workaround non-default libtool on debian

Debian patches libtool so that the default value of
link_all_deplibs is set to 'no' rather than 'unknown',
causing transitive dependencies in shared objects to
be lost.
diff --git a/contrib/packages/deb/ubuntu-precise/debian/patches/debian_libtool.patch b/contrib/packages/deb/ubuntu-precise/debian/patches/debian_libtool.patch
new file mode 100644
index 0000000..7be0ba2
--- /dev/null
+++ b/contrib/packages/deb/ubuntu-precise/debian/patches/debian_libtool.patch
@@ -0,0 +1,52 @@
+--- a/ltmain.sh	2016-05-11 23:23:25.796742323 -0400
++++ b/ltmain.sh	2016-05-11 23:24:47.173010324 -0400
+@@ -6447,6 +6447,9 @@
+ 	    # It is a libtool convenience library, so add in its objects.
+ 	    func_append convenience " $ladir/$objdir/$old_library"
+ 	    func_append old_convenience " $ladir/$objdir/$old_library"
++	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
++	    func_fatal_error "\`$lib' is not a convenience library"
++	  fi
+ 	    tmp_libs=
+ 	    for deplib in $dependency_libs; do
+ 	      deplibs="$deplib $deplibs"
+@@ -6457,9 +6460,6 @@
+ 	      fi
+ 	      func_append tmp_libs " $deplib"
+ 	    done
+-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
+-	    func_fatal_error "\`$lib' is not a convenience library"
+-	  fi
+ 	  continue
+ 	fi # $pass = conv
+ 
+--- a/m4/libtool.m4	2016-05-11 23:26:23.801328557 -0400
++++ b/m4/libtool.m4	2016-05-11 23:27:12.701489603 -0400
+@@ -4589,9 +4589,6 @@
+       ;;
+     esac
+     ;;
+-  linux* | k*bsd*-gnu | gnu*)
+-    _LT_TAGVAR(link_all_deplibs, $1)=no
+-    ;;
+   *)
+     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+     ;;
+@@ -4654,9 +4651,6 @@
+   openbsd*)
+     with_gnu_ld=no
+     ;;
+-  linux* | k*bsd*-gnu | gnu*)
+-    _LT_TAGVAR(link_all_deplibs, $1)=no
+-    ;;
+   esac
+ 
+   _LT_TAGVAR(ld_shlibs, $1)=yes
+@@ -5055,7 +5049,6 @@
+ 	if test "$aix_use_runtimelinking" = yes; then
+ 	  shared_flag="$shared_flag "'${wl}-G'
+ 	fi
+-	_LT_TAGVAR(link_all_deplibs, $1)=no
+       else
+ 	# not using gcc
+ 	if test "$host_cpu" = ia64; then
diff --git a/contrib/packages/deb/ubuntu-precise/debian/rules b/contrib/packages/deb/ubuntu-precise/debian/rules
index 1a759a5..f803861 100755
--- a/contrib/packages/deb/ubuntu-precise/debian/rules
+++ b/contrib/packages/deb/ubuntu-precise/debian/rules
@@ -58,6 +58,7 @@
 	(cd unix/xserver; \
 	export PIXMANINCDIR=/usr/include/pixman-1; \
 	autoreconf -fiv; \
+  patch -p1 -i ../../debian/patches/debian_libtool.patch; \
 	./configure --prefix=/usr \
 		--disable-silent-rules \
 		--disable-static \
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/patches/debian_libtool.patch b/contrib/packages/deb/ubuntu-trusty/debian/patches/debian_libtool.patch
new file mode 100644
index 0000000..7be0ba2
--- /dev/null
+++ b/contrib/packages/deb/ubuntu-trusty/debian/patches/debian_libtool.patch
@@ -0,0 +1,52 @@
+--- a/ltmain.sh	2016-05-11 23:23:25.796742323 -0400
++++ b/ltmain.sh	2016-05-11 23:24:47.173010324 -0400
+@@ -6447,6 +6447,9 @@
+ 	    # It is a libtool convenience library, so add in its objects.
+ 	    func_append convenience " $ladir/$objdir/$old_library"
+ 	    func_append old_convenience " $ladir/$objdir/$old_library"
++	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
++	    func_fatal_error "\`$lib' is not a convenience library"
++	  fi
+ 	    tmp_libs=
+ 	    for deplib in $dependency_libs; do
+ 	      deplibs="$deplib $deplibs"
+@@ -6457,9 +6460,6 @@
+ 	      fi
+ 	      func_append tmp_libs " $deplib"
+ 	    done
+-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
+-	    func_fatal_error "\`$lib' is not a convenience library"
+-	  fi
+ 	  continue
+ 	fi # $pass = conv
+ 
+--- a/m4/libtool.m4	2016-05-11 23:26:23.801328557 -0400
++++ b/m4/libtool.m4	2016-05-11 23:27:12.701489603 -0400
+@@ -4589,9 +4589,6 @@
+       ;;
+     esac
+     ;;
+-  linux* | k*bsd*-gnu | gnu*)
+-    _LT_TAGVAR(link_all_deplibs, $1)=no
+-    ;;
+   *)
+     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+     ;;
+@@ -4654,9 +4651,6 @@
+   openbsd*)
+     with_gnu_ld=no
+     ;;
+-  linux* | k*bsd*-gnu | gnu*)
+-    _LT_TAGVAR(link_all_deplibs, $1)=no
+-    ;;
+   esac
+ 
+   _LT_TAGVAR(ld_shlibs, $1)=yes
+@@ -5055,7 +5049,6 @@
+ 	if test "$aix_use_runtimelinking" = yes; then
+ 	  shared_flag="$shared_flag "'${wl}-G'
+ 	fi
+-	_LT_TAGVAR(link_all_deplibs, $1)=no
+       else
+ 	# not using gcc
+ 	if test "$host_cpu" = ia64; then
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/rules b/contrib/packages/deb/ubuntu-trusty/debian/rules
index 97aebb3..3811477 100755
--- a/contrib/packages/deb/ubuntu-trusty/debian/rules
+++ b/contrib/packages/deb/ubuntu-trusty/debian/rules
@@ -65,6 +65,7 @@
 	(cd unix/xserver; \
 	export PIXMANINCDIR=/usr/include/pixman-1; \
 	autoreconf -fiv; \
+  patch -p1 -i ../../debian/patches/debian_libtool.patch; \
 	./configure --prefix=/usr \
 		--disable-silent-rules \
 		--disable-static \
diff --git a/contrib/packages/deb/ubuntu-xenial/debian/rules b/contrib/packages/deb/ubuntu-xenial/debian/rules
index 9770083..1a7a20b 100644
--- a/contrib/packages/deb/ubuntu-xenial/debian/rules
+++ b/contrib/packages/deb/ubuntu-xenial/debian/rules
@@ -59,6 +59,7 @@
 	(cd unix/xserver; \
 	export PIXMANINCDIR=/usr/include/pixman-1; \
 	autoreconf -fiv; \
+  patch -p1 -i ../../debian/xorg-source-patches/debian_libtool.patch; \
 	./configure --prefix=/usr \
 		--disable-silent-rules \
 		--disable-static \
diff --git a/contrib/packages/deb/ubuntu-xenial/debian/xorg-source-patches/debian_libtool.patch b/contrib/packages/deb/ubuntu-xenial/debian/xorg-source-patches/debian_libtool.patch
new file mode 100644
index 0000000..d24877d
--- /dev/null
+++ b/contrib/packages/deb/ubuntu-xenial/debian/xorg-source-patches/debian_libtool.patch
@@ -0,0 +1,87 @@
+Index: a/ltmain.sh
+===================================================================
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -7890,19 +7890,19 @@
+ 	    # It is a libtool convenience library, so add in its objects.
+ 	    func_append convenience " $ladir/$objdir/$old_library"
+ 	    func_append old_convenience " $ladir/$objdir/$old_library"
+-	    tmp_libs=
+-	    for deplib in $dependency_libs; do
+-	      deplibs="$deplib $deplibs"
+-	      if $opt_preserve_dup_deps; then
+-		case "$tmp_libs " in
+-		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
+-		esac
+-	      fi
+-	      func_append tmp_libs " $deplib"
+-	    done
+ 	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
+ 	    func_fatal_error "'$lib' is not a convenience library"
+ 	  fi
++	  tmp_libs=
++	  for deplib in $dependency_libs; do
++	    deplibs="$deplib $deplibs"
++	    if $opt_preserve_dup_deps; then
++	      case "$tmp_libs " in
++	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
++	      esac
++	    fi
++	    func_append tmp_libs " $deplib"
++	  done
+ 	  continue
+ 	fi # $pass = conv
+ 
+## Do not link against deplibs.  This is not needed for shared libs
+## on atleast ELF systems since those already know which libs they
+## need themself.  This seems to break a few things and will be fixed
+## in a better way in a future upstream version.
+
+Index: a/ltmain.sh
+===================================================================
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -7568,10 +7568,7 @@
+ 	case $pass in
+ 	dlopen) libs=$dlfiles ;;
+ 	dlpreopen) libs=$dlprefiles ;;
+-	link)
+-	  libs="$deplibs %DEPLIBS%"
+-	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+-	  ;;
++	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+ 	esac
+       fi
+       if test lib,dlpreopen = "$linkmode,$pass"; then
+Index: a/m4/libtool.m4
+===================================================================
+--- a/m4/libtool.m4
++++ b/m4/libtool.m4
+@@ -4936,9 +4936,6 @@
+       ;;
+     esac
+     ;;
+-  linux* | k*bsd*-gnu | gnu*)
+-    _LT_TAGVAR(link_all_deplibs, $1)=no
+-    ;;
+   *)
+     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+     ;;
+@@ -4998,9 +5001,6 @@
+   openbsd* | bitrig*)
+     with_gnu_ld=no
+     ;;
+-  linux* | k*bsd*-gnu | gnu*)
+-    _LT_TAGVAR(link_all_deplibs, $1)=no
+-    ;;
+   esac
+ 
+   _LT_TAGVAR(ld_shlibs, $1)=yes
+@@ -5773,7 +5779,6 @@
+ 	if test yes = "$lt_cv_irix_exported_symbol"; then
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
+ 	fi
+-	_LT_TAGVAR(link_all_deplibs, $1)=no
+       else
+ 	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+ 	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'