#!/bin/bash

if test "$1" == ""; then
  echo -e "\nmakedeps - Make a dependency file for an executable using dpkg-shlibdeps"
  echo -e "Usage: `basename "$0"` <executable file>\n"
  exit
fi

PRGNAME=`basename "$1"`
ARCH=`uname -m`
DEST="deps-$PRGNAME"_"$ARCH"
STARTDIR=`pwd`
echo "Making dependencies list in $DEST..."

mkdir deps_tmp
mkdir deps_tmp/debian
echo "source: $PROGRAM" > deps_tmp/debian/control
mkdir deps_tmp/usr
mkdir deps_tmp/usr/bin
cp $1 deps_tmp/usr/bin/
cd deps_tmp
dpkg-shlibdeps -O usr/bin/$PRGNAME > "$STARTDIR/$DEST"
cd ..
rm -rf deps_tmp
echo "Done"
