]> arthur.barton.de Git - ax-make.git/blob - scripts/axify
Add "axify" script to the project
[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 if [ "$MAKEFILE_AX" -nt "$LIB_D/`basename "$MAKEFILE_AX"`" ]; then
30         echo "Updating \"$LIB_D/`basename "$MAKEFILE_AX"`\" ..."
31         cp -v "$MAKEFILE_AX" "$LIB_D/`basename "$MAKEFILE_AX"`" || exit 1
32 else
33         echo "Makefile \"$LIB_D/`basename "$MAKEFILE_AX"`\" is up to date."
34 fi
35
36 # -- Project Makefile's ---
37
38 if [ ! -e "Makefile" ]; then
39 echo "Creating \"Makefile\" ..."
40 [ "$LIB_D" != "." ] && subdirs="$LIB_D" || subdirs=""
41 cat >"Makefile" <<EOF
42 #
43 # Makefile
44 #
45
46 SUBDIRS = $subdirs
47
48 include $LIB_D/Makefile.ax
49 EOF
50 fi
51
52 if [ "$LIB_D" != "." -a ! -e "$LIB_D/Makefile" ]; then
53 echo "Creating \"$LIB_D/Makefile\" ..."
54 cat >"$LIB_D/Makefile" <<EOF
55 #
56 # Makefile
57 #
58
59 include Makefile.ax
60 EOF
61 fi
62
63 # --- Standard project files ---
64
65 for f in AUTHORS COPYING README; do
66         if [ ! -e "$f" ]; then
67                 echo "Creating empty \"$f\" ..."
68                 touch "$f"
69         fi
70 done
71
72 exit 0