blob: 03007aa4f4e010e3fefc89015c26c9b17d85a357 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Fix cross link using autoconf detected AR
2
3If building on 32bit host and creating 64bit libraries, the target
4package builds should not invoke the 32bit hosts's ar. Specifically
5you will get an error message like:
6
7x86_64-linux-gcc -m64 --sysroot=/opt/qemux86-64/tmp/sysroots/qemux86-64 -g -o test test.o libnewt.a -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lslang
8libnewt.a: could not read symbols: Archive has no index; run ranlib to add one
9collect2: error: ld returned 1 exit status
10
11Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
12
13Upstream-Status: Pending
14
15Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
16---
17 Makefile.in | 3 ++-
18 configure.ac | 4 ++++
19 2 files changed, 6 insertions(+), 1 deletion(-)
20
21diff --git a/Makefile.in b/Makefile.in
22--- a/Makefile.in
23+++ b/Makefile.in
24@@ -7,6 +7,7 @@ CFLAGS = @CFLAGS@
25 LDFLAGS = @LDFLAGS@
26 CPPFLAGS = -D_GNU_SOURCE @CPPFLAGS@
27 GNU_LD = @GNU_LD@
28+AR = @AR@
29
30 VERSION = @VERSION@
31 TAG = r$(subst .,-,$(VERSION))
32@@ -109,7 +110,7 @@ whiptcl.$(SOEXT): $(WHIPTCLOBJS) $(LIBNEWTSH)
33 $(CC) -shared $(SHCFLAGS) $(LDFLAGS) -o whiptcl.$(SOEXT) $(WHIPTCLOBJS) -L. -lnewt $(LIBTCL) -lpopt $(LIBS)
34
35 $(LIBNEWT): $(LIBOBJS)
36- ar rv $@ $^
37+ $(AR) rv $@ $^
38
39 newt.o $(SHAREDDIR)/newt.o: newt.c Makefile
40
41diff --git a/configure.ac b/configure.ac
42index 92e6da8..cd83d57 100644
43--- a/configure.ac
44+++ b/configure.ac
45@@ -15,6 +15,10 @@ AC_PROG_INSTALL
46 AC_PROG_LN_S
47 AC_PROG_GREP
48 AC_SYS_LARGEFILE
49+AN_MAKEVAR([AR], [AC_PROG_AR])
50+AN_PROGRAM([ar], [AC_PROG_AR])
51+AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
52+AC_PROG_AR
53
54 # Are we using GNU ld?
55 AC_MSG_CHECKING([for GNU ld])
56--
571.8.1.2
58