3 # ax-make: Alex' Simple Makefile System
4 # Copyright (c)2014-2020 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 if curl --version >/dev/null 2>&1; then
35 curl -#o "$FILE" "$URL" && return 0
36 echo "Failed to download $URL! [curl]"
40 if wget --version >/dev/null 2>&1; then
41 wget -qO "$FILE" --show-progress "$URL" && return 0
42 echo "Failed to download $URL! [wget]"
46 echo "Can't download $URL, no download tool found!"
77 [ -n "$1" ] && LIB_D="$1"
79 if [ -r "/usr/local/share/ax-make/Makefile.ax" ]; then
80 MAKEFILE_AX="/usr/local/share/ax-make/Makefile.ax"
81 elif [ -r "/usr/share/ax-make/Makefile.ax" ]; then
82 MAKEFILE_AX="/usr/share/ax-make/Makefile.ax"
84 echo "$NAME: No source \"Makefile.ax\" found!"
85 echo "$NAME: Please check your installation of \"ax-make\" and try again."
91 if [ ! -d "$LIB_D" ]; then
92 mkdir -pv "$LIB_D" || exit 1
95 target="$LIB_D/$(basename "$MAKEFILE_AX")"
96 if [ ! -e "$target" ] || [ "$MAKEFILE_AX" -nt "$target" ]; then
97 echo "Updating \"$target\" ..."
98 cp -v "$MAKEFILE_AX" "$target" || exit 1
100 echo "Makefile \"$target\" is up to date."
103 # -- Project Makefile's ---
105 if [ ! -e "Makefile" ]; then
106 echo "Creating \"Makefile\" ..."
107 [ "$LIB_D" != "." ] && subdirs="$LIB_D" || subdirs=""
108 cat >"Makefile" <<EOF
115 include $LIB_D/Makefile.ax
119 if [ "$LIB_D" != "." ] && [ ! -e "$LIB_D/Makefile" ]; then
120 echo "Creating \"$LIB_D/Makefile\" ..."
121 cat >"$LIB_D/Makefile" <<EOF
130 # --- Standard project files ---
132 if [ ! -e AUTHORS ]; then
133 if git --version >/dev/null 2>&1; then
134 echo "Creating \"AUTHORS\" file ..."
135 echo "$(git config user.name) <$(git config user.email)>" >>AUTHORS
139 if [ ! -e COPYING ]; then
145 LICENSE_URL="http://www.gnu.org/licenses/gpl-2.0.txt"
148 LICENSE_URL="http://www.gnu.org/licenses/gpl-3.0.txt"
151 LICENSE_URL="https://www.gnu.org/licenses/lgpl-2.1.txt"
154 LICENSE_URL="https://www.gnu.org/licenses/lgpl-3.0.txt"
157 echo "Can't setup unknown \"$LICENSE\" license!"
160 [ -n "$LICENSE_URL" ] && Download "$LICENSE_URL" COPYING
162 [ -n "$LICENSE" ] && echo "COPYING file already exists, skipping."
165 for f in AUTHORS COPYING README; do
166 if [ ! -e "$f" ]; then
167 echo "Creating empty \"$f\" file ..."