#! /bin/sh -e

# DP: Allows libffi to be installed

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
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0

--- libffi/libtool-version	Tue Apr 17 22:57:22 2001
+++ libffi/libtool-version	Tue Apr 17 22:36:34 2001
@@ -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
+2:0:0
--- libffi/Makefile.am~	2004-05-30 16:29:01.000000000 +0200
+++ libffi/Makefile.am	2004-05-30 16:30:31.000000000 +0200
@@ -179,7 +179,7 @@
 
 AM_CFLAGS = -fexceptions
 
-libffi_la_LDFLAGS = -release $(VERSION)  -Wl,-O1
+libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`  -Wl,-O1
 
 INCLUDES = -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
 
--- libffi/Makefile.in~	2004-05-30 16:29:01.000000000 +0200
+++ libffi/Makefile.in	2004-05-30 16:31:05.000000000 +0200
@@ -223,7 +223,7 @@
 
 AM_CFLAGS = -fexceptions
 
-libffi_la_LDFLAGS = -release $(VERSION) -Wl,-O1
+libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` -Wl,-O1
 
 INCLUDES = -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
