How to avoid text in autoconf / m4?

The following code from my configuration.ac file does not work (note the enclosed square brackets with [default = none] ):

AC_ARG_ENABLE(debug, [ --enable-debug build with debugging support [default=no].], [DEBUG="$enableval"], [DEBUG="no"] ) 

How to avoid these brackets?

+7
bash m4 autoconf
source share
3 answers

Found! From this tutorial:

M4 arguments are quoted using [and]. There is NO WAY to avoid them, however you have several options if you want to insert [or]:

  • Use the "Quadrigaph". @ <: @ gives you [and @:> @ gives you].
  • Balance your quotes. M4 will turn [[]] into []. Beware of using this in macro arguments. Sometimes you also need to quote twice ([[[]]]).
  • Modify the sentence using: changequote (<<, →) to change the quotation to <and →. The autoconf documentation (in my opinion, in my opinion) warns against (using) this, as this can lead to unexpected results.
  • Avoid [and] where possible. This is my personal choice.

My new code is:

 AC_ARG_ENABLE(debug, AS_HELP_STRING( [--enable-debug], [build with debugging symbols @<:@default=no@:>@]), [enable_debug="$enableval"], [enable_debug="no"] ) 
+16
source share

Brackets are escape characters, as you do for '\' , you can escape brackets [] with brackets, for example:

AC_ARG_ENABLE (debugging, [--enable-debug build with debugging support [ [default = none] ] .], [DEBUG = "$ enableval"], [DEBUGGING = "no"])

Note: [ [] default = no [] ] may not work as you expect, since m4 should look for end_bracket from the end. It should be expanded to [ ]default=no[ ] .

+7
source share

use AC_HELP_STRING

0
source share

All Articles