autogen.sh: Fix for Solaris 10.
This is a squashed workaround of the issues in #1302 (closed).
* Replace `test -e` by `test -d` (directory) and `-h`
(symlink), because pre-POSIX /bin/sh of Solaris 10
does not support `test -e`.
* Replace the combination of `head` and `sed ...` by
single sed command `sed -n 1...p`. GNU libtoolize
with Solaris 10 /bin/sh complain "Broken Pipe" for
the closure of stdout by `head`. Let `sed` receive
all stdout and discard.