+ while test -h "$self_abspathname"; do
+ # Resolve symbolic link.
+ linkval=`func_readlink "$self_abspathname"`
+ test -n "$linkval" || break
+ case "$linkval" in
+ /* ) self_abspathname="$linkval" ;;
+ * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
+ esac
+ done
+ gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
+}
+
+# func_tmpdir
+# creates a temporary directory.
+# Input:
+# - progname name of this program
+# Sets variable
+# - tmp pathname of freshly created temporary directory
+func_tmpdir ()
+{
+ # Use the environment variable TMPDIR, falling back to /tmp. This allows
+ # users to specify a different temporary directory, for example, if their
+ # /tmp is filled up or too small.
+ : ${TMPDIR=/tmp}
+ {
+ # Use the mktemp program if available. If not available, hide the error
+ # message.
+ tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+ } ||
+ {
+ # Use a simple mkdir command. It is guaranteed to fail if the directory
+ # already exists. $RANDOM is bash specific and expands to empty in shells
+ # other than bash, ksh and zsh. Its use does not increase security;
+ # rather, it minimizes the probability of failure in a very cluttered /tmp
+ # directory.
+ tmp=$TMPDIR/gl$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+ } ||
+ {
+ echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
+ func_exit 1
+ }
+}
+
+# func_fatal_error message
+# outputs to stderr a fatal error message, and terminates the program.
+# Input:
+# - progname name of this program
+func_fatal_error ()
+{
+ echo "$progname: *** $1" 1>&2
+ echo "$progname: *** Stop." 1>&2
+ func_exit 1
+}
+
+# func_readlink SYMLINK
+# outputs the target of the given symlink.
+if (type -p readlink) > /dev/null 2>&1; then
+ func_readlink ()
+ {
+ # Use the readlink program from GNU coreutils.
+ readlink "$1"
+ }
+else
+ func_readlink ()
+ {
+ # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
+ # would do the wrong thing if the link target contains " -> ".
+ LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
+ }
+fi