1#!/bin/sh
2
3if [ "$testdir" = "" ]; then
4   echo You must use make check or make check-ada
5   exit 1
6fi
7
8# Provide which replacement.
9#
10# type -p is missing from Solaris 2 /bin/sh and /bin/ksh (ksh88), but both
11# ksh93 and bash have it.
12# type output format differs between ksh88 and ksh93, so avoid it if
13# type -p is present.  Unfortunately, HP-UX /bin/sh ignores -p with type.
14# Fall back to whence which ksh88 and ksh93 provide, but bash does not.
15
16which () {
17    path=`type -p $* 2>/dev/null` && { echo $path | awk '{print $NF}'; return 0; }
18    path=`type $* 2>/dev/null` && { echo $path | awk '{print $NF}'; return 0; }
19    path=`whence $* 2>/dev/null` && { echo $path; return 0; }
20    return 1
21}
22
23# Set up environment to use the Ada compiler from the object tree
24
25host_gnatchop=`which gnatchop`
26host_gnatmake=`which gnatmake`
27ROOT=`${PWDCMD-pwd}`
28BASE=`cd $ROOT/../../..; ${PWDCMD-pwd}`
29
30PATH=$BASE:$ROOT:$PATH
31ADA_INCLUDE_PATH=$BASE/ada/rts
32LD_LIBRARY_PATH=$ADA_INCLUDE_PATH:$BASE:$LD_LIBRARY_PATH
33ADA_OBJECTS_PATH=$ADA_INCLUDE_PATH
34
35if [ ! -d $ADA_INCLUDE_PATH ]; then
36   echo gnatlib missing, exiting.
37   exit 1
38fi
39
40if [ ! -f $BASE/gnatchop ]; then
41   echo gnattools missing, exiting.
42   exit 1
43fi
44
45if [ ! -f $BASE/gnatmake ]; then
46   echo gnattools missing, exiting.
47   exit 1
48fi
49
50export PATH ADA_INCLUDE_PATH ADA_OBJECTS_PATH BASE LD_LIBRARY_PATH
51
52echo '#!/bin/sh' > host_gnatchop
53echo PATH=`dirname $host_gnatchop`:'$PATH' >> host_gnatchop
54echo unset ADA_INCLUDE_PATH ADA_OBJECTS_PATH GCC_EXEC_PREFIX >> host_gnatchop
55echo export PATH >> host_gnatchop
56echo exec gnatchop '"$@"' >> host_gnatchop
57
58chmod +x host_gnatchop
59
60echo '#!/bin/sh' > host_gnatmake
61echo PATH=`dirname $host_gnatmake`:'$PATH' >> host_gnatmake
62echo unset ADA_INCLUDE_PATH ADA_OBJECTS_PATH GCC_EXEC_PREFIX >> host_gnatmake
63echo export PATH >> host_gnatmake
64echo exec gnatmake '"$@"' >> host_gnatmake
65
66chmod +x host_gnatmake
67
68# Limit the stack to 16MB for stack checking
69ulimit -s 16384
70
71exec $testdir/run_all.sh ${1+"$@"}
72