Unable to set AR and ARFLAGS for operating systems like OS X

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to set AR and ARFLAGS for operating systems like OS X

Jeffrey Walton-3
It looks like Autotools is not equipped to handle changes to AR and
ARFLAGS. There is no AC_PROG_AR macro to find the correct AR and
ARFLAGS for the platform and compiler.

Trying to hack AR configuration information in configure.ac produces a
non-working configuration due to hard-coding ARFLAGS like "cru":

  IS_APPLE=`echo $build | $EGREP -i -c 'apple'`
  if test "$IS_APPLE" -ne "0"; then
     AC_SUBST([AR], ["/usr/bin/libtool"])
     AC_SUBST([ARFLAGS], ["-static -o"])
     AC_SUBST([ac_ct_AR], ["/usr/bin/libtool"])
  fi

OS X needs the following flags, otherwise building fat libraries and
some cross-compiles fail.

  AR = /usr/bin/libtool
  ARFLAGS = -static -o

Usage of AR and ARFLAGS on OS X must be:

  $(AR) $(ARFLAGS) <library name> ...

Similar problems are encountered on Solaris with SunCC. We need the
following on the platform when SunCC is the compiler.

  AR = $(CXX)
  ARFLAGS = -xar -o
  RANLIB = true

The limitations are not documented in the Autoconf or Automake
manuals, so problems are reported against individual projects. Users
don't understand why they can't build fat libraries and why some
builds fail. The don't realize its an Autotools problem, and not a
project problem.

The issue also runs afoul of GNU's "user choice" philosophy. Users
should be able to select the appropriate tool for the platform and
compiler.

Reply | Threaded
Open this post in threaded view
|

Re: Unable to set AR and ARFLAGS for operating systems like OS X

Jeffrey Walton-3
On Sat, Nov 4, 2017 at 12:30 PM, Jeffrey Walton <[hidden email]> wrote:

> It looks like Autotools is not equipped to handle changes to AR and
> ARFLAGS. There is no AC_PROG_AR macro to find the correct AR and
> ARFLAGS for the platform and compiler.
>
> Trying to hack AR configuration information in configure.ac produces a
> non-working configuration due to hard-coding ARFLAGS like "cru":
>
>   IS_APPLE=`echo $build | $EGREP -i -c 'apple'`
>   if test "$IS_APPLE" -ne "0"; then
>      AC_SUBST([AR], ["/usr/bin/libtool"])
>      AC_SUBST([ARFLAGS], ["-static -o"])
>      AC_SUBST([ac_ct_AR], ["/usr/bin/libtool"])
>   fi
>
> OS X needs the following flags, otherwise building fat libraries and
> some cross-compiles fail.
>
>   AR = /usr/bin/libtool
>   ARFLAGS = -static -o
>
> Usage of AR and ARFLAGS on OS X must be:
>
>   $(AR) $(ARFLAGS) <library name> ...
>
> Similar problems are encountered on Solaris with SunCC. We need the
> following on the platform when SunCC is the compiler.
>
>   AR = $(CXX)
>   ARFLAGS = -xar -o
>   RANLIB = true

In case its need for Apple platforms:

   $ AR=/usr/bin/libtool ARFLAGS='-static -o' ./configure
   checking for a BSD-compatible install... /usr/bin/install -c
   ...
   checking dependency style of gcc... gcc3
   checking the archiver (/usr/bin/libtool) interface... unknown
   configure: error: could not determine /usr/bin/libtool interface

And:

   $ /usr/bin/libtool -V
   Apple Inc. version cctools-862

/usr/bin/libtool --version, -v and --help produce errors. -V is the
only one that works.

Jeff