1
2
dnl CHAMPLAIN_CONFIG_COMMANDS is like AC_CONFIG_COMMANDS, except that:
3
dnl
4
dnl     1) It redirects the stdout of the command to the file.
5
dnl     2) It does not recreate the file if contents did not change.
6
dnl
7
dnl (macro copied from CAIRO)
8
9
AC_DEFUN([CHAMPLAIN_CONFIG_COMMANDS],
10
[dnl
11
        AC_CONFIG_COMMANDS($1,
12
        [
13
                _config_file=$1
14
                _tmp_file=champlainconf.tmp
15
                AC_MSG_NOTICE([creating $_config_file])
16
                {
17
                        $2
18
                } >> "$_tmp_file" ||
19
                AC_MSG_ERROR([failed to write to $_tmp_file])
20
21
                if cmp -s "$_tmp_file" "$_config_file"; then
22
                  AC_MSG_NOTICE([$_config_file is unchanged])
23
                  rm -f "$_tmp_file"
24
                else
25
                  mv "$_tmp_file" "$_config_file" ||
26
                  AC_MSG_ERROR([failed to update $_config_file])
27
                fi
28
        ], $3)
29
])