Index: libffi/ChangeLog.libffi
===================================================================
--- libffi.orig/ChangeLog.libffi
+++ libffi/ChangeLog.libffi
@@ -1,3 +1,16 @@
+2009-12-29  Kay Tietz  <ktietz70@googlemail.com>
+
+	* testsuite/libffi.call/ffitest.h,
+	testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRuLL): Fix
+	definitions.
+
+2009-12-25  Carlo Bramini  <carlo.bramix@libero.it>
+
+	* configure.ac (AM_LTLDFLAGS): Define for windows hosts.
+	* Makefile.am (libffi_la_LDFLAGS): Add AM_LTLDFLAGS.
+	* configure: Rebuilt.
+	* Makefile.in: Rebuilt.
+
 2009-12-24  Anthony Green  <green@redhat.com>
 
 	* testsuite/libffi.call/huge_struct.c: Fix printf format, and
Index: libffi/Makefile.am
===================================================================
--- libffi.orig/Makefile.am
+++ libffi/Makefile.am
@@ -175,7 +175,7 @@ nodist_libffi_convenience_la_SOURCES = $
 
 AM_CFLAGS = -Wall -g -fexceptions
 
-libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
+libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(AM_LTLDFLAGS)
 
 AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
 AM_CCASFLAGS = $(AM_CPPFLAGS)
Index: libffi/configure.ac
===================================================================
--- libffi.orig/configure.ac
+++ libffi/configure.ac
@@ -85,6 +85,8 @@ case "$host" in
 	;;
   i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*)
 	TARGET=X86_WIN32; TARGETDIR=x86
+	# All mingw/cygwin/win32 builds require this for sharedlib
+	AM_LTLDFLAGS="-no-undefined"
 	;;
   i?86-*-darwin*)
 	TARGET=X86_DARWIN; TARGETDIR=x86
@@ -163,6 +165,7 @@ case "$host" in
 esac
 
 AC_SUBST(AM_RUNTESTFLAGS)
+AC_SUBST(AM_LTLDFLAGS)
 
 if test $TARGETDIR = unknown; then
   AC_MSG_ERROR(["libffi has not been ported to $host."])
Index: libffi/configure
===================================================================
--- libffi.orig/configure
+++ libffi/configure
@@ -847,6 +847,7 @@ SPARC_FALSE
 SPARC_TRUE
 MIPS_FALSE
 MIPS_TRUE
+AM_LTLDFLAGS
 AM_RUNTESTFLAGS
 TESTSUBDIR_FALSE
 TESTSUBDIR_TRUE
@@ -4772,13 +4773,13 @@ if test "${lt_cv_nm_interface+set}" = se
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:4775: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:4776: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4778: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:4779: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4781: output\"" >&5)
+  (eval echo "\"\$as_me:4782: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -5984,7 +5985,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 5987 "configure"' > conftest.$ac_ext
+  echo '#line 5988 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7837,11 +7838,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7840: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7841: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7844: \$? = $ac_status" >&5
+   echo "$as_me:7845: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8176,11 +8177,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8179: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8180: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8183: \$? = $ac_status" >&5
+   echo "$as_me:8184: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8281,11 +8282,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8284: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8285: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8288: \$? = $ac_status" >&5
+   echo "$as_me:8289: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8336,11 +8337,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8339: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8340: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8343: \$? = $ac_status" >&5
+   echo "$as_me:8344: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11139,7 +11140,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11142 "configure"
+#line 11143 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11235,7 +11236,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11238 "configure"
+#line 11239 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12184,6 +12185,8 @@ case "$host" in
 	;;
   i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*)
 	TARGET=X86_WIN32; TARGETDIR=x86
+	# All mingw/cygwin/win32 builds require this for sharedlib
+	AM_LTLDFLAGS="-no-undefined"
 	;;
   i?86-*-darwin*)
 	TARGET=X86_DARWIN; TARGETDIR=x86
@@ -12263,6 +12266,7 @@ esac
 
 
 
+
 if test $TARGETDIR = unknown; then
   { { $as_echo "$as_me:$LINENO: error: \"libffi has not been ported to $host.\"" >&5
 $as_echo "$as_me: error: \"libffi has not been ported to $host.\"" >&2;}
Index: libffi/Makefile.in
===================================================================
--- libffi.orig/Makefile.in
+++ libffi/Makefile.in
@@ -264,6 +264,7 @@ distcleancheck_listfiles = find . -type 
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
 AMTAR = @AMTAR@
+AM_LTLDFLAGS = @AM_LTLDFLAGS@
 AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
@@ -478,7 +479,7 @@ nodist_libffi_la_SOURCES = $(am__append_
 libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
 nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
 AM_CFLAGS = -Wall -g -fexceptions
-libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
+libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(AM_LTLDFLAGS)
 AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
 AM_CCASFLAGS = $(AM_CPPFLAGS)
 all: fficonfig.h
Index: libffi/testsuite/libffi.call/ffitest.h
===================================================================
--- libffi.orig/testsuite/libffi.call/ffitest.h
+++ libffi/testsuite/libffi.call/ffitest.h
@@ -46,9 +46,9 @@
 #endif
 
 /* MinGW kludge.  */
-#ifdef WIN64
-#define PRIdLL "PRId64"
-#define PRIuLL "PRIu64"
+#ifdef _WIN64
+#define PRIdLL "I64d"
+#define PRIuLL "I64u"
 #else
 #define PRIdLL "lld"
 #define PRIuLL "llu"
Index: libffi/testsuite/libffi.special/ffitestcxx.h
===================================================================
--- libffi.orig/testsuite/libffi.special/ffitestcxx.h
+++ libffi/testsuite/libffi.special/ffitestcxx.h
@@ -45,9 +45,9 @@
 
 
 /* MinGW kludge.  */
-#ifdef WIN64
-#define PRIdLL "PRId64"
-#define PRIuLL "PRIu64"
+#ifdef _WIN64
+#define PRIdLL "I64d"
+#define PRIuLL "I64u"
 #else
 #define PRIdLL "lld"
 #define PRIuLL "llu"
