]> arthur.barton.de Git - ax-make.git/blobdiff - scripts/axify
axify: Simplify AUTHORS file creation
[ax-make.git] / scripts / axify
index b40d9182ea2ed02561613c4827e7451f84726715..93adf396671bffea3568c3e3b1f9f5c75a9498e8 100755 (executable)
 
 NAME=`basename "$0"`
 
+Usage() {
+       echo "Usage: $NAME [<lib-dir>]"
+       echo
+       echo "  <lib-dir>    Library directory. Default: current working directory."
+       echo
+       exit 2
+}
+
+while true; do
+       case "$1" in
+               "-"*)
+                       Usage
+                       ;;
+               *)
+                       break
+                       ;;
+       esac
+       shift
+done
+
+[ $# -gt 1 ] && Usage
+
 [ -n "$1" ] && LIB_D="$1" || LIB_D="."
 
 if [ -r "/usr/local/share/ax-make/Makefile.ax" ]; then
@@ -25,12 +47,16 @@ fi
 
 # -- Makefile.ax --
 
-[ ! -d "$LIB_D" ] && mkdir -pv "$LIB_D"
-if [ "$MAKEFILE_AX" -nt "$LIB_D/`basename "$MAKEFILE_AX"`" ]; then
-       echo "Updating \"$LIB_D/`basename "$MAKEFILE_AX"`\" ..."
-       cp -v "$MAKEFILE_AX" "$LIB_D/`basename "$MAKEFILE_AX"`" || exit 1
+if [ ! -d "$LIB_D" ]; then
+       mkdir -pv "$LIB_D" || exit 1
+fi
+
+target="$LIB_D/`basename "$MAKEFILE_AX"`"
+if [ ! -e "$target" -o "$MAKEFILE_AX" -nt "$target" ]; then
+       echo "Updating \"$target\" ..."
+       cp -v "$MAKEFILE_AX" "$target" || exit 1
 else
-       echo "Makefile \"$LIB_D/`basename "$MAKEFILE_AX"`\" is up to date."
+       echo "Makefile \"$target\" is up to date."
 fi
 
 # -- Project Makefile's ---
@@ -62,9 +88,16 @@ fi
 
 # --- Standard project files ---
 
+if [ ! -e AUTHORS ]; then
+       if git --version >/dev/null 2>&1; then
+               echo "Creating \"AUTHORS\" file ..."
+               echo "`git config user.name` <`git config user.email`>" >>AUTHORS
+       fi
+fi
+
 for f in AUTHORS COPYING README; do
        if [ ! -e "$f" ]; then
-               echo "Creating empty \"$f\" ..."
+               echo "Creating empty \"$f\" file ..."
                touch "$f"
        fi
 done