mkdir -p ${TMP}/${d}
 done
 
-# LIBS=`ldd selector | grep "=> /" | awk '{print $3}'`
-# DEPS=`for l in ${LIBS}; do dpkg -S $l; done | cut -f 1 -d: | sort | uniq`
+LIB_DEPENDS=$(dpkg-shlibdeps -O ./selector|grep Depends|sed -e "s/^.*Depends=//")
 
 cat > ${TMP}/DEBIAN/control <<EOF
 Package: selector
 Version: ${VERSION}
 Maintainer: Francois Fleuret <francois@fleuret.org>
 Architecture: i386
-Depends: libncurses5, libstdc++6, libc6, libgcc1
+Depends: ${LIB_DEPENDS}
 Description: A command line for dynamic string-matching.
  This is a command line for dynamic string selection. As you type a
  list of strings separated by ';' or a regexp, the display is updated