Files
mercury/runtime/machdeps/doregtest
Julien Fischer f3d68031f5 Minor fixes for the doregtest script.
runtime/machdeps/doregtest:
    Fix some things identified by ShellCheck.
2021-01-13 15:24:23 +11:00

39 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Compile regtest.c with the specified register name and invoke
# the resulting executable.
if [ $# -ne 1 ]; then
echo "Usage: $(basename $0) register-name" 1>&2
exit 1
fi
CFLAGS=
PIC_CFLAGS="${CFLAGS} -fpic"
echo Trying register "$1"...
if ../../scripts/mgnuc $CFLAGS "-DREG=\"$1\"" regtest.c regtest2.c -o /tmp/regtest$$ -lm &&
[ -x /tmp/regtest$$ ] && /tmp/regtest$$
then
if ../../scripts/mgnuc $PIC_CFLAGS "-DREG=\"$1\"" regtest.c regtest2.c \
-o /tmp/regtest$$ -lm &&
[ -x /tmp/regtest$$ ] && /tmp/regtest$$
then
echo "Register $1 seems to work OK"
else
if ../../scripts/mgnuc -g $CFLAGS "-DREG=\"$1\"" -c regtest.c &&
../../scripts/mgnuc -g $PIC_CFLAGS -c regtest2.c &&
../../scripts/mgnuc -g regtest.o regtest2.o -o /tmp/regtest$$ -lm &&
[ -x /tmp/regtest$$ ] && /tmp/regtest$$
then
echo "Register $1 can't be used in PIC mode"
else
echo "Register $1 can't be used in PIC mode, and"
echo "register $1 also gets clobbered when you merely call PIC code."
fi
fi
else
echo "Register $1 can't be used"
fi
rm -f /tmp/regtest$$