]> arthur.barton.de Git - ax-make.git/blobdiff - scripts/axify
axify: Simplify AUTHORS file creation
[ax-make.git] / scripts / axify
index ec3d593c84764e3891a572d4aab13199967cbd37..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,7 +47,9 @@ fi
 
 # -- Makefile.ax --
 
-[ ! -d "$LIB_D" ] && mkdir -pv "$LIB_D"
+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
@@ -64,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