Discussion:
How to set AR and ARFLAGS for Apple platforms?
Jeffrey Walton
2017-11-04 05:01:36 UTC
Permalink
Hi Everyone,

I'm having trouble selecting the preferred AR in Makefiles on Apple
systems. The default value (even when calling AM_PROG_AR) is:

$ egrep 'AR =|ARFLAGS =' Makefile
AMTAR = $${TAR-tar}
AR = ar
ac_ct_AR = ar

On Apple systems we need Apple's libtool at /usr/bin/libtool (not to
be confused with Autotool's libtool). We need it for fat libraries and
cross-compiling for some platforms.

I tried the following in my configure.ac:

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

But it does not fix all of them:

autoupdate && autoreconf --force --install --warnings=all
./configure
...

And then:

$ egrep 'AR =|ARFLAGS =' Makefile
AMTAR = $${TAR-tar}
AR = /usr/bin/libtool
ARFLAGS = -static -o
ac_ct_AR = ar

How does one set AR and ARFLAGS for Apple platforms?

Thanks in advance,

Jeff

Loading...