]> git.draconx.ca Git - dxcommon.git/commitdiff
Apply AS_TR_SH to variable names in library helpers.
authorNick Bowler <nbowler@draconx.ca>
Sat, 23 Feb 2019 16:08:13 +0000 (11:08 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 23 Feb 2019 16:15:12 +0000 (11:15 -0500)
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

index fdaaff5c0fafedc6bb73e08719ffcd8efe60833d..83d891718a7f7470342789631d807ded2ee1ec58 100644 (file)
@@ -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.