Autotools is selecting the wrong AR
and ARFLAGS
for the platform. It happens with (and without) AM_PROG_AR
in Makefile.am
: [...] Autoconf should be using Apple's libtool
I understand that you would like configure
to select and use OS X libtool
for creating archives, and that doing so would afford you some advantages. POSIX ar
may even be an unsuitable tool for your particular job, but I reject the assertion that /usr/bin/ar
is the wrong tool for the platform. Apple provides that tool in OS X, and it works as advertised, even if the advertised behavior is more circumscribed than you want or need.
It should be something like:
AR = /usr/bin/libtool
ARFLAGS = -static -o
Maybe. Although Mac libtool
can perform the same function as ar
, it is not a drop-in replacement. That's what configure
complains about when you specify those variables on its command line (but only when you also have AM_PROG_AR
). In particular, if you examine the configure
script you will probably find that it tests the behavior of the tool designated by AR
with use of a command such as this:
$AR cru libconftest.a conftest.$ac_objext >&5
It will also have a fallback for the interface provided by Microsoft's lib
utility. Both of these are associated with the AM_PROG_AR
macro.
Note that the test uses hardcoded flags for the main options, not any $ARFLAGS
that may have been specified. It is specifically testing the program's command-line interface, and Mac libtool
does not provide one that is recognized.
You have several options:
Let the build system continue to use AM_PROG_AR
, and provide a wrapper script for Mac libtool
that mimics the traditional command-line interface of POSIX ar
. When configuring for Mac, designate the wrapper script to configure
as the value of variable AR
.
./configure AR=my-mac-libtool-wrapper
If the build system does not use AM_PROG_AR
then by default the AR
and ARFLAGS
variables will mean nothing to configure
, but you can specify them directly to make
:
make AR=/usr/bin/libtool ARFLAGS="-static -o"
Alternatively, if the build system does not use AM_PROG_AR
then you can add your own code to make configure
handle the AR
and ARFLAGS
variables. The minimum to get configure
to recognize them and pass them on to the Makefile without performing any actual tests would probably be:
AC_ARG_VAR([AR], [Specifies the archiver to use])
AC_ARG_VAR([ARFLAGS], [Specifies the archiver flags to use])
AM_PROG_AR
inconfigure.ac
? – Bruni./configure AR=/usr/bin/libtool ARFLAGS="-static -o"
. There's then a chance that you'll override what the script would determine for itself. – StanfordAR=/usr/bin/libtool ARFLAGS='-static -o' ./configure
dies early. The message ischecking the archiver (/usr/bin/libtool) interface... unknown
and thenconfigure: error: could not determine /usr/bin/libtool interface
. That's kind of why we've been trying to fix it in the script. – Perfect