autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

avoiding undesired macro expansion after AS_TR_CPP


From: Bruno Haible
Subject: avoiding undesired macro expansion after AS_TR_CPP
Date: Thu, 3 Jun 2010 22:52:34 +0200
User-agent: KMail/1.9.9

Hi,

I would like to avoid undesired macro expansion on the result of AS_TR_CPP,
and cannot get it to work. Can someone help, please?

================================ configure.ac =============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE

dnl m4_define([FOO_BAR], [undesired substitution])

AC_DEFUN([MYCOND],
[
  AM_CONDITIONAL([LIBUNISTRING_]AS_TR_CPP([$1]), [true])
])

MYCOND([foo/bar])

AC_OUTPUT
============================================================================

After

  $ aclocal
  $ autoconf

everything looks fine.

Now uncomment the line 4 of configure.ac.

  $ autoconf
  configure.ac:11: error: AC_SUBST: `LIBUNISTRING_undesired substitution_TRUE' 
is not a valid shell variable name
  aclocal.m4:125: AM_CONDITIONAL is expanded from...
  configure.ac:6: MYCOND is expanded from...
  configure.ac:11: the top level

So I guess some more quoting is needed.

Attempt #1: Use brackets. Change line 8 to

  AM_CONDITIONAL([LIBUNISTRING_][AS_TR_CPP([$1])], [true])
  $ autoconf
  configure.ac:11: error: AC_SUBST: `LIBUNISTRING_AS_TR_CPP([foo/bar])_TRUE' is 
not a valid shell variable name
  aclocal.m4:125: AM_CONDITIONAL is expanded from...
  configure.ac:6: MYCOND is expanded from...
  configure.ac:11: the top level

Attempt #2: Use m4_quote. Change line 8 to

  AM_CONDITIONAL([LIBUNISTRING_]m4_quote(AS_TR_CPP([$1])), [true])
  $ autoconf
  configure.ac:11: error: AC_SUBST: `LIBUNISTRING_undesired substitution_TRUE' 
is not a valid shell variable name
  aclocal.m4:125: AM_CONDITIONAL is expanded from...
  configure.ac:6: MYCOND is expanded from...
  configure.ac:11: the top level

Attempt #3: Use m4_dquote. Change line 8 to

  AM_CONDITIONAL([LIBUNISTRING_]m4_dquote(AS_TR_CPP([$1])), [true])
  $ autoconf
  configure.ac:11: error: AC_SUBST: `LIBUNISTRING_[undesired 
substitution]_TRUE' is not a valid shell variable name
  aclocal.m4:125: AM_CONDITIONAL is expanded from...
  configure.ac:6: MYCOND is expanded from...
  configure.ac:11: the top level

Attempt #4: Use m4_quote and brackets. Change line 8 to

  AM_CONDITIONAL([LIBUNISTRING_]m4_quote([AS_TR_CPP([$1])]), [true])
  $ autoconf
  configure.ac:11: error: AC_SUBST: `LIBUNISTRING_AS_TR_CPP([foo/bar])_TRUE' is 
not a valid shell variable name
  aclocal.m4:125: AM_CONDITIONAL is expanded from...
  configure.ac:6: MYCOND is expanded from...
  configure.ac:11: the top level


Yes, I know I could write
  AM_CONDITIONAL(AS_TR_CPP([LIBUNISTRING_$1]), [true])
but this feels like cheating, because it exploits a particular fact about the
AS_TR_CPP macro.

What am I missing?

Bruno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]