bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unable to override value of AR set by gnulib macro?


From: Bruno Haible
Subject: Re: Unable to override value of AR set by gnulib macro?
Date: Fri, 2 Sep 2011 22:20:26 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

John W. Eaton wrote:
> GNU Octave's configure script used to allow users to set AR using
> 
>   ./configure AR=...
> 
> but that stopped working recently.

Oh, I see. Octave has a macro OCTAVE_PROG_AR like this:

AC_DEFUN([OCTAVE_PROG_AR],
[if test -z "$AR"; then
  AR=ar
fi
AC_SUBST(AR)

if test -z "$ARFLAGS"; then
  ARFLAGS="rc"
fi
AC_SUBST(ARFLAGS)
])

> it seems to me that it would be
> better to allow the user to set AR and ARFLAGS from the environment
> and only set default values if these variables are not already set.

Yes. Like we do for other build tool variables. Also, when binutils
is compiled for cross-compiling, the cross-compiler specific version
should be used.

I've pushed these two patches:


2011-09-02  Bruno Haible  <address@hidden>

        Find 'ar' program that fits with --host argument.
        * m4/gnulib-common.m4 (gl_PROG_AR_RANLIB): Use AC_CHECK_TOOL.

--- m4/gnulib-common.m4.orig    Fri Sep  2 21:58:43 2011
+++ m4/gnulib-common.m4 Fri Sep  2 21:58:32 2011
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 29
+# gnulib-common.m4 serial 30
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -230,8 +230,9 @@
      ARFLAGS='-o'
      RANLIB=':'
     ],
-    [dnl Use the Automake-documented default values for AR and ARFLAGS.
-     AR='ar'
+    [dnl Use the Automake-documented default values for AR and ARFLAGS,
+     dnl but prefer ${host}-ar over ar (useful for cross-compiling).
+     AC_CHECK_TOOL([AR], [ar], [ar])
      ARFLAGS='cru'
      dnl Use the ranlib program if it is available.
      AC_PROG_RANLIB


2011-09-02  Bruno Haible  <address@hidden>

        Allow the user to override the choice of AR, ARFLAGS, RANLIB.
        * m4/gnulib-common.m4 (gl_PROG_AR_RANLIB): Don't override the given
        values of AR, ARFLAGS, RANLIB.
        Reported by John W. Eaton <address@hidden> for Octave.

*** m4/gnulib-common.m4.orig    Fri Sep  2 22:14:10 2011
--- m4/gnulib-common.m4 Fri Sep  2 22:14:07 2011
***************
*** 213,218 ****
--- 213,220 ----
  
  # gl_PROG_AR_RANLIB
  # Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
+ # The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
+ # the values.
  AC_DEFUN([gl_PROG_AR_RANLIB],
  [
    dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
***************
*** 220,244 ****
    dnl library formats. In particular, the GNU binutils programs ar, ranlib
    dnl produce libraries that work only with gcc, not with cc.
    AC_REQUIRE([AC_PROG_CC])
!   AC_EGREP_CPP([Amsterdam],
      [
  #ifdef __ACK__
  Amsterdam
  #endif
!     ],
!     [AR='cc -c.a'
!      ARFLAGS='-o'
!      RANLIB=':'
!     ],
!     [dnl Use the Automake-documented default values for AR and ARFLAGS,
!      dnl but prefer ${host}-ar over ar (useful for cross-compiling).
!      AC_CHECK_TOOL([AR], [ar], [ar])
!      ARFLAGS='cru'
!      dnl Use the ranlib program if it is available.
!      AC_PROG_RANLIB
      ])
    AC_SUBST([AR])
    AC_SUBST([ARFLAGS])
  ])
  
  # AC_PROG_MKDIR_P
--- 222,268 ----
    dnl library formats. In particular, the GNU binutils programs ar, ranlib
    dnl produce libraries that work only with gcc, not with cc.
    AC_REQUIRE([AC_PROG_CC])
!   AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
      [
+       AC_EGREP_CPP([Amsterdam],
+         [
  #ifdef __ACK__
  Amsterdam
  #endif
!         ],
!         [gl_cv_c_amsterdam_compiler=yes],
!         [gl_cv_c_amsterdam_compiler=no])
      ])
+   if test -z "$AR"; then
+     if test $gl_cv_c_amsterdam_compiler = yes; then
+       AR='cc -c.a'
+       if test -z "$ARFLAGS"; then
+         ARFLAGS='-o'
+       fi
+     else
+       dnl Use the Automake-documented default values for AR and ARFLAGS,
+       dnl but prefer ${host}-ar over ar (useful for cross-compiling).
+       AC_CHECK_TOOL([AR], [ar], [ar])
+       if test -z "$ARFLAGS"; then
+         ARFLAGS='cru'
+       fi
+     fi
+   else
+     if test -z "$ARFLAGS"; then
+       ARFLAGS='cru'
+     fi
+   fi
    AC_SUBST([AR])
    AC_SUBST([ARFLAGS])
+   if test -z "$RANLIB"; then
+     if test $gl_cv_c_amsterdam_compiler = yes; then
+       RANLIB=':'
+     else
+       dnl Use the ranlib program if it is available.
+       AC_PROG_RANLIB
+     fi
+   fi
+   AC_SUBST([RANLIB])
  ])
  
  # AC_PROG_MKDIR_P
-- 
In memoriam Robert Mensah <http://en.wikipedia.org/wiki/Robert_Mensah>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]