Change the ranlib detection
authorIan Lynagh <ian@well-typed.com>
Tue, 2 Jul 2013 23:16:16 +0000 (00:16 +0100)
committerIan Lynagh <ian@well-typed.com>
Wed, 3 Jul 2013 11:13:57 +0000 (12:13 +0100)
On Windows, the ranlib in the path may not be the right ranlib (it may
be the 32bit ranlib when we are making a Win64 compiler, or vice-versa).
Therefore we can't leave it up to libffi to detect the right ranlib, but
need to tell it which ranlib to use. This means that we need to find
ranlib even if we don't actually need it ourselves.

aclocal.m4
configure.ac
ghc.mk
libffi/ghc.mk
mk/config.mk.in
rules/build-package-data.mk

index af492df..0852dbf 100644 (file)
@@ -1096,30 +1096,42 @@ AC_SUBST([ArArgs], ["$fp_prog_ar_args"])
 
 # FP_PROG_AR_NEEDS_RANLIB
 # -----------------------
-# Sets the output variable RANLIB to "ranlib" if it is needed and found,
-# to "true" otherwise.
-AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],
-[AC_REQUIRE([FP_PROG_AR_IS_GNU])
-AC_REQUIRE([FP_PROG_AR_ARGS])
-AC_REQUIRE([AC_PROG_CC])
-AC_CACHE_CHECK([whether ranlib is needed], [fp_cv_prog_ar_needs_ranlib],
-[if test $fp_prog_ar_is_gnu = yes; then
-  fp_cv_prog_ar_needs_ranlib=no
-elif echo $TargetPlatform | grep "^.*-apple-darwin$"  > /dev/null 2> /dev/null; then
-  # It's quite tedious to check for Apple's crazy timestamps in .a files,
-  # so we hardcode it.
-  fp_cv_prog_ar_needs_ranlib=yes
-elif echo $fp_prog_ar_args | grep "s" > /dev/null 2> /dev/null; then
-  fp_cv_prog_ar_needs_ranlib=no
-else
-  fp_cv_prog_ar_needs_ranlib=yes
-fi])
-if test $fp_cv_prog_ar_needs_ranlib = yes; then
-   AC_PROG_RANLIB
-else
-  RANLIB="true"
-  AC_SUBST([RANLIB])
-fi
+# Sets the output variable RANLIB_CMD to "ranlib" if it is needed and
+# found, to "true" otherwise. Sets REAL_RANLIB_CMD to the ranlib program,
+# even if we don't need ranlib (libffi might still need it).
+AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[
+    AC_REQUIRE([FP_PROG_AR_IS_GNU])
+    AC_REQUIRE([FP_PROG_AR_ARGS])
+    AC_REQUIRE([AC_PROG_CC])
+
+    AC_PROG_RANLIB
+
+    if test $fp_prog_ar_is_gnu = yes
+    then
+        fp_cv_prog_ar_needs_ranlib=no
+    elif test "$TargetOS_CPP" = "darwin"
+    then
+        # It's quite tedious to check for Apple's crazy timestamps in
+        # .a files, so we hardcode it.
+        fp_cv_prog_ar_needs_ranlib=yes
+    else
+        case $fp_prog_ar_args in
+        *s*)
+            fp_cv_prog_ar_needs_ranlib=no;;
+        *)
+            fp_cv_prog_ar_needs_ranlib=yes;;
+        esac
+    fi
+
+    REAL_RANLIB_CMD="$RANLIB"
+    if test $fp_cv_prog_ar_needs_ranlib = yes
+    then
+        RANLIB_CMD="$RANLIB"
+    else
+        RANLIB_CMD="true"
+    fi
+    AC_SUBST([REAL_RANLIB_CMD])
+    AC_SUBST([RANLIB_CMD])
 ])# FP_PROG_AR_NEEDS_RANLIB
 
 
index 7bbeca6..8d8136f 100644 (file)
@@ -328,6 +328,7 @@ then
     CC="${mingwbin}gcc.exe"
     LD="${mingwbin}ld.exe"
     NM="${mingwbin}nm.exe"
+    RANLIB="${mingwbin}ranlib.exe"
     OBJDUMP="${mingwbin}objdump.exe"
     fp_prog_ar="${mingwbin}ar.exe"
 
diff --git a/ghc.mk b/ghc.mk
index 87b6ac8..4754ad6 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -815,7 +815,7 @@ define installLibsTo
                case $$i in \
                  *.a) \
                    $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,$2); \
-                   $(RANLIB) $2/`basename $$i` ;; \
+                   $(RANLIB_CMD) $2/`basename $$i` ;; \
                  *.dll) \
                    $(call INSTALL_PROGRAM,$(INSTALL_OPTS),$$i,$2) ; \
                    $(STRIP_CMD) $2/`basename $$i` ;; \
index ffef273..d761a43 100644 (file)
@@ -86,6 +86,7 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
            LD=$(LD) \
            AR=$(AR_STAGE1) \
            NM=$(NM) \
+           RANLIB=$(REAL_RANLIB_CMD) \
         CFLAGS="$(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -w" \
         LDFLAGS="$(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE1) -w" \
         "$(SHELL)" ./configure \
index 1235798..2e36be5 100644 (file)
@@ -636,7 +636,8 @@ LN_S                        = @LN_S@
 MV                     = mv
 PERL                   = @PerlCmd@
 PIC                    = pic
-RANLIB                 = @RANLIB@
+RANLIB_CMD = @RANLIB_CMD@
+REAL_RANLIB_CMD = @REAL_RANLIB_CMD@
 SED                    = @SedCmd@
 SHELL                  = /bin/sh
 
index 2429942..82a2535 100644 (file)
@@ -86,7 +86,7 @@ endif
 
 $1_$2_CONFIGURE_OPTS += --configure-option=--with-cc="$$(CC_STAGE$3)"
 $1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)"
-$1_$2_CONFIGURE_OPTS += --with-ranlib="$$(RANLIB)"
+$1_$2_CONFIGURE_OPTS += --with-ranlib="$$(REAL_RANLIB_CMD)"
 $1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)")
 $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)")