Search code examples
autotoolsautoconfm4

How to change the default autoconf configure --help output


I'd like to change the contents of autoconf's default configure --help output, in particular the text that is placed in the HELP_BEGIN diversion by _AC_INIT_HELP.

I realize this will be a hack that is not entirely "kosher" under autoconf doctrine, but I'm willing to live with any consequences in portability, etc. However I'd prefer not to directly edit the autoconf implementation, or require a post-processing step on the generated configure script.

It seems like the power of m4 should let me do this, but I've tried many different things, none of which work. Most of them result in m4 crashes, eg:

$ cat configure.ac 
AC_PREREQ(2.69)
m4_define([_AC_INIT_HELP],patsubst(m4_defn([_AC_INIT_HELP]),[Fine],[Foo]))
AC_INIT(foo,1.0)
AC_OUTPUT()
$ autoreconf
/usr/local/pkg/autotools-201608/bin/m4: memory exhausted
autom4te: /usr/local/pkg/autotools-201608/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1

How can I make this work?


Solution

  • Finally found the answer myself.

    The key is to exploit m4_copy:

    AC_PREREQ(2.69)
    m4_copy([_AC_INIT_HELP],[_MY_INIT_HELP])
    m4_define([_AC_INIT_HELP],[patsubst(m4_defn([_MY_INIT_HELP]),[Fine],[Foo])])
    AC_INIT(foo,1.0)
    AC_OUTPUT()