-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·95 lines (84 loc) · 2.22 KB
/
configure
File metadata and controls
executable file
·95 lines (84 loc) · 2.22 KB
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
91
92
93
94
95
#!/bin/sh
name='MakeMeHappy'
datadir="/usr/share/$name"
etcdir="/etc/$name"
parseCHANGES='
if (m/^\* v[^v]*(v[0-9]+\.[0-9]+[^ ]*) +\(released/) {
print $1;
exit 0
}'
version="no-version-yet"
python=''
if test "x$1" = "x--help"; then
cat <<EOF
Fine tuning of the installation directories:
--datadir=DIR Configure distribution data directory
--etcdir=DIR Configure installation-wide data directory
--python=FILE Configure Python-3 binary name
EOF
exit 0
fi
findprg() {
_prg="$1"
REPLY=''
_oldifs="$IFS"
IFS=':'
for dir in $PATH; do
f="$dir/$_prg"
if [ -x "$f" ]; then
printf 'Looking up %s program in $PATH: %s\n' "$_prg" "$f"
REPLY="$f"
IFS="$_oldifs"
return 0
fi
done
IFS="$_oldifs"
printf 'Could not find binary: %s\n' "$_prg"
return 1
}
gotgit=1
findprg git || {
printf 'Version will be set to %s\n' "$version"
gotgit=0
}
git="$REPLY"
while [ "$#" -gt 0 ]; do
case "$1" in
--datadir=*) datadir="${1#*=}" ;;
--etcdir=*) etcdir="${1#*=}" ;;
--python=*) python="${1#*=}" ;;
*) printf 'Unknown option: "%s"\n' "$1"
exit 1 ;;
esac
shift
done
if [ -z "$python" ]; then
findprg python3 || exit 1
python="$REPLY"
fi
if [ "$gotgit" -gt 0 ]; then
if [ "$("$git" rev-parse --is-inside-work-tree 2>/dev/null)" = 'true' ]
then
version="$(git describe --always)"
version=${version#v}
if test -n "$(git diff-index --name-only HEAD --)"; then
version=${version}-dirty
fi
else
printf 'Running outside of git repository!\n'
fi
fi
if [ "$version" = "no-version-yet" ]; then
# Either, there's no git installed, or we don't have git repository infor-
# mation while trying to figure out the project's version. Fall back the to
# the version in the latest release note in CHANGES.
version=$(perl -ne "$parseCHANGES" < CHANGES)
fi
printf 'Version will be set to %s\n' "$version"
printf 'Generating mmh from mmh.in...\n'
sed -e "s|@@DATADIR@@|${datadir}|" \
-e "s|@@ETCDIR@@|${etcdir}|" \
-e "s|@@PYTHON@@|${python}|" \
-e "s|@@VERSION@@|${version}|" \
< mmh.in > mmh
chmod 0755 mmh