From 5009438d49efb85e19a37854c3b5a223993ec6cc Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 23 Feb 2019 11:08:13 -0500 Subject: [PATCH] Apply AS_TR_SH to variable names in library helpers. This should help writing tests for libraries with hyphens in the names, by automatically translating hyphens in computed varible names to underscores. --- m4/libhelper.m4 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/m4/libhelper.m4 b/m4/libhelper.m4 index fdaaff5..83d8917 100644 --- a/m4/libhelper.m4 +++ b/m4/libhelper.m4 @@ -12,11 +12,11 @@ dnl Helper to setup a library test. Defines two user variables FOO_CFLAGS dnl and FOO_LIBS, where FOO is replaced with env-base in uppercase. The dnl human-name is the name of the library used in help text, by default the dnl same as env-base. -AC_DEFUN([DX_LIB_SETUP], [m4_do( - [AC_ARG_VAR(m4_toupper([$1])[_CFLAGS], - [C compiler flags for ]m4_default([$2], [$1]))], - [AC_ARG_VAR(m4_toupper([$1])[_LIBS], - [linker flags for ]m4_default([$2], [$1]))])]) +AC_DEFUN([DX_LIB_SETUP], + [m4_do([AC_ARG_VAR(AS_TR_SH([m4_toupper([$1])])[_CFLAGS], + [C compiler flags for ]m4_default([$2], [$1]))], + [AC_ARG_VAR(AS_TR_SH([m4_toupper([$1])])[_LIBS], + [linker flags for ]m4_default([$2], [$1]))])]) dnl DX_LIB_PKGCONFIG_FLAGS(env-base, [library-name]) dnl @@ -26,8 +26,8 @@ dnl dx_cv_foo_pkg_cflags and dx_cv_foo_pkg_libs, where foo is replaced with dnl env-base in lowercase. If not specified, the library name defaults to dnl env-base. AC_DEFUN([DX_LIB_PKGCONFIG_FLAGS], - [_DX_LIB_PKGCONFIG_FLAGS(m4_tolower([$1]), - [m4_default([$2], [$1])])]) + [_DX_LIB_PKGCONFIG_FLAGS(AS_TR_SH([m4_tolower([$1])]), + [m4_default([$2], [$1])])]) dnl Internal helper macro for the above. AC_DEFUN([_DX_LIB_PKGCONFIG_FLAGS], [AS_IF([test x"$PKG_CONFIG" != x""], @@ -65,8 +65,8 @@ dnl The result ("yes" or "no") are printed so this macro should be preceded dnl by a call to AC_MSG_CHECKING. AC_DEFUN([DX_LIB_SEARCH], [m4_divert_push([KILL]) -m4_pushdef([_DX_CVNAME], m4_tolower([dx_cv_$1_lib_])[$][1]) -m4_pushdef([_DX_FNNAME], m4_tolower([dx_fn_$1_lib_])[$][1]) +m4_pushdef([_DX_CVNAME], AS_TR_SH([m4_tolower([dx_cv_$1_lib_])])[$][1]) +m4_pushdef([_DX_FNNAME], AS_TR_SH([m4_tolower([dx_fn_$1_lib_])])[$][1]) m4_divert([INIT_PREPARE])dnl # Helper function to test whether $1 works. @@ -91,9 +91,11 @@ CFLAGS=$_dx_save_cflags LIBS=$_dx_save_libs])dnl AC_MSG_RESULT([$_DX_CVNAME([found])]) -AS_IF([test x"$_DX_CVNAME([found])" = x"yes"], [dnl - AC_SUBST(m4_toupper([$1_CFLAGS]), [$_DX_CVNAME([cflags])])dnl - AC_SUBST(m4_toupper([$1_LIBS]), [$_DX_CVNAME([libs])])]) +AS_IF([test x"$_DX_CVNAME([found])" = x"yes"], + [m4_do([AC_SUBST(AS_TR_SH([m4_toupper([$1_CFLAGS])]), + [$_DX_CVNAME([cflags])])], + [AC_SUBST(AS_TR_SH([m4_toupper([$1_LIBS])]), + [$_DX_CVNAME([libs])])])]) m4_popdef([_DX_CVNAME], [_DX_FNNAME])]) dnl Internal helper macro for the above. -- 2.43.2