forked from FlexibleSUSY/FlexibleSUSY
-
Notifications
You must be signed in to change notification settings - Fork 1
/
createaddon
executable file
·90 lines (71 loc) · 2.16 KB
/
createaddon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
# addon creation script for FlexibleSUSY
# Author: Alexander Voigt
# directory of this script
BASEDIR=$(dirname $0)
overwrite="no"
name=""
# exit codes
exit_ok="0"
exit_syntax_error="1"
exit_addon_dir_exists="2"
exit_no_default_addon="3"
#_____________________________________________________________________
help() {
cat <<EOF
Usage: ./`basename $0` [options] --name=<addon-name>
Options:
--name= Name of the FlexibleSUSY addon
Example: --name=MyAddon
--force,-f Overwrite existing addon files.
--help,-h Print this help message.
This script creates the directory addons/<addon-name>/
and the makefile module addons/<addon-name>/module.mk
Example:
./createaddon --name=MyMSSMExtension
EOF
}
if test $# -lt 1 ; then
echo "Error: Too few arguments"
help
exit ${exit_syntax_error}
fi
if test $# -gt 0 ; then
while test ! "x$1" = "x" ; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--force|-f) overwrite="yes" ;;
--help|-h) help; exit ${exit_ok} ;;
--name=*) name="$optarg" ;;
*) echo "Invalid option '$1'. Try $0 --help" ; exit ${exit_syntax_error} ;;
esac
shift
done
fi
if [ -z "$name" ] ; then
echo "Error: no addon specified!"
help
exit ${exit_syntax_error}
fi
# create target directory name
targetdir="addons/${name}"
if test -d "$targetdir" -a "x$overwrite" = "xno" ; then
echo "Error: directory $targetdir already exists!"
echo "Please chose another addon name or use the --force option."
echo "See ./`basename $0` --help for more information."
exit ${exit_addon_dir_exists}
fi
echo "Creating addon $name"
if test ! -d "$targetdir" ; then
printf " Creating addon directory %s ... " "$targetdir"
mkdir -p $targetdir
echo "done"
fi
printf " Creating Makefile module %s/module.mk ... " "$targetdir"
sed -e "s|@DIR@|$targetdir|g" \
-e "s|@ADDON@|$name|g" \
< templates/module.addon.mk.in > $targetdir/module.mk
echo "done"