-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautogen.sh
executable file
·113 lines (102 loc) · 3.14 KB
/
autogen.sh
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
function print_usage() {
echo "Usage: $0 [OPTIONS...]"
echo "Prepare Autotools build infrastructure"
echo
echo " -h, --help print this usage info"
echo " -l, --add-langvar Add env. variable \$GTLANG_kpv to login script."
echo " This makes it possible to use the built fst's"
echo " with the analyser and generator scripts."
echo
}
# option variables
langvar=""
# manual getopt loop... Mac OS X does not have good getopt
while test $# -ge 1 ; do
if test x$1 = x--add-langvar -o x$1 = x-l ; then
langvar=langvar
elif test x$1 = x--help -o x$1 = x-h ; then
print_usage
exit 0
else
echo
echo "ERROR: $0: unknown option $1"
print_usage
exit 1
fi
shift
done
# Variable setup for adding env. variable:
GTLANG=kpv
LANGDIR=$(pwd)
TIME=$(date +%H%M)
DATE=$(date +%Y%m%d)
LOGINFILE=
# Find the login file:
if [[ -r ~/.bash_profile ]]; then
LOGINFILE=~/.bash_profile
elif [[ -r ~/.profile ]]; then
LOGINFILE=~/.profile
elif [[ -r ~/.bashrc ]]; then
LOGINFILE=~/.bashrc
fi
echo
echo "Initial automake setup of $(basename $(pwd))"
# autoreconf should work for most platforms
autoreconf -i
# If option -l / --add-langvar was used:
if test x$langvar = xlangvar ; then
if test x$LOGINFILE = x ; then
echo
echo "ERROR: could not find a login script to add the variable to!"
echo
exit 1
else
if test x${GTLANG_kpv} = x${LANGDIR} ; then
echo "\${GTLANG_kpv} already defined."
else
# Already defined with a different value:
if test x${GTLANG_kpv} != x ; then
renew=renew
OLDLANGDIR=${GTLANG_kpv}
fi
# Add the variable to the login script:
cp $LOGINFILE $LOGINFILE.gtbackup.${DATE}-${TIME}
echo "export GTLANG_kpv=$LANGDIR" >> $LOGINFILE
source $LOGINFILE
# Feedback depending on whether it was added or redefined:
if test x$renew = xrenew ; then
echo "The env. variable \${GTLANG_kpv} has been redefined in"
echo "$LOGINFILE. The old value ${OLDLANGDIR} is no longer in use."
else
echo "The env. variable \${GTLANG_kpv} has been added"
echo "to $LOGINFILE. Your built fst's (those you get after"
echo "'make') will be used with the analyser and generator"
echo "scripts. There's a backup of your old $LOGINFILE in"
echo " $LOGINFILE.gtbackup.${DATE}-${TIME}."
echo "Please log out and in again for the variable to take effect."
fi
fi
fi
fi
# Check whether the variable is defined, warn the user if not or different from
# the current dir:
if test x${GTLANG_kpv} = x ; then
echo "WARNING: The variable \${GTLANG_kpv} has not been defined. You"
echo "will not be able to use your own fst's with the analyser and"
echo "generator scripts if not defined. Please consider rerunning this"
echo "script with option -l:"
echo
echo "$0 -l"
echo
elif test x${GTLANG_kpv} != x${LANGDIR} ; then
echo "WARNING: The variable \${GTLANG_kpv} has the value:"
echo " ${GTLANG_kpv}"
echo "instead of the expected:"
echo " ${LANGDIR}"
echo "Please consider rerunning this script with option -l to update the"
echo "variable:"
echo
echo "$0 -l"
echo
fi