Configuring a Package

Many packages come with an autoconf-generated ./configure script for checking the build environment and configuring optional support for libraries. The econf function should be used where possible — this will provide correct build and path specifications for a Gentoo environment.

Often the configure script will try to automatically enable support for optional components based upon installed packages. This must not be allowed to happen. For example, if a user has Perl installed but has USE="-perl", packages with optional Perl support must not link against Perl. This automatic detection can usually be overridden using --enable- and --disable or --with- and --without- switches (but note that these don't always work — make sure these are tested properly!).

The use_enable and use_with utility functions should, where appropriate, be used to generate these switches.

src_configure() {
	# We have optional perl, python and ruby support
	econf \
		$(use_enable perl) \
		$(use_enable python) \
		$(use_enable ruby)
}

src_configure() {
	# Our package optional IPv6 support which uses --with rather than
	# --enable / --disable

	econf $(use_with ipv6)
}

Sometimes the package's choice of name for the option will not exactly match the name or case of the USE flag. This is very often the case with the X flag. For these situations, there are two argument forms:

src_configure() {
	# Our package has optional perl, python and ruby support
	econf \
		$(use_enable perl perlinterp) \
		$(use_enable python pythoninterp) \
		$(use_enable ruby rubyinterp)

	# ...
}

src_configure() {
	econf $(use_with X x11)
}

To check for an unset USE flag, the use_enable !flag form can be used.

econf Options

econf is designed to work with configure scripts generated by GNU Autoconf. It first passes the default options listed below to the configure script, followed by any additional parameters passed to econf.

  • --prefix="${EPREFIX}"/usr
  • --mandir="${EPREFIX}"/usr/share/man
  • --infodir="${EPREFIX}"/usr/share/info
  • --datadir="${EPREFIX}"/usr/share
  • --sysconfdir="${EPREFIX}"/etc
  • --localstatedir="${EPREFIX}"/var/lib
  • --build="${CBUILD}" (only passed if CBUILD is non-empty)
  • --host="${CHOST}"
  • --target="${CTARGET}" (only passed if CTARGET is non-empty)
  • --libdir is set from the value of the LIBDIR_${ABI} variable in profiles.
  • --disable-dependency-tracking
  • --disable-silent-rules

In EAPI 6 and later, the following options are passed in addition:

  • --docdir="${EPREFIX}"/usr/share/doc/${PF}
  • --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html

In EAPI 7 and later, the following option is passed in addition:

  • --with-sysroot="${ESYSROOT:-/}"