Next: , Previous: , Up: Adding options to a configure script   [Contents][Index]

11.3 Choosing Package Options

If a software package has optional compile-time features, the user can give configure command line options to specify whether to compile them. The options have one of these forms:


These options allow users to choose which optional features to build and install. --enable-feature options should never make a feature behave differently or cause one feature to replace another. They should only cause parts of the program to be built rather than left out.

The user can give an argument by following the feature name with ‘=’ and the argument. Giving an argument of ‘no’ requests that the feature not be made available. A feature with an argument looks like --enable-debug=stabs. If no argument is given, it defaults to ‘yes’. --disable-feature is equivalent to --enable-feature=no.

Normally configure scripts complain about --enable-package options that they do not support. See Option Checking for details, and for how to override the defaults.

For each optional feature, should call AC_ARG_ENABLE to detect whether the configure user asked to include it. Whether each feature is included or not by default, and which arguments are valid, is up to you.

Macro: AC_ARG_ENABLE (feature, help-string, [action-if-given], [action-if-not-given])

If the user gave configure the option --enable-feature or --disable-feature, run shell commands action-if-given. If neither option was given, run shell commands action-if-not-given. The name feature indicates an optional user-level facility. It should consist only of alphanumeric characters, dashes, plus signs, and dots.

The option’s argument is available to the shell commands action-if-given in the shell variable enableval, which is actually just the value of the shell variable named enable_feature, with any non-alphanumeric characters in feature changed into ‘_’. You may use that variable instead, if you wish. The help-string argument is like that of AC_ARG_WITH (see External Software).

Note that action-if-not-given is not expanded until the point that AC_ARG_ENABLE was expanded. If you need the value of enable_feature set to a default value by the time argument parsing is completed, use m4_divert_text to the DEFAULTS diversion (see m4_divert_text) (if done as an argument to AC_ARG_ENABLE, also provide non-diverted text to avoid a shell syntax error).

You should format your help-string with the macro AS_HELP_STRING (see Pretty Help Strings).

See the examples suggested with the definition of AC_ARG_WITH (see External Software) to get an idea of possible applications of AC_ARG_ENABLE.

Next: , Previous: , Up: Adding options to a configure script   [Contents][Index]