-
Notifications
You must be signed in to change notification settings - Fork 0
/
ada-link
executable file
·98 lines (84 loc) · 1.82 KB
/
ada-link
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
#!/bin/sh
fatal()
{
echo "ada-link: fatal: $1" 1>&2
exit 1
}
if [ $# -lt 2 ]
then
echo "ada-link: usage: [@dir] basename objects ..." 1>&2
exit 1
fi
#
# check if base directory was specified
#
BASE_DIR="."
echo "$1" | grep '^@' 2>&1 >/dev/null
if [ $? -eq 0 ]
then
BASE_DIR=`echo $1 | sed 's/^@//g'`
shift
fi
ADALINK=`head -n 1 "${BASE_DIR}/conf-adalink"`
if [ $? -ne 0 ]
then
fatal "could not read ${BASE_DIR}/conf-adalink"
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
ADALDFLAGS="${ADALDFLAGS} `head -n 1 ${BASE_DIR}/conf-adaldflags 2>/dev/null`"
#
# Read global flag file list, if present.
#
if [ -f "${BASE_DIR}/conf-aldfflist" ]
then
for f in `cat "${BASE_DIR}/conf-aldfflist"`
do
FLAGS=`cat $f 2>/dev/null` || fatal "could not read $f"
ADALDFLAGS="${ADALDFLAGS} ${FLAGS}"
done
fi
out="$1"
shift
#
# Read local flag file list, if present.
#
if [ -f "${out}.lff" ]
then
for f in `cat "${out}.lff"`
do
targ="`dirname $out`/`dirname $f`/`basename $f`"
FLAGS="`cat $targ 2>/dev/null`" || fatal "could not read $f"
ADALDFLAGS="${ADALDFLAGS} ${FLAGS}"
done
fi
#
# compensate for any compiler bugs
#
case ${SYSTYPE} in
DARWIN)
case ${ADATYPE} in
GCC)
# undefined __UNWIND symbols bug
# /usr/local/ada-n.m/bin/gcc -> /usr/local/ada-n.m/lib
SED_SUB="s:bin/${ADALINK}$:lib:g"
GCC_LIB_PATH="`which ${ADALINK} | sed "${SED_SUB}"`" ||
fatal "could not convert GCC_LIB_PATH"
ADALDFLAGS="${ADALDFLAGS} ${GCC_LIB_PATH} -largs -lgcc_s.1"
;;
*)
;;
esac
;;
*)
;;
esac
exec ${ADALINK} -o ${out} ${1+"$@"} ${ADALDFLAGS}