From 639a5c4515a36bcbadb82145d755005620c535c3 Mon Sep 17 00:00:00 2001
From: Jack Lloyd <jack@randombit.net>
Date: Fri, 13 Nov 2020 18:04:09 -0500
Subject: [PATCH] Fix use of -L flag when combined with --external-libdir

GH #2496
--- configure.py.orig	2020-11-14 16:39:43 UTC
+++ configure.py
@@ -2118,9 +2118,9 @@ def create_template_vars(source_paths, build_paths, op
 
         'visibility_attribute': cc.gen_visibility_attribute(options),
 
-        'lib_link_cmd': cc.so_link_command_for(osinfo.basename, options) + ' ' + external_link_cmd(),
-        'exe_link_cmd': cc.binary_link_command_for(osinfo.basename, options) + ' ' + external_link_cmd(),
-        'post_link_cmd': '',
+        'lib_link_cmd': cc.so_link_command_for(osinfo.basename, options),
+        'exe_link_cmd': cc.binary_link_command_for(osinfo.basename, options),
+        'external_link_cmd': external_link_cmd(),
 
         'ar_command': ar_command(),
         'ar_options': options.ar_options or cc.ar_options or osinfo.ar_options,
 configure.py               | 6 +++---
 src/build-data/makefile.in | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

--- src/build-data/makefile.in.orig	2020-11-07 07:43:35 UTC
+++ src/build-data/makefile.in
@@ -20,7 +20,7 @@ LDFLAGS        = %{ldflags}
 
 EXE_LINK_CMD   = %{exe_link_cmd}
 
-LIB_LINKS_TO   = %{link_to}
+LIB_LINKS_TO   = %{external_link_cmd} %{link_to}
 EXE_LINKS_TO   = %{link_to_botan} $(LIB_LINKS_TO)
 
 BUILD_FLAGS    = $(ABI_FLAGS) $(LANG_FLAGS) $(CXXFLAGS) $(WARN_FLAGS)
