-# Check if the OS can hard-link symlinks or not
-ln "$fromdir/foo/sym" "$fromdir/foo/sym.test" && L=hL || L=cL
-rm -f "$fromdir/foo/sym.test"
+# Check if the OS can hard-link symlinks or not.
+# (Note: the link we check MUST NOT point to a valid file!)
+ln -s no-such-dir "$to2dir"
+if ln "$to2dir" "$to2dir.test" 2>/dev/null; then
+ L=hL
+else
+ L=cL
+fi
+rm -f "$to2dir" "$to2dir.test"
+
+# Check if rsync can preserve time on symlinks
+case "$RSYNC" in
+*protocol=2*)
+ T=.T
+ ;;
+*)
+ if $RSYNC --version | grep ", symtimes" >/dev/null; then
+ T=.t
+ else
+ T=.T
+ fi
+ ;;
+esac