+#! /bin/sh
+# mass_install - Install zero or more files in a directory
+# Gordon Matzigkeit <gord@fig.org>, 2001-09-26
+
+# Usage: mass_install DIR [FILES...] [OPTS...]
+FILES=
+DIR=
+OPTS=
+
+for arg
+do
+ if test -n "$OPTS"; then
+ # Everything from here is an option.
+ OPTS="$OPTS $arg"
+ else
+ case "$arg" in
+ # We found the first option.
+ -*) OPTS="$arg" ;;
+ *)
+ if test -z "$DIR"; then
+ # We don't have a directory yet.
+ DIR="$arg"
+ else
+ # We have no files.
+ FILES="$FILES $arg"
+ fi
+ ;;
+ esac
+ fi
+done
+
+if test -n "$DIR" && test -n "$FILES"; then
+ # Make sure the directory exists.
+ if test ! -d "$DIR"; then
+ cmd="mkdir -p $DIR"
+ $cmd || exit $?
+ fi
+
+ # Run the installer.
+ for f in $FILES; do
+ base=`echo "$f" | sed -e 'sX.*/XX'`
+ cmd="install $OPTS $f $DIR/$base"
+ echo "$cmd"
+ $cmd || exit $?
+ done
+fi
+exit 0