#!/bin/sh -e

if [ -z "$DEB_HOST_ARCH" ]; then
  DEB_HOST_ARCH="$(dpkg-architecture -qDEB_HOST_ARCH)"
fi

case "$DEB_HOST_ARCH" in
  alpha|ia64) ;;
  *) exit ;;
esac

if [ "$1" ]; then
  DIR="$1"
else
  DIR='.'
fi

echo "Patching the SONAME for $DEB_HOST_ARCH in $DIR/libtool."

exec \
perl -i -pe '/^(library_names_spec|soname_spec)=/ and s/major/major.1/' \
  $DIR/libtool

