* Vincent Lefevre wrote on Thu, Mar 20, 2008 at 01:20:50AM CET: > > There would be another reason to use cmp instead of diff: it is > simpler and lighter. So, why not using cmp and let the cygwin(?) > developers fix their tools?
Because there is no fix. cmp is working on binary files and diff is working on text files, as designed. FWIW, to make this discussion constructive, here's a quick and incomplete patch to cope without diff in Autoconf (missing a NEWS entry, documentation, and maybe a wrapper macro around $as_diff). Vincent, it'd be nice if you could run the git Autoconf testsuite on Maemo with this, to see if it stands a chance of working. That's not to say that I'm sure I want this applied, but maybe it's a better ground for discussion. I don't like that this adds four forks to every configure invocation but that's only a side issue. The larger question is whether these systems are general enough to warrant that Autoconf works on them. AIUI since the Zaurus doesn't have awk, the current git Autoconf won't work on it anyway. Cheers, Ralf 2008-03-21 Ralf Wildenhues <[EMAIL PROTECTED]> Port Autoconf to systems that lack 'diff'. * lib/m4sugar/m4sh.m4 (_AS_DIFF_PREPARE): New macro, sets as_diff to diff if present, otherwise cmp. (_AS_PREPARE): Call it. * lib/autoconf/general.m4 (AC_CACHE_SAVE): Use $as_diff. * lib/autoconf/programs.m4 (_AC_FEATURE_CHECK_LENGTH): Likewise. * lib/autoconf/status.m4 (_AC_OUTPUT_HEADER): Likewise. * lib/autotest/general.m4 (AT_INIT): Initialize at_diff using as_diff. Report by Vincent Lefevre. diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 645108e..88df4f2 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1943,7 +1943,7 @@ _AC_CACHE_DUMP() | t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end'] >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else +if $as_diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && AC_MSG_NOTICE([updating cache $cache_file]) diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4 index 20fb479..674b2c2 100644 --- a/lib/autoconf/programs.m4 +++ b/lib/autoconf/programs.m4 @@ -509,7 +509,7 @@ m4_define([_AC_FEATURE_CHECK_LENGTH], cp "conftest.in" "conftest.nl" AS_ECHO(['$4']) >> "conftest.nl" $3 < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + $as_diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${$1_max-0}; then # Best one so far, save it but keep looking for a better one diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index c8f329a..ce9b068 100644 --- a/lib/autoconf/status.m4 +++ b/lib/autoconf/status.m4 @@ -669,7 +669,7 @@ which seems to be undefined. Please make sure it is defined.]) esac \ || AC_MSG_ERROR([could not create $ac_file]) dnl This would break Makefile dependencies: -dnl if diff "$ac_file" "$tmp/out" >/dev/null 2>&1; then +dnl if $as_diff "$ac_file" "$tmp/out" >/dev/null 2>&1; then dnl echo "$ac_file is unchanged" dnl else dnl rm -f "$ac_file"; mv "$tmp/out" "$ac_file" @@ -864,7 +864,7 @@ m4_define([_AC_OUTPUT_HEADER], && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || AC_MSG_ERROR([could not create $ac_file]) - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + if $as_diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then AC_MSG_NOTICE([$ac_file is unchanged]) else rm -f "$ac_file" diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index c4cff41..e8b6192 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -928,7 +928,7 @@ test -d "$at_suite_dir" || AS_ERROR([cannot create '$at_suite_dir']) # Can we diff with `/dev/null'? DU 5.0 refuses. -if diff /dev/null /dev/null >/dev/null 2>&1; then +if $as_diff /dev/null /dev/null >/dev/null 2>&1; then at_devnull=/dev/null else at_devnull=$at_suite_dir/devnull @@ -936,11 +936,11 @@ else fi # Use `diff -u' when possible. -if at_diff=`diff -u "$at_devnull" "$at_devnull" 2>&1` && test -z "$at_diff" +if at_diff=`$as_diff -u "$at_devnull" "$at_devnull" 2>&1` && test -z "$at_diff" then - at_diff='diff -u' + at_diff="$as_diff -u" else - at_diff=diff + at_diff=$as_diff fi # Get the last needed group. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 8014f15..c351bdc 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -417,6 +417,7 @@ m4_defun([_AS_PREPARE], [_AS_LINENO_PREPARE _AS_DIRNAME_PREPARE +_AS_DIFF_PREPARE _AS_ECHO_N_PREPARE[]dnl We do not need this ourselves but user code might. _AS_EXPR_PREPARE _AS_LN_S_PREPARE @@ -731,6 +732,19 @@ fi ])# _AS_BASENAME_PREPARE +# _AS_DIFF_PREPARE +# ---------------- +# Maemo and the Zaurus do not have diff. OTOH, we prefer diff +# because it avoids spurious differences due to newline encoding. +m4_defun([_AS_DIFF_PREPARE], +[if (diff $as_myself $as_myself) >/dev/null 2>&1; then + as_diff=diff +else + as_diff=cmp +fi +]) + + # AS_DIRNAME(FILE-NAME) # --------------------- # Simulate the command 'dirname FILE-NAME'. Not all systems have dirname.