#!/bin/sh
set -C -e -f -u
cd "$AUTOPKGTEST_TMP"

# See debian/patches/gprconfig.patch.

cat > m.adb <<EOF
procedure M is
begin
   null;
end M;
EOF
cat > p.gpr <<EOF
project P is
   for Main use ("m.adb");
end P;
EOF
status=0
(gprbuild -vh p.gpr || status=$?) | tee log
test $status = 0
echo 'Direct gcc* commands (there should be none, we want gnatgcc)'
grep /usr/bin/gcc log || status=$?
test $status = 1

find . -type f -delete

cat > m.c <<EOF
int main(void)
{
    return 0;
}
EOF
cat > p.gpr <<EOF
project P is
   for Languages use ("C");
   for Main use ("m.c");
end P;
EOF
status=0
(gprbuild -vh p.gpr || status=$?) | tee log
test $status = 0
echo 'Direct gcc* commands (there should be none, we want gnatgcc)'
grep /usr/bin/gcc log || status=$?
test $status = 1
