#! /bin/sh -e

# DP: Hack p/lang.c to work around bootstrap failures on alpha and mips.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        #cd ${dir}gcc && autoconf
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        #rm ${dir}gcc/configure
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0

--- gcc/p/lang.c.old	2004-07-30 06:00:30.000000000 +0000
+++ gcc/p/lang.c	2004-07-30 15:01:48.000000000 +0000
@@ -34,6 +34,22 @@
 #include "gtype-p.h"
 #endif
 
+#ifdef GCC_3_4
+#ifndef c_dialect_cxx
+/* mips and alpha use these macros ... */
+typedef enum c_language_kind
+{
+  clk_c         = 0,            /* C90, C94 or C99 */
+  clk_objc      = 1,            /* clk_c with ObjC features.  */
+  clk_cxx       = 2,            /* ANSI/ISO C++ */
+  clk_objcxx    = 3             /* clk_cxx with ObjC features.  */
+}
+c_language_kind;
+#define c_dialect_cxx()         (c_language & clk_cxx)
+#define c_dialect_objc()        (c_language & clk_objc)
+#endif
+#endif
+
 /* The following functions are not called from GPC, but needed by
    the backend. Depending on the GCC version, they're simply called
    as extern, so we can't make them static (yet). */
