Repository: randombit/botan (cpp)

Issue:
"botan config ldflags" returns incorrect library path
I built Botan with a prefix specified, e.g.

    ./configure.py --prefix=/tmp/botan

When the CLI botan of the build is queried to determine information about the build, it returns an incorrect -L library path, with duplicate components.

    jim@wandering:/tmp/botan/bin$ LD_LIBRARY_PATH=/tmp/botan/lib/ ./botan config ldflags
    -fstack-protector -m64 -pthread -L/tmp/botan//tmp/botan/lib

I am using Botan version 1.12.1

Done twice with different prefixes; same results.


Pull request description:
Fix cli ldflags output
Closes #2199

Patch:
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp
index 52b14ff1c..d55a81e7c 100644
--- a/src/cli/utils.cpp
+++ b/src/cli/utils.cpp
@@ -185,7 +185,7 @@ class Config_Info final : public Command
             {
             if(*BOTAN_LINK_FLAGS)
                output() << BOTAN_LINK_FLAGS << ' ';
-            output() << "-L" << BOTAN_INSTALL_PREFIX << "/" << BOTAN_INSTALL_LIB_DIR << "\n";
+            output() << "-L" << BOTAN_INSTALL_LIB_DIR << "\n";
             }
          else if(arg == "libs")
             {


Test patch:
diff --git a/src/scripts/test_cli.py b/src/scripts/test_cli.py
index 993284951..b87f4598d 100755
--- a/src/scripts/test_cli.py
+++ b/src/scripts/test_cli.py
@@ -114,9 +114,9 @@ def cli_config_tests(_tmp_dir):
 
     if len(prefix) < 4 or prefix[0] != '/':
         logging.error("Bad prefix %s" % (prefix))
-    if ("-I%s" % (prefix)) not in cflags:
+    if ("-I%s/include/botan-2" % (prefix)) not in cflags:
         logging.error("Bad cflags %s" % (cflags))
-    if ("-L%s" % (prefix)) not in ldflags:
+    if not ldflags.endswith(("-L%s/lib" % (prefix))):
         logging.error("Bad ldflags %s" % (ldflags))
     if "-lbotan-2" not in libs:
         logging.error("Bad libs %s" % (libs))