#! /bin/sh -e

# DP: libjava-mips patch from Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>

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

# append the patch here and adjust the -p? flag in the patch calls.

--- libjava/include/mips-signal.h.old	2003-10-22 18:35:16.000000000 +0200
+++ libjava/include/mips-signal.h	2003-12-13 18:29:53.000000000 +0100
@@ -80,7 +80,7 @@
     kact.k_sa_handler = catch_segv;                  \
     kact.k_sa_flags = SA_SIGINFO | SA_NODEFER;       \
     sigemptyset (&kact.k_sa_mask);                   \
-    syscall (SYS_sigaction, SIGSEGV, &kact, NULL);   \
+    syscall (__NR_sigaction, SIGSEGV, &kact, NULL);  \
   }                                                  \
 while (0)
 								
