3 # ax-make: Alex' Simple Makefile System
4 # Copyright (c)2014 Alexander Barton (alex@barton.de)
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
15 echo "Usage: $NAME [-2|-3|-l <lic>] [<lib-dir>]"
17 echo ' -2 Use the GNU GPLv2 for the COPYING file.'
18 echo ' -3 Use the GNU GPLv3 for the COPYING file.'
19 echo ' -l <lic> Specify license to use for the COPYING file:'
20 echo ' <lic> can be "gpl2", "gpl3", "lgpl21", "lgpl3".'
21 echo ' By default an empty COPYING file is created.'
23 echo " <lib-dir> Library directory. Default: current working directory."
32 echo "Downloading $URL to $FILE ..."
34 curl --version >/dev/null 2>&1
36 curl -#o "$FILE" "$URL" && return 0
37 echo "Failed to download $URL! [curl]"
41 wget --version >/dev/null 2>&1
43 wget -qO "$FILE" --show-progress "$URL" && return 0
44 echo "Failed to download $URL! [wget]"
48 echo "Can't download $URL, no download tool found!"
79 [ -n "$1" ] && LIB_D="$1"
81 if [ -r "/usr/local/share/ax-make/Makefile.ax" ]; then
82 MAKEFILE_AX="/usr/local/share/ax-make/Makefile.ax"
83 elif [ -r "/usr/share/ax-make/Makefile.ax" ]; then
84 MAKEFILE_AX="/usr/share/ax-make/Makefile.ax"
86 echo "$NAME: No source \"Makefile.ax\" found!"
87 echo "$NAME: Please check your installation of \"ax-make\" and try again."
93 if [ ! -d "$LIB_D" ]; then
94 mkdir -pv "$LIB_D" || exit 1
97 target="$LIB_D/`basename "$MAKEFILE_AX"`"
98 if [ ! -e "$target" -o "$MAKEFILE_AX" -nt "$target" ]; then
99 echo "Updating \"$target\" ..."
100 cp -v "$MAKEFILE_AX" "$target" || exit 1
102 echo "Makefile \"$target\" is up to date."
105 # -- Project Makefile's ---
107 if [ ! -e "Makefile" ]; then
108 echo "Creating \"Makefile\" ..."
109 [ "$LIB_D" != "." ] && subdirs="$LIB_D" || subdirs=""
110 cat >"Makefile" <<EOF
117 include $LIB_D/Makefile.ax
121 if [ "$LIB_D" != "." -a ! -e "$LIB_D/Makefile" ]; then
122 echo "Creating \"$LIB_D/Makefile\" ..."
123 cat >"$LIB_D/Makefile" <<EOF
132 # --- Standard project files ---
134 if [ ! -e AUTHORS ]; then
135 if git --version >/dev/null 2>&1; then
136 echo "Creating \"AUTHORS\" file ..."
137 echo "`git config user.name` <`git config user.email`>" >>AUTHORS
141 if [ ! -e COPYING ]; then
147 LICENSE_URL="http://www.gnu.org/licenses/gpl-2.0.txt"
150 LICENSE_URL="http://www.gnu.org/licenses/gpl-3.0.txt"
153 LICENSE_URL="https://www.gnu.org/licenses/lgpl-2.1.txt"
156 LICENSE_URL="https://www.gnu.org/licenses/lgpl-3.0.txt"
159 echo "Can't setup unknown \"$LICENSE\" license!"
162 [ -n "$LICENSE_URL" ] && Download "$LICENSE_URL" COPYING
164 [ -n "$LICENSE" ] && echo "COPYING file already exists, skipping."
167 for f in AUTHORS COPYING README; do
168 if [ ! -e "$f" ]; then
169 echo "Creating empty \"$f\" file ..."