autoconf
[Top][All Lists]
Advanced

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

Re: dynamic strings in help text


From: Keith Marshall
Subject: Re: dynamic strings in help text
Date: Mon, 20 Mar 2006 22:05:15 +0000

On Monday 20 March 2006 8:58 pm, Dan McMahill wrote:
> I have a configure.ac file which has some shell commands to set a
> variable which I want to later use in a help string.  The shell
> commands basically just enumerate modules contained in the source
> directory.
>   :
> This doesn't work for 2 reasons.
>   :
> Is there a simple way around this?

Hi Dan,

I had a similar requirement for autoconfiscating `man'.  If you can live 
with enumerating the modules at `autoconf' time, rather than at 
`configure' time, then you can use esyscmd.  I did it for `man's language 
collection by putting:

   MAN_NLS_LANGUAGE_SELECTION( MAN_LANGUAGES_AVAILABLE )

in configure.ac, with the following in aclocal.m4

# m4_sq( TEXT )
# ----------
# Emit TEXT, enclosed in single quotation marks.
#
m4_define([m4_sq], [`$*'])dnl`

# MAN_AS_HELP_DEFAULT( TEXT,... )
# -------------------------------
# Emit TEXT, enclosed in brackets, for use in an AS_HELP_STRING.
#
m4_define([MAN_AS_HELP_DEFAULT], [@<:@$*@:>@])

# MAN_AS_HELP_APPEND( DESCRIPTION )
# ---------------------------------
# Append an extra line of DESCRIPTION to an AS_HELP_STRING.
#
m4_define([MAN_AS_HELP_APPEND], [AS_HELP_STRING([], [$*])])

# MAN_LANGUAGES_AVAILABLE
# -----------------------
# Inspect the `manpage' source repository,
# to identify which national language `manpage' sets are available.
#
AC_DEFUN([MAN_LANGUAGES_AVAILABLE],
[m4_esyscmd([cd man; echo ?? | tr " " ,])dnl
])

# MAN_NLS_LANGUAGE_SELECTION( AVAILABLE )
# ---------------------------------------
# ENABLE/DISABLE National Language Support,
# and select the language pack(s) to install, from those AVAILABLE.
#
AC_DEFUN([MAN_NLS_LANGUAGE_SELECTION],
[AC_REQUIRE([WIN32_AC_NULLDEV])dnl
 AC_REQUIRE([MAN_NLS_PREREQUISITES])dnl
 AC_MSG_CHECKING([which national language manpages are required])
 AC_ARG_ENABLE([languages],
   MAN_LANGUAGE_HELP_STRING(MAN_LANGUAGE_LIST($1)),
   [test x$enableval = xall && languages=MAN_LANGUAGE_LIST($1) || 
languages=$enableval],
   [languages=en])
 test x$languages = xnone && man_enable_nls=no languages=en
 if test x$man_enable_nls = xno
 then
   AC_DEFINE([NONLS], [1], [Define to 1 if you DON'T want National 
Language Support.])
 fi
 AC_MSG_RESULT([$languages])
 for lang in `IFS=,; echo $languages`
 do
   langname=`cat "$srcdir/man/$lang.txt" 2>$NULLDEV`
   test x$langname = x && langname=$lang || langname="$lang ($langname)"
   AC_MSG_CHECKING([whether $langname manpages are available])
   ac_val=`exec 2>$NULLDEV; cd "$srcdir/man/$lang" && echo *.man || echo 
'*.man'`
   if test "$ac_val" = "*.man"
   then
     ac_val=no
   else
     test x$man_languages != x && man_languages="$man_languages,"
     man_languages=${man_languages}${lang}
     ac_val=yes
   fi
   AC_MSG_RESULT([$ac_val])
 done
 AC_MSG_CHECKING([which national language manpages to install])
 test x$man_languages = x && man_languages=en
 AC_SUBST([languages], [`IFS="$IFS,"; eval echo $man_languages`])
 AC_MSG_RESULT([$man_languages])
 if test x"$man_enable_nls" = xyes
 then
   if test x"$man_languages" != xen
   then
     make_messages=messages
     make_install_messages=install-messages
   fi
 fi
 AC_SUBST([make_install_messages])
 AC_SUBST([make_messages])dnl
])

# MAN_LANGUAGE_LIST( LANGUAGES,... )
# ----------------------------------
# A wrapper macro called by MAN_NLS_LANGUAGE_SELECTION,
# to remove the trailing newline character from the LANGUAGES list
# which is generated by MAN_LANGUAGES_AVAILABLE.
#
AC_DEFUN([MAN_LANGUAGE_LIST], [m4_normalize([$*])])

# MAN_LANGUAGE_HELP_STRING( LANGUAGES,... )
# -----------------------------------------
# A helper macro called by MAN_NLS_LANGUAGE_SELECTION,
# to emit the list of available LANGUAGES in `configure --help' output.
#
AC_DEFUN([MAN_LANGUAGE_HELP_STRING],
[AS_HELP_STRING([--enable-languages=LIST],
[LIST of language packs to install] MAN_AS_HELP_DEFAULT([m4_sq(en) 
only])[,])
MAN_AS_HELP_APPEND([where LIST is ]m4_sq(all)[, any comma separated 
subset of ]m4_sq($*)[,])
MAN_AS_HELP_APPEND([or ]m4_sq(none)[, to disable NLS and fall back to 
]m4_sq(en)[ only])dnl
])

HTH,
Keith.




reply via email to

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