#! /bin/sh -e

# DP: build libffi without building libgcj

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

--- configure.in.orig	2004-08-03 00:53:36.000000000 +0200
+++ configure.in	2004-08-03 00:52:35.000000000 +0200
@@ -136,8 +136,7 @@
 host_tools="texinfo byacc flex bison binutils gas ld gcc sid sim gdb make patch prms send-pr gprof etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool diff rcs fileutils shellutils time textutils wdiff find uudecode hello tar gzip indent recode release sed utils guile perl gawk findutils gettext zip fastjar"
 
 # libgcj represents the runtime libraries only used by gcj.
-libgcj="target-libffi \
-	target-boehm-gc \
+libgcj="target-boehm-gc \
 	target-zlib \
 	target-qthreads \
 	target-libjava"
@@ -150,6 +150,7 @@
 		target-libstdc++-v3 \
 		target-libf2c \
 		${libgcj} \
+		target-libffi \
 		target-libobjc"
 
 # these tools are built using the target libraries, and are intended to
--- configure~	2004-08-28 02:31:04.000000000 +0200
+++ configure	2004-08-28 10:55:28.000000000 +0200
@@ -876,8 +876,7 @@
 host_tools="texinfo byacc flex bison binutils gas ld gcc sid sim gdb make patch prms send-pr gprof etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool diff rcs fileutils shellutils time textutils wdiff find uudecode hello tar gzip indent recode release sed utils guile perl gawk findutils gettext zip fastjar"
 
 # libgcj represents the runtime libraries only used by gcj.
-libgcj="target-libffi \
-	target-boehm-gc \
+libgcj="target-boehm-gc \
 	target-zlib \
 	target-qthreads \
 	target-libjava"
@@ -891,6 +890,7 @@
 		target-libstdc++-v3 \
 		target-libf2c \
 		${libgcj} \
+		target-libffi \
 		target-libobjc"
 
 # these tools are built using the target libraries, and are intended to
