#!/bin/sh # # ax-make: Alex' Simple Makefile System # Copyright (c)2014 Alexander Barton (alex@barton.de) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # NAME=`basename "$0"` Usage() { echo "Usage: $NAME []" echo echo " 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 MAKEFILE_AX="/usr/local/share/ax-make/Makefile.ax" elif [ -r "/usr/share/ax-make/Makefile.ax" ]; then MAKEFILE_AX="/usr/share/ax-make/Makefile.ax" else echo "$NAME: No source \"Makefile.ax\" found!" echo "$NAME: Please check your installation of \"ax-make\" and try again." exit 1 fi # -- Makefile.ax -- 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 \"$target\" is up to date." fi # -- Project Makefile's --- if [ ! -e "Makefile" ]; then echo "Creating \"Makefile\" ..." [ "$LIB_D" != "." ] && subdirs="$LIB_D" || subdirs="" cat >"Makefile" <"$LIB_D/Makefile" </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\" file ..." touch "$f" fi done exit 0