[configure.in] Define CAIRO_CONFIG_COMMANDS for easier file creation

This commit is contained in:
Behdad Esfahbod 2008-09-01 22:15:03 -04:00
parent 5f1993c53a
commit 7510aa8033

View file

@ -204,6 +204,32 @@ if test "x$PKG_CONFIG" = x; then
fi
dnl ===========================================================================
dnl
dnl CAIRO_CONFIG_COMMANDS is like AC_CONFIG_COMMANDS, except that:
dnl
dnl 1) It redirects the stdout of the command to the file.
dnl 2) It does not recreate the file if contents didn't change.
dnl
AC_DEFUN([CAIRO_CONFIG_COMMANDS], [
AC_CONFIG_COMMANDS($1,
[
_config_file=$1
_tmp_file=$1.tmp
AC_MSG_NOTICE([creating $_config_file])
{
echo "/* Generated by configure. Do not edit */"
$2
} >> "$_tmp_file"
if cmp -s "$_tmp_file" "$_config_file"; then
AC_MSG_NOTICE([$_config_file is unchanged])
rm -f "$_tmp_file"
else
mv "$_tmp_file" "$_config_file"
fi
], $3)
])
dnl ===========================================================================
dnl
dnl cairo_cache_version should be increased every time that the backend
@ -1025,64 +1051,36 @@ fi
dnl ===========================================================================
AC_CONFIG_COMMANDS([src/cairo-features.h],
CAIRO_CONFIG_COMMANDS([src/cairo-features.h],
[
featuresfile=src/cairo-features.h
outfile=$featuresfile.tmp
AC_MSG_NOTICE([creating $featuresfile])
cat > $outfile <<_EOF
/* Generated by configure. Do not edit */
#ifndef CAIRO_FEATURES_H
#define CAIRO_FEATURES_H
_EOF
echo '#ifndef CAIRO_FEATURES_H'
echo '#define CAIRO_FEATURES_H'
echo ''
for FEATURE in $CAIRO_FEATURES; do
echo "#define CAIRO_HAS_$FEATURE 1" >> $outfile
done
echo '' >> $outfile
echo "#define CAIRO_HAS_$FEATURE 1"
done | LANG=C sort
echo ''
for FEATURE in $CAIRO_NO_FEATURES; do
echo "/*#undef CAIRO_HAS_$FEATURE */" >> $outfile
done
echo '' >> $outfile
echo '#endif' >> $outfile
if cmp -s $outfile $featuresfile; then
AC_MSG_NOTICE([$featuresfile is unchanged])
rm -f $outfile
else
mv $outfile $featuresfile
fi
echo "/*#undef CAIRO_HAS_$FEATURE */"
done | LANG=C sort
echo ''
echo '#endif'
],[
CAIRO_FEATURES='$CAIRO_FEATURES'
CAIRO_NO_FEATURES='$CAIRO_NO_FEATURES'
])
AC_CONFIG_COMMANDS([src/cairo-no-features.h],
CAIRO_CONFIG_COMMANDS([src/cairo-no-features.h],
[
nofeaturesfile=src/cairo-no-features.h
outfile=$nofeaturesfile.tmp
AC_MSG_NOTICE([creating $nofeaturesfile])
cat > $outfile <<_EOF
/* Generated by configure. Do not edit */
#ifndef CAIRO_NO_FEATURES_H
#define CAIRO_NO_FEATURES_H
/* This is a dummy header, to trick gtk-doc only */
_EOF
echo '#ifndef CAIRO_NO_FEATURES_H'
echo '#define CAIRO_NO_FEATURES_H'
echo ''
echo '/* This is a dummy header, to trick gtk-doc only */'
echo ''
for FEATURE in $CAIRO_NO_FEATURES; do
echo "#define CAIRO_HAS_$FEATURE 1" >> $outfile
echo "#define CAIRO_HAS_$FEATURE 1"
done
echo '' >> $outfile
echo '#endif' >> $outfile
if cmp -s $outfile $nofeaturesfile; then
AC_MSG_NOTICE([$nofeaturesfile is unchanged])
rm -f $outfile
else
mv $outfile $nofeaturesfile
fi
echo ''
echo '#endif'
],[
CAIRO_NO_FEATURES='$CAIRO_NO_FEATURES'
])