]> arthur.barton.de Git - ax-make.git/blob - scripts/axify
ccd7b8db395d9b685c020d031f4ab3e12bf43e93
[ax-make.git] / scripts / axify
1 #!/bin/sh
2 #
3 # ax-make: Alex' Simple Makefile System
4 # Copyright (c)2014 Alexander Barton (alex@barton.de)
5 #
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.
10 #
11
12 NAME=`basename "$0"`
13
14 [ -n "$1" ] && LIB_D="$1" || LIB_D="."
15
16 if [ -r "/usr/local/share/ax-make/Makefile.ax" ]; then
17         MAKEFILE_AX="/usr/local/share/ax-make/Makefile.ax"
18 elif [ -r "/usr/share/ax-make/Makefile.ax" ]; then
19         MAKEFILE_AX="/usr/share/ax-make/Makefile.ax"
20 else
21         echo "$NAME: No source \"Makefile.ax\" found!"
22         echo "$NAME: Please check your installation of \"ax-make\" and try again."
23         exit 1
24 fi
25
26 # -- Makefile.ax --
27
28 [ ! -d "$LIB_D" ] && mkdir -pv "$LIB_D"
29
30 target="$LIB_D/`basename "$MAKEFILE_AX"`"
31 if [ ! -e "$target" -o "$MAKEFILE_AX" -nt "$target" ]; then
32         echo "Updating \"$target\" ..."
33         cp -v "$MAKEFILE_AX" "$target" || exit 1
34 else
35         echo "Makefile \"$target\" is up to date."
36 fi
37
38 # -- Project Makefile's ---
39
40 if [ ! -e "Makefile" ]; then
41 echo "Creating \"Makefile\" ..."
42 [ "$LIB_D" != "." ] && subdirs="$LIB_D" || subdirs=""
43 cat >"Makefile" <<EOF
44 #
45 # Makefile
46 #
47
48 SUBDIRS = $subdirs
49
50 include $LIB_D/Makefile.ax
51 EOF
52 fi
53
54 if [ "$LIB_D" != "." -a ! -e "$LIB_D/Makefile" ]; then
55 echo "Creating \"$LIB_D/Makefile\" ..."
56 cat >"$LIB_D/Makefile" <<EOF
57 #
58 # Makefile
59 #
60
61 include Makefile.ax
62 EOF
63 fi
64
65 # --- Standard project files ---
66
67 authors=AUTHORS
68 if [ ! -e AUTHORS ]; then
69         if git --version >/dev/null 2>&1; then
70                 echo "Creating \"AUTHORS\" file ..."
71                 echo "`git config user.name` <`git config user.email`>" >>AUTHORS
72                 authors=
73         fi
74 fi
75
76 for f in $authors COPYING README; do
77         if [ ! -e "$f" ]; then
78                 echo "Creating empty \"$f\" file ..."
79                 touch "$f"
80         fi
81 done
82
83 exit 0