Can you override the default help message generated as part of running autoconf?

I would like to modify the configure.ac script so that when I build it the configure script using autoconf, it will have a custom help message.

eg:

$autoconf
$./configure --help

      

gives

"Hello World"

      

Instead of default, which talks about fine-tuning the installation directories and changing build flags.

Is it possible?

+3


source to share


1 answer


Have a look at the _ AC_INIT_HELP macro in your autoconf general.m4

script. He is responsible for printing the help message.

This script will insert text in various deviations as stated in general.m4

:

dnl The order of the diversions here is
dnl - HELP_BEGIN
dnl   which may be extended by extra generic options such as with X or
dnl   AC_ARG_PROGRAM.  Displayed only in long --help.
dnl
dnl - HELP_CANON
dnl   Support for cross compilation (--build, --host and --target).
dnl   Display only in long --help.
dnl
dnl - HELP_ENABLE
dnl   which starts with the trailer of the HELP_BEGIN, HELP_CANON section,
dnl   then implements the header of the non generic options.
dnl
dnl - HELP_WITH
dnl
dnl - HELP_VAR
dnl
dnl - HELP_VAR_END
dnl
dnl - HELP_END
dnl   initialized below, in which we dump the trailer (handling of the
dnl   recursion for instance).

      

The easiest way to display a help message Hello World

is to simply paste the following code at the end of the configure.ac file:

m4_cleardivert([HELP_BEGIN])dnl
m4_cleardivert([HELP_CANON])dnl
m4_cleardivert([HELP_ENABLE])dnl
m4_cleardivert([HELP_WITH])dnl
m4_cleardivert([HELP_VAR])dnl
m4_cleardivert([HELP_VAR_END])dnl
m4_cleardivert([HELP_END])dnl
m4_divert_push([HELP_BEGIN])dnl
  cat <<_ACEOF
Hello World
_ACEOF
m4_divert_pop([HELP_BEGIN])dnl
m4_divert_push([HELP_END])dnl
exit 0
m4_divert_pop([HELP_END])dnl

      



It will clean up all leaks and add your custom text without having to include any custom scripts m4

. exit

need to stop processing configure

script when displaying help.


If you would like to make additional changes to the help text, you can include your own m4 script at the beginning of the file configure.ac

:

m4_include([custom_help.m4])

      

Copy the macro _AC_INIT_HELP

to your custom_help.m4

script and modify it to suit your needs.

+1


source







All Articles