#!/bin/sh

# When SOURCE_DATE_EPOCH is defined in the environment,
# and the date it contains is older than an Ada source,
# gcc (>= 7.1.0-9) writes SOURCE_DATE_EPOCH in the .ali file
# instead of the actual source file timestamp.
# gprbuild/2017 detects the mismatch and insists on recompiling.

set -C -e -f -u

cd "$ADTTMP"

cat > a.adb <<EOF
procedure A is
begin
   null;
end A;
EOF
cat > p.gpr <<EOF
project P is
   for Main use ("a.adb");
end P;
EOF
export SOURCE_DATE_EPOCH=100
gprbuild p.gpr
! (gprbuild -vh p.gpr | grep "different time stamp for a\.adb")
