codegen_test.sh.in: determine option to produce context diff
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Sat, 22 Jun 2024 13:37:41 +0000 (22 15:37 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Sat, 22 Jun 2024 13:52:55 +0000 (22 15:52 +0200)
Some versions of diff, notably the one that comes with HP-UX B.11.31,
do not support unified context diffs.
Detect which of unified or copied context diffs are supported.

Reported-by: Ian McNish <ian@ians.net>
Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
codegen_test.sh.in
configure.ac
m4/isl_detect_diff_options.m4 [new file with mode: 0644]

index 97a0b96..caadbd2 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+DIFF="@DIFF@"
+DIFF_OPTIONS="@DIFF_OPTIONS@"
 EXEEXT=@EXEEXT@
 srcdir=@srcdir@
 
@@ -17,7 +19,7 @@ for i in $srcdir/test_inputs/codegen/*.st \
        dir=`dirname $i`
        ref=$dir/$out
        (./isl_codegen$EXEEXT < $i > $test &&
-        diff -uw $ref $test && rm $test) || failed=1
+        "$DIFF" $DIFF_OPTIONS -w $ref $test && rm $test) || failed=1
 done
 
 test $failed -eq 0 || exit
index 117d5f6..b9318dd 100644 (file)
@@ -40,6 +40,8 @@ AC_CHECK_PROG(PERL, perl, perl, [])
 AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex, [])
 AC_CHECK_PROG(POD2HTML, pod2html, pod2html, [])
 
+ISL_DETECT_DIFF_OPTIONS
+
 AC_SUBST(OS_SRCDIR)
 if test "$host_os" = "mingw32" -a -n "$CYGPATH"; then
        OS_SRCDIR=`$CYGPATH -m "$srcdir"`
diff --git a/m4/isl_detect_diff_options.m4 b/m4/isl_detect_diff_options.m4
new file mode 100644 (file)
index 0000000..5b66d9f
--- /dev/null
@@ -0,0 +1,13 @@
+AC_DEFUN([ISL_DETECT_DIFF_OPTIONS], [
+       AC_SUBST([DIFF_OPTIONS])
+       AC_PATH_PROG([DIFF], [diff])
+
+       AC_MSG_CHECKING([for $DIFF context option])
+       for opt in -u -c; do
+               if $DIFF $opt /dev/null /dev/null > /dev/null 2>&1; then
+                       DIFF_OPTIONS=$opt
+                       break
+               fi
+       done
+       AC_MSG_RESULT([$DIFF_OPTIONS])
+])