output=$1
rm -f $output.T
-exec > $output.T
+
+# We used to exec > $output.T but apparently this has bugs.
+# Use a redirected subshell instead.
+(
# Define TARGET_CPU_DEFAULT if the system wants one.
# This substitutes for lots of *.h files.
fi
for def in $DEFINES; do
- echo "#ifndef $def"
- echo "# define $def"
+ echo "#ifndef $def" | sed 's/=.*//'
+ echo "# define $def" | sed 's/=/ /'
echo "#endif"
done
-# Include insn-codes.h last, because it includes machmode.h,
-# and we want EXTRA_CC_MODES to be taken into account.
-echo "#ifndef GENERATOR_FILE"
-echo "#include \"insn-codes.h\""
-echo "#include \"insn-flags.h\""
-echo "#endif"
+# If this is tm_p.h, include tm-preds.h unconditionally.
+# If this is tconfig.h or hconfig.h, include no more files.
+# Otherwise, include insn-constants.h and insn-flags.h,
+# but only if GENERATOR_FILE is not defined.
+case $output in
+ *tm_p.h)
+ echo "#include \"tm-preds.h\""
+ ;;
+ *tconfig.h | *hconfig.h)
+ ;;
+ *)
+ echo "#ifndef GENERATOR_FILE"
+ echo "# include \"insn-constants.h\""
+ echo "# include \"insn-flags.h\""
+ echo "#endif"
+ ;;
+esac
-exec >&-
+) > $output.T
# Avoid changing the actual file if possible.
-if [ -f $output ] && cmp $output.T $output; then
+if [ -f $output ] && cmp $output.T $output >/dev/null 2>&1; then
echo $output is unchanged >&2
rm -f $output.T
else