#! /bin/sh -e

# DP: Install libffi with soversion 3.

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

diff -urN libffi.old/Makefile.am libffi/Makefile.am
--- libffi.old/Makefile.am	2003-10-22 01:02:59.000000000 +0200
+++ libffi/Makefile.am	2004-02-21 10:06:49.000000000 +0100
@@ -175,7 +175,7 @@
 
 AM_CFLAGS = -Wall -g -fexceptions
 
-libffi_la_LDFLAGS = -release $(VERSION) 
+libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
 
 INCLUDES = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
 
diff -urN libffi.old/Makefile.in libffi/Makefile.in
--- libffi.old/Makefile.in	2003-11-24 00:52:28.000000000 +0100
+++ libffi/Makefile.in	2004-02-21 10:06:49.000000000 +0100
@@ -226,7 +226,7 @@
 
 AM_CFLAGS = -Wall -g -fexceptions
 
-libffi_la_LDFLAGS = -release $(VERSION) 
+libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
 
 INCLUDES = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
diff -urN libffi.old/libtool-version libffi/libtool-version
--- libffi.old/libtool-version	1970-01-01 01:00:00.000000000 +0100
+++ libffi/libtool-version	2004-02-21 10:06:49.000000000 +0100
@@ -0,0 +1,6 @@
+# This file is used to maintain libtool version info for libffi.  See
+# the libtool manual to understand the meaning of the fields.  This is
+# a separate file so that version updates don't involve re-running
+# automake.
+# CURRENT:REVISION:AGE
+3:0:0
