From c6a2f41369bb4549bfaadf1120ccacd884b0b70f Mon Sep 17 00:00:00 2001
From: Conrad Kostecki <ck@bl4ckb0x.de>
Date: Sun, 22 Nov 2020 00:55:36 +0100
Subject: [PATCH] Add support for setting AR

By default, the command 'ar' is called. Is should be possible, as with
'CC', to override that value and set an own AR.

Signed-off-by: Conrad Kostecki <conrad@kostecki.com>
---
 configure       | 11 +++++++++++
 src/Makefile.in |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 1b85d113..78535332 100755
--- a/configure
+++ b/configure
@@ -146,6 +146,7 @@ generate_stdout()
 	echo "           SRC_DIR = $BUILD_DIR"
 	echo "            SYSTEM = $SYSTEM"
 	echo "           PROFILE = $PROFILE"
+	echo "                AR = $AR"
 	echo "                CC = $CC"
 	echo "          COMPILER = $COMPILER"
 	echo "            CFLAGS = $CFLAGS"
@@ -215,6 +216,7 @@ for option; do
 		echo "  --cores=N                Specify number of cores available on target machine"
 		echo
 		echo "The following environment variables may be used:"
+		echo "   AR       AR archiver command"
 		echo "   CC       C compiler command"
 		echo "   CFLAGS   C compiler flags"
 		echo "   LDFLAGS  Linker flags"
@@ -645,6 +647,15 @@ if test ! -x "${CC}"; then
 fi
 assert "$CC" "not found"
 
+printf "Finding suitable archiver........"
+if test ! -x "${AR}"; then
+	AR=`pathsearch "${AR:-ar}"`
+	if test -z "$AR" -o ! -x "$AR"; then
+		AR=`pathsearch "${AR:-ar}"`
+	fi
+fi
+assert "$AR" "not found"
+
 cat << EOF > .1.c
 #include <stdio.h>
 int main(void) {
diff --git a/src/Makefile.in b/src/Makefile.in
index 0b7ae7b6..73788497 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -25,7 +25,7 @@ libck.so: $(OBJECTS)
 	$(LD) $(LDFLAGS) -o $(TARGET_DIR)/libck.so $(OBJECTS)
 
 libck.a: $(OBJECTS)
-	ar rcs $(TARGET_DIR)/libck.a $(OBJECTS)
+	$(AR) rcs $(TARGET_DIR)/libck.a $(OBJECTS)
 
 ck_array.o: $(INCLUDE_DIR)/ck_array.h $(SDIR)/ck_array.c
 	$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_array.o $(SDIR)/ck_array.c
From 866c2af332a075cc83af78b184be0d5e6152de13 Mon Sep 17 00:00:00 2001
From: Olivier Houchard <cognet@ci0.org>
Date: Sun, 22 Nov 2020 01:16:10 +0100
Subject: [PATCH] build: Make the lookup for an archiver report success.

Move the code looking for ar outside the compiler checking code, and make
it report success if found.
---
 configure | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 78535332..16a8f64f 100755
--- a/configure
+++ b/configure
@@ -647,15 +647,6 @@ if test ! -x "${CC}"; then
 fi
 assert "$CC" "not found"
 
-printf "Finding suitable archiver........"
-if test ! -x "${AR}"; then
-	AR=`pathsearch "${AR:-ar}"`
-	if test -z "$AR" -o ! -x "$AR"; then
-		AR=`pathsearch "${AR:-ar}"`
-	fi
-fi
-assert "$AR" "not found"
-
 cat << EOF > .1.c
 #include <stdio.h>
 int main(void) {
@@ -736,6 +727,17 @@ else
 	assert "" "unknown compiler"
 fi
 
+printf "Finding suitable archiver........"
+if test ! -x "${AR}"; then
+	AR=`pathsearch "${AR:-ar}"`
+	if test -z "$AR" -o ! -x "$AR"; then
+		AR=`pathsearch "${AR:-ar}"`
+	else
+		echo "success [$AR]"
+	fi
+fi
+assert "$AR" "not found"
+
 printf "Detecting VMA bits..............."
 VMA="unknown"
 if test "$VMA_BITS" = "unknown"; then
