diff mbox series

[1/1] config: Handle dash in library name for AC_LIB_LINKAGEFLAGS_BODY

Message ID 20240707195341.25305-2-abdul.b.ijaz@intel.com
State New
Headers show
Series config: Handle dash in library name for AC_LIB_LINKAGEFLAGS_BODY | expand

Commit Message

Ijaz, Abdul B July 7, 2024, 7:53 p.m. UTC
From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>

For a library with dash in the name like yaml-cpp the AC_LIB_LINKAGEFLAGS_BODY
function generates a with_libname_type argument variable name with a dash but
this results in configure error.  Since dashes are not allowed in the variable
name.

This change handles such cases and in case input library for the
AC_LIB_HAVE_LINKFLAGS has dash then it replaces it with the underscore "_".

Example of an error for yaml-cpp library before the change using gcc config
scripts in gdb:
gdb/gdb/configure: line 22868: with_libyaml-cpp_type=auto: command not found

After having underscore for this variable name:

checking whether to use yaml-cpp... yes
checking for libyaml-cpp... yes
checking how to link with libyaml-cpp... -lyaml-cpp

config/ChangeLog:

	* lib-link.m4: Handle dash in the library name for
	AC_LIB_LINKFLAGS_BODY.

2024-07-03 Ijaz, Abdul B <abdul.b.ijaz@intel.com>
---
 config/lib-link.m4 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/config/lib-link.m4 b/config/lib-link.m4
index 20e281fd323..a60a8069453 100644
--- a/config/lib-link.m4
+++ b/config/lib-link.m4
@@ -126,6 +126,7 @@  AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
 [
   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  define([Name],[translit([$1],[./-], [___])])
   dnl By default, look in $includedir and $libdir.
   use_additional=yes
   AC_LIB_WITH_FINAL_PREFIX([
@@ -152,8 +153,8 @@  AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
 ])
   AC_LIB_ARG_WITH([lib$1-type],
 [  --with-lib$1-type=TYPE     type of library to search for (auto/static/shared) ],
-  [ with_lib$1_type=$withval ], [ with_lib$1_type=auto ])
-  lib_type=`eval echo \$with_lib$1_type`
+  [ with_lib[]Name[]_type=$withval ], [ with_lib[]Name[]_type=auto ])
+  lib_type=`eval echo \$with_lib[]Name[]_type`
 
   dnl Search the library and its dependencies in $additional_libdir and
   dnl $LDFLAGS. Using breadth-first-seach.