-
Notifications
You must be signed in to change notification settings - Fork 0
/
ada-compile
executable file
·95 lines (80 loc) · 1.63 KB
/
ada-compile
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
fatal()
{
echo "ada-compile: fatal: $1" 1>&2
exit 1
}
if [ $# -lt 1 ]
then
echo "ada-compile: usage: [@dir] source" 1>&2
exit 1
fi
#
# check if new base dir was specified
#
BASE_DIR="."
if [ $# -eq 2 ]
then
BASE_DIR=`echo "$1" | sed 's/^@//g'`
shift
fi
#
# Extract base name of given source file.
#
out=`echo "$1" | awk -F. '{print $1}'`
src="$1"
shift
ADA=`head -n 1 "${BASE_DIR}/conf-adacomp"`
if [ $? -ne 0 ]
then
fatal "could not read ${BASE_DIR}/conf-adacomp"
fi
SYSTYPE=`head -n 1 "${BASE_DIR}/conf-systype"`
if [ $? -ne 0 ]
then
fatal "could not read ${BASE_DIR}/conf-systype"
fi
ADATYPE=`head -n 1 "${BASE_DIR}/conf-adatype"`
if [ $? -ne 0 ]
then
fatal "could not read ${BASE_DIR}/conf-adatype"
fi
ADAFLAGS="${ADAFLAGS} `head -n 1 ${BASE_DIR}/conf-adacflags 2>/dev/null`"
#
# Read global flag file list, if present.
#
if [ -f "${BASE_DIR}/conf-adafflist" ]
then
for f in `cat "${BASE_DIR}/conf-adafflist"`
do
FLAGS=`cat $f 2>/dev/null` || fatal "could not read $f"
ADAFLAGS="${ADAFLAGS} ${FLAGS}"
done
fi
#
# Read local flag file list, if present.
#
if [ -f "${out}.iff" ]
then
for f in `cat "${out}.iff"`
do
targ="`dirname $out`/`dirname $f`/`basename $f`"
FLAGS="`cat $targ 2>/dev/null`" || fatal "could not read $f"
ADAFLAGS="${ADAFLAGS} ${FLAGS}"
done
fi
#
# read configuration pragma file, if present
#
if [ -f conf-adapragma ]
then
case ${ADATYPE} in
GCC) ADAFLAGS="${ADAFLAGS} -gnatec=conf-adapragma";;
*) ;;
esac
fi
rm -f "${out}.ali"
${ADA} -o "${out}.o" -c ${src} ${1+"$@"} ${ADAFLAGS}
ret=$?
if [ ${ret} -eq 0 ]; then exec touch "${out}.ali"; fi
exit $ret