major confutils.eclass cleanup:
authorBenedikt Boehm <hollow@gentoo.org>
Wed, 20 Feb 2008 13:07:50 +0000 (13:07 +0000)
committerBenedikt Boehm <hollow@gentoo.org>
Wed, 20 Feb 2008 13:07:50 +0000 (13:07 +0000)
 * add built_with_use helpers
 * implement all documented features
 * document all implemented features
 * add standard eclass documentation
 * code DRY up

eclass/confutils.eclass

index 6cc691dd6619befdc66bb9cdd4ef401231b66368..1e6c56baae2430e6cb81264f2f99604e542f1ca7 100644 (file)
-# Copyright 1999-2007 Gentoo Foundation
+# Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/confutils.eclass,v 1.20 2007/11/22 21:51:16 drac Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/confutils.eclass,v 1.21 2008/02/20 13:07:50 hollow Exp $
+
+# @ECLASS: confutils.eclass
+# @MAINTAINER:
+# Benedikt Böhm <hollow@gentoo.org>
+# @BLURB: utility functions to help with configuring a package
+# @DESCRIPTION:
+# The confutils eclass contains functions to handle use flag dependencies and
+# extended --with-*/--enable-* magic.
 #
-# eclass/confutils.eclass
-#              Utility functions to help with configuring a package
-#
-#              Based on Stuart's work for the PHP 5 eclass
-#
-# Author(s)            Stuart Herbert
-#                              <stuart@gentoo.org>
-#
-# ========================================================================
+# Based on the PHP5 eclass by Stuart Herbert <stuart@stuartherbert.com>
 
 inherit eutils
 
+DESCRIPTION="Based on the ${ECLASS} eclass"
+
+# @VARIABLE: EBUILD_SUPPORTS_SHAREDEXT
+# @DESCRIPTION:
+# Set this variable to 1 if your ebuild supports shared extensions. You need to
+# call confutils_init() in pkg_setup() if you use this variable.
 if [[ ${EBUILD_SUPPORTS_SHAREDEXT} == 1 ]]; then
        IUSE="sharedext"
 fi
 
-# ========================================================================
-
-# list of USE flags that need deps that aren't yet in Portage
-# this list was originally added for PHP
-#
-# your eclass must define CONFUTILS_MISSING_DEPS if you need this
-
-# ========================================================================
-# confutils_init ()
-#
-# Call this function from your src_compile() function to initialise
-# this eclass first
-
-confutils_init () {
-       if [[ ${EBUILD_SUPPORTS_SHAREDEXT} == 1 ]] && use sharedext ; then
-               shared="=shared"
+# @FUNCTION: confutils_init
+# @USAGE: [value]
+# @DESCRIPTION:
+# Call this function from your pkg_setup() function to initialize this eclass
+# if EBUILD_SUPPORTS_SHAREDEXT is enabled. If no value is given `shared' is used
+# by default.
+confutils_init() {
+       if [[ ${EBUILD_SUPPORTS_SHAREDEXT} == 1 ]] && use sharedext; then
+               shared="=${1:-shared}"
        else
                shared=
        fi
 }
 
-# ========================================================================
-# confutils_require_any ()
-#
-# Use this function to ensure one or more of the specified USE flags have
-# been enabled
-#
-# $1    - message to output everytime a flag is found
-# $2    - message to output everytime a flag is not found
-# $3 .. - flags to check
-#
-
+# @FUNCTION: confutils_require_any
+# @USAGE: <flag> [more flags ...]
+# @DESCRIPTION:
+# Use this function to ensure one or more of the specified USE flags have been
+# enabled
 confutils_require_any() {
-       success_msg="$1"
-       shift
-       fail_msg="$1"
-       shift
-
-       required_flags="$@"
-       success=0
-
-       while [[ -n $1 ]]; do
-               if use $1 ; then
-                       einfo "$success_msg $1"
-                       success=1
-               else
-                       ewarn "$fail_msg $1"
-               fi
-               shift
-       done
+       local required_flags="$@"
+       local success=0
 
-       # did we find what we are looking for?
-       if [[ $success == 1 ]]; then
-               return
-       fi
+       for flag in ${required_flags}; do
+               use ${flag} && success=1
+       done
 
-       # if we get here, then none of the required USE flags are switched on
+       [[ ${success} -eq 1 ]] && return
 
        echo
        eerror "You *must* enable one or more of the following USE flags:"
-       eerror "  $required_flags"
+       eerror "  ${required_flags}"
        eerror
        eerror "You can do this by enabling these flags in /etc/portage/package.use:"
-       eerror "    =$CATEGORY/$PN-$PVR $required_flags"
-       eerror
+       eerror "    =${CATEGORY}/${PN}-${PVR} ${required_flags}"
+       echo
        die "Missing USE flags"
 }
 
-# ========================================================================
-# confutils_use_conflict ()
-#
-# Use this function to automatically complain to the user if conflicting
-# USE flags have been enabled
-#
-# $1   - flag that depends on other flags
-# $2 .. - flags that conflict
+# @FUNCTION: confutils_require_built_with_all
+# @USAGE: <foreign> <flag> [more flags ...]
+# @DESCRIPTION:
+# Use this function to ensure all of the specified USE flags have been enabled
+# in the specified foreign package
+confutils_require_built_with_all() {
+       local foreign=$1 && shift
+       local required_flags="$@"
 
-confutils_use_conflict () {
-       if ! use $1 ; then
-               return
-       fi
+       built_with_use ${foreign} ${required_flags} && return
+
+       echo
+       eerror "You *must* enable all of the following USE flags in ${foreign}:"
+       eerror "  ${required_flags}"
+       eerror
+       eerror "You can do this by enabling these flags in /etc/portage/package.use:"
+       eerror "    ${foreign} ${required_flags}"
+       echo
+       die "Missing USE flags in ${foreign}"
+}
+
+# @FUNCTION: confutils_require_built_with_any
+# @USAGE: <foreign> <flag> [more flags ...]
+# @DESCRIPTION:
+# Use this function to ensure one or more of the specified USE flags have been
+# enabled in the specified foreign package
+confutils_require_built_with_any() {
+       local foreign=$1 && shift
+       local required_flags="$@"
+       local success=0
+
+       for flag in ${required_flags}; do
+               built_with_use ${foreign} ${flag} && success=1
+       done
+
+       [[ ${success} -eq 1 ]] && return
+
+       echo
+       eerror "You *must* enable one or more of the following USE flags in ${foreign}:"
+       eerror "  ${required_flags}"
+       eerror
+       eerror "You can do this by enabling these flags in /etc/portage/package.use:"
+       eerror "    ${foreign} ${required_flags}"
+       echo
+       die "Missing USE flags in ${foreign}"
+}
 
-       local my_flag="$1"
-       shift
+# @FUNCTION: confutils_use_conflict
+# @USAGE: <enabled flag> <conflicting flag> [more conflicting flags ...]
+# @DESCRIPTION:
+# Use this function to automatically complain to the user if conflicting USE
+# flags have been enabled
+confutils_use_conflict() {
+       use $1 || return
 
+       local my_flag="$1" && shift
        local my_present=
        local my_remove=
 
-       while [ "$1+" != "+" ]; do
-               if use $1 ; then
-                       my_present="${my_present} $1"
-                       my_remove="${my_remove} -$1"
+       for flag in "$@"; do
+               if use ${flag}; then
+                       my_present="${my_present} ${flag}"
+                       my_remove="${my_remove} -${flag}"
                fi
-               shift
        done
 
-       if [ -n "$my_present" ]; then
-               echo
-               eerror "USE flag '$my_flag' conflicts with these USE flag(s):"
-               eerror "  $my_present"
-               eerror
-               eerror "You must disable these conflicting flags before you can emerge this package."
-               eerror "You can do this by disabling these flags in /etc/portage/package.use:"
-               eerror "    =$CATEGORY/$PN-$PVR $my_remove"
-               eerror
-               die "Conflicting USE flags"
-       fi
-}
-
-# ========================================================================
-# confutils_use_depend_all ()
-#
-# Use this function to automatically complain to the user if a USE flag
-# depends on another USE flag that hasn't been enabled
-#
-# $1   - flag that depends on other flags
-# $2 .. - the flags that must be set for $1 to be valid
+       [[ -z "${my_present}" ]] && return
 
-confutils_use_depend_all () {
-       if ! use $1 ; then
-               return
-       fi
+       echo
+       eerror "USE flag '${my_flag}' conflicts with these USE flag(s):"
+       eerror "  ${my_present}"
+       eerror
+       eerror "You must disable these conflicting flags before you can emerge this package."
+       eerror "You can do this by disabling these flags in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} ${my_remove}"
+       eerror
+       eerror "You could disable this flag instead in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} -${my_flag}"
+       echo
+       die "Conflicting USE flags"
+}
 
-       local my_flag="$1"
-       shift
+# @FUNCTION: confutils_use_depend_all
+# @USAGE: <enabled flag> <needed flag> [more needed flags ...]
+# @DESCRIPTION:
+# Use this function to automatically complain to the user if a USE flag depends
+# on another USE flag that hasn't been enabled
+confutils_use_depend_all() {
+       use $1 || return
 
+       local my_flag="$1" && shift
        local my_missing=
 
-       while [ "$1+" != "+" ]; do
-               if ! use $1 ; then
-                       my_missing="${my_missing} $1"
-               fi
-               shift
+       for flag in "$@"; do
+               use ${flag} || my_missing="${my_missing} ${flag}"
        done
 
-       if [ -n "$my_missing" ]; then
-               echo
-               eerror "USE flag '$my_flag' needs these additional flag(s) set:"
-               eerror "  $my_missing"
-               eerror
-               eerror "You can do this by enabling these flags in /etc/portage/package.use:"
-               eerror "    =$CATEGORY/$PN-$PVR $my_missing"
-               eerror
-               eerror "You could disable this flag instead in /etc/portage/package.use:"
-               eerror "        =$CATEGORY/$PN-$PVR -$my_flag"
-               echo
-
-               die "Need missing USE flags"
-       fi
-}
-
-# ========================================================================
-# confutils_use_depend_any ()
-#
-# Use this function to automatically complain to the user if a USE flag
-# depends on another USE flag that hasn't been enabled
-#
-# $1   - flag that depends on other flags
-# $2 .. - flags that must be set for $1 to be valid
+       [[ -z "${my_missing}" ]] && return
 
-confutils_use_depend_any () {
-       if ! use $1 ; then
-               return
-       fi
+       echo
+       eerror "USE flag '${my_flag}' needs these additional flag(s) set:"
+       eerror "  ${my_missing}"
+       eerror
+       eerror "You can do this by enabling these flags in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} ${my_missing}"
+       eerror
+       eerror "You could disable this flag instead in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} -${my_flag}"
+       echo
+       die "Need missing USE flags"
+}
 
-       local my_flag="$1"
-       shift
+# @FUNCTION: confutils_use_depend_any
+# @USAGE: <enabled flag> <needed flag> [more needed flags ...]
+# @DESCRIPTION:
+# Use this function to automatically complain to the user if a USE flag depends
+# on another USE flag that hasn't been enabled
+confutils_use_depend_any() {
+       use $1 || return
 
+       local my_flag="$1" && shift
        local my_found=
        local my_missing=
 
-       while [ "$1+" != "+" ]; do
-               if use $1 ; then
-                       my_found="${my_found} $1"
+       for flag in "$@"; do
+               if use ${flag}; then
+                       my_found="${my_found} ${flag}"
                else
-                       my_missing="${my_missing} $1"
+                       my_missing="${my_missing} ${flag}"
                fi
-               shift
        done
 
-       if [ -z "$my_found" ]; then
-               echo
-               eerror "USE flag '$my_flag' needs one of these additional flag(s) set:"
-               eerror "  $my_missing"
-               eerror
-               eerror "You can do this by enabling one of these flags in /etc/portage/package.use"
-               eerror
-               die "Need missing USE flag"
-       fi
+       [[ -n "${my_found}" ]] && return
+
+       echo
+       eerror "USE flag '${my_flag}' needs one or more of these additional flag(s) set:"
+       eerror "  ${my_missing}"
+       eerror
+       eerror "You can do this by enabling one of these flags in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} ${my_missing}"
+       eerror
+       eerror "You could disable this flag instead in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} -${my_flag}"
+       echo
+       die "Need missing USE flag(s)"
 }
 
-# ========================================================================
-# enable_extension_disable ()
-#
-# Use this function to disable an extension that is enabled by default.
-# This is provided for those rare configure scripts that don't support
-# a --enable for the corresponding --disable
-#
-# $1   - extension name
-# $2   - USE flag
-# $3   - optional message to einfo() to the user
+# @FUNCTION: confutils_use_depend_built_with_all
+# @USAGE: <enabled flag> <foreign> <needed flag> [more needed flags ...]
+# @DESCRIPTION:
+# Use this function to automatically complain to the user if a USE flag depends
+# on a USE flag in another package that hasn't been enabled
+confutils_use_depend_built_with_all() {
+       use $1 || return
 
-enable_extension_disable () {
-       if ! use "$2" ; then
-               my_conf="${my_conf} --disable-$1"
-               [ -n "$3" ] && einfo "  Disabling $1"
-       else
-               [ -n "$3" ] && einfo "  Enabling $1"
-       fi
-}
+       local my_flag="$1" && shift
+       local foreign=$1 && shift
+       local required_flags="$@"
 
-# ========================================================================
-# enable_extension_enable ()
-#
-# This function is like use_enable(), except that it knows about
-# enabling modules as shared libraries, and it supports passing
-# additional data with the switch
-#
-# $1   - extension name
-# $2   - USE flag
-# $3   - 1 = support shared, 0 = never support shared
-# $4   - additional setting for configure
-# $5   - additional message to einfo out to the user
+       built_with_use ${foreign} ${required_flags} && return
 
-enable_extension_enable () {
-       local my_shared
+       echo
+       eerror "USE flag '${my_flag}' needs the following USE flags in ${foreign}:"
+       eerror "  ${required_flags}"
+       eerror
+       eerror "You can do this by enabling these flags in /etc/portage/package.use:"
+       eerror "    ${foreign} ${required_flags}"
+       eerror
+       eerror "You could disable this flag instead in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} -${my_flag}"
+       echo
+       die "Missing USE flags in ${foreign}"
+}
 
-       if [ "$3" == "1" ]; then
-               if [ "$shared+" != "+" ]; then
-                       my_shared="${shared}"
-                       if [ "$4+" != "+" ]; then
-                               my_shared="${my_shared},$4"
-                       fi
-               elif [ "$4+" != "+" ]; then
-                       my_shared="=$4"
-               fi
-       else
-               if [ "$4+" != "+" ]; then
-                       my_shared="=$4"
-               fi
-       fi
+# @FUNCTION: confutils_use_depend_built_with_any
+# @USAGE: <enabled flag> <foreign> <needed flag> [more needed flags ...]
+# @DESCRIPTION:
+# Use this function to automatically complain to the user if a USE flag depends
+# on a USE flag in another package that hasn't been enabled
+confutils_use_depend_built_with_any() {
+       use $1 || return
+
+       local my_flag="$1" && shift
+       local foreign=$1 && shift
+       local required_flags="$@"
+       local success=0
+
+       for flag in ${required_flags}; do
+               built_with_use ${foreign} ${flag} && success=1
+       done
 
-       if use $2 ; then
-               my_conf="${my_conf} --enable-$1$my_shared"
-               einfo "  Enabling $1"
-       else
-               my_conf="${my_conf} --disable-$1"
-               einfo "  Disabling $1"
-       fi
+       [[ ${success} -eq 1 ]] && return
+
+       echo
+       eerror "USE flag '${my_flag}' needs one or more of the following USE flags in ${foreign}:"
+       eerror "  ${required_flags}"
+       eerror
+       eerror "You can do this by enabling these flags in /etc/portage/package.use:"
+       eerror "    ${foreign} ${required_flags}"
+       eerror
+       eerror "You could disable this flag instead in /etc/portage/package.use:"
+       eerror "    =${CATEGORY}/${PN}-${PVR} -${my_flag}"
+       echo
+       die "Missing USE flags in ${foreign}"
 }
 
-# ========================================================================
-# enable_extension_enableonly ()
-#
-# This function is like use_enable(), except that it knows about
-# enabling modules as shared libraries, and it supports passing
-# additional data with the switch
-#
-# $1   - extension name
-# $2   - USE flag
-# $3   - 1 = support shared, 0 = never support shared
-# $4   - additional setting for configure
-# $5   - additional message to einfo out to the user
 
-enable_extension_enableonly () {
-       local my_shared
+# internal function constructs the configure values for optional shared module
+# support and extra arguments
+_confutils_shared_suffix() {
+       local my_shared=
 
-       if [ "$3" == "1" ]; then
-               if [ "$shared+" != "+" ]; then
+       if [[ "$1" == "1" ]]; then
+               if [[ -n "${shared}" ]]; then
                        my_shared="${shared}"
-                       if [ "$4+" != "+" ]; then
-                               my_shared="${my_shared},$4"
+                       if [[ -n "$2" ]]; then
+                               my_shared="${my_shared},$2"
                        fi
-               elif [ "$4+" != "+" ]; then
-                       my_shared="=$4"
+               elif [[ -n "$2" ]]; then
+                       my_shared="=$2"
                fi
        else
-               if [ "$4+" != "+" ]; then
-                       my_shared="=$4"
+               if [[ -n "$2" ]]; then
+                       my_shared="=$2"
                fi
        fi
 
-       if use $2 ; then
-               my_conf="${my_conf} --enable-$1$my_shared"
-               einfo "  Enabling $1"
-       else
-               # note: we deliberately do *not* use a --disable switch here
-               einfo "  Disabling $1"
-       fi
+       echo "${my_shared}"
 }
-# ========================================================================
-# enable_extension_without ()
-#
-# Use this function to disable an extension that is enabled by default
-# This function is provided for those rare configure scripts that support
-# --without but not the corresponding --with
-#
-# $1   - extension name
-# $2   - USE flag
-# $3   - optional message to einfo() to the user
 
-enable_extension_without () {
-       if ! use "$2" ; then
-               my_conf="${my_conf} --without-$1"
-               einfo "  Disabling $1"
+# @FUNCTION: enable_extension_disable
+# @USAGE: <extension> <flag> [msg]
+# @DESCRIPTION:
+# Use this function to disable an extension that is enabled by default.  This is
+# provided for those rare configure scripts that don't support a --enable for
+# the corresponding --disable.
+enable_extension_disable() {
+       local my_msg=${3:-$1}
+
+       if use "$2" ; then
+               einfo "  Enabling ${my_msg}"
        else
-               einfo "  Enabling $1"
+               my_conf="${my_conf} --disable-$1"
+               einfo "  Disabling ${my_msg}"
        fi
 }
 
-# ========================================================================
-# enable_extension_with ()
-#
-# This function is a replacement for use_with.  It supports building
-# extensions as shared libraries,
-
-# $1   - extension name
-# $2   - USE flag
-# $3   - 1 = support shared, 0 = never support shared
-# $4   - additional setting for configure
-# $5   - optional message to einfo() out to the user
-
-enable_extension_with () {
-       local my_shared
-
-       if [ "$3" == "1" ]; then
-               if [ "$shared+" != "+" ]; then
-                       my_shared="${shared}"
-                       if [ "$4+" != "+" ]; then
-                               my_shared="${my_shared},$4"
-                       fi
-               elif [ "$4+" != "+" ]; then
-                       my_shared="=$4"
-               fi
+# @FUNCTION: enable_extension_enable
+# @USAGE: <extension> <flag> [shared] [extra conf] [msg]
+# @DESCRIPTION:
+# This function is like use_enable(), except that it knows about enabling
+# modules as shared libraries, and it supports passing additional data with the
+# switch.
+enable_extension_enable() {
+       local my_shared=$(_confutils_shared_suffix $3 $4)
+       local my_msg=${5:-$1}
+
+       if use $2; then
+               my_conf="${my_conf} --enable-${1}${my_shared}"
+               einfo "  Enabling ${my_msg}"
        else
-               if [ "$4+" != "+" ]; then
-                       my_shared="=$4"
-               fi
+               my_conf="${my_conf} --disable-$1"
+               einfo "  Disabling ${my_msg}"
        fi
+}
+
+# @FUNCTION: enable_extension_enableonly
+# @USAGE: <extension> <flag> [shared] [extra conf] [msg]
+# @DESCRIPTION:
+# This function is like use_enable(), except that it knows about enabling
+# modules as shared libraries, and it supports passing additional data with the
+# switch.  This function is provided for those rare configure scripts that support
+# --enable but not the corresponding --disable.
+enable_extension_enableonly() {
+       local my_shared=$(_confutils_shared_suffix $3 $4)
+       local my_msg=${5:-$1}
 
        if use $2 ; then
-               my_conf="${my_conf} --with-$1$my_shared"
-               einfo "  Enabling $1"
+               my_conf="${my_conf} --enable-${1}${my_shared}"
+               einfo "  Enabling ${my_msg}"
        else
-               my_conf="${my_conf} --without-$1"
-               einfo "  Disabling $1"
+               # note: we deliberately do *not* use a --disable switch here
+               einfo "  Disabling ${my_msg}"
        fi
 }
 
-# ========================================================================
-# enable_extension_withonly ()
-#
-# This function is a replacement for use_with.  It supports building
-# extensions as shared libraries,
-
-# $1   - extension name
-# $2   - USE flag
-# $3   - 1 = support shared, 0 = never support shared
-# $4   - additional setting for configure
-# $5   - optional message to einfo() out to the user
-
-enable_extension_withonly () {
-       local my_shared
-
-       if [ "$3" == "1" ]; then
-               if [ "$shared+" != "+" ]; then
-                       my_shared="${shared}"
-                       if [ "$4+" != "+" ]; then
-                               my_shared="${my_shared},$4"
-                       fi
-               elif [ "$4+" != "+" ]; then
-                       my_shared="=$4"
-               fi
+# @FUNCTION: enable_extension_without
+# @USAGE: <extension> <flag> [msg]
+# @DESCRIPTION:
+# Use this function to disable an extension that is enabled by default. This
+# function is provided for those rare configure scripts that support --without
+# but not the corresponding --with
+enable_extension_without() {
+       local my_msg=${3:-$1}
+
+       if use "$2"; then
+               einfo "  Enabling ${my_msg}"
        else
-               if [ "$4+" != "+" ]; then
-                       my_shared="=$4"
-               fi
+               my_conf="${my_conf} --without-$1"
+               einfo "  Disabling ${my_msg}"
        fi
+}
 
-       if use $2 ; then
-               my_conf="${my_conf} --with-$1$my_shared"
-               einfo "  Enabling $1"
+# @FUNCTION: enable_extension_with
+# @USAGE: <extension> <flag> [shared] [extra conf] [msg]
+# @DESCRIPTION:
+# This function is like use_with(), except that it knows about enabling modules
+# as shared libraries, and it supports passing additional data with the switch.
+enable_extension_with() {
+       local my_shared=$(_confutils_shared_suffix $3 $4)
+       local my_msg=${5:-$1}
+
+       if use $2; then
+               my_conf="${my_conf} --with-${1}${my_shared}"
+               einfo "  Enabling ${my_msg}"
        else
-               # note - we deliberately do *not* use --without here
-               einfo "  Disabling $1"
+               my_conf="${my_conf} --without-$1"
+               einfo "  Disabling ${my_msg}"
        fi
 }
 
-# ========================================================================
-# confutils_warn_about_external_deps
-
-confutils_warn_about_missing_deps ()
-{
-       local x
-       local my_found=0
-
-       for x in $CONFUTILS_MISSING_DEPS ; do
-               if use $x ; then
-                       ewarn "USE flag $x enables support for software not in Portage"
-                       my_found=1
-               fi
-       done
-
-       if [ "$my_found" = "1" ]; then
-               ewarn
-               ewarn "This ebuild will continue, but if you haven't already installed the"
-               ewarn "software required to satisfy the list above, this package will probably"
-               ewarn "fail to compile."
-               ewarn
-               sleep 5
+# @FUNCTION: enable_extension_withonly
+# @USAGE: <extension> <flag> [shared] [extra conf] [msg]
+# @DESCRIPTION:
+# This function is like use_with(), except that it knows about enabling modules
+# as shared libraries, and it supports passing additional data with the switch.
+# This function is provided for those rare configure scripts that support --enable
+# but not the corresponding --disable.
+enable_extension_withonly() {
+       local my_shared=$(_confutils_shared_suffix $3 $4)
+       local my_msg=${5:-$1}
+
+       if use $2; then
+               my_conf="${my_conf} --with-${1}${my_shared}"
+               einfo "  Enabling ${my_msg}"
+       else
+               # note: we deliberately do *not* use a --without switch here
+               einfo "  Disabling ${my_msg}"
        fi
 }
 
-# ========================================================================
-# enable_extension_enable_built_with ()
-#
-# This function is like use_enable(), except that it knows about
-# enabling modules as shared libraries, and it supports passing
-# additional data with the switch
-#
-# $1    - pkg name
-# $2   - USE flag
-# $3   - extension name
-# $4   - additional setting for configure
-# $5   - alternative message
-
-enable_extension_enable_built_with () {
-       local msg=$3
-       [[ -n $5 ]] && msg="$5"
-
-       local param
-       [[ -n $4 ]] && msg="=$4"
-
-       if built_with_use $1 $2 ; then
-               my_conf="${my_conf} --enable-$3${param}"
-               einfo "  Enabling $msg"
+# @FUNCTION: enable_extension_enable_built_with
+# @USAGE: <foreign> <flag> <extension> [shared] [extra conf] [msg]
+# @DESCRIPTION:
+# This function is like enable_extension_enable(), except that it
+# enables/disables modules based on a USE flag in a foreign package.
+enable_extension_enable_built_with() {
+       local my_shared=$(_confutils_shared_suffix $4 $5)
+       local my_msg=${6:-$3}
+
+       if built_with_use $1 $2; then
+               my_conf="${my_conf} --enable-${3}${my_shared}"
+               einfo "  Enabling ${my_msg}"
        else
                my_conf="${my_conf} --disable-$3"
-               einfo "  Disabling $msg"
+               einfo "  Disabling ${my_msg}"
        fi
 }
 
-# ========================================================================
-# enable_extension_with_built_with ()
-#
-# This function is like use_enable(), except that it knows about
-# enabling modules as shared libraries, and it supports passing
-# additional data with the switch
-#
-# $1    - pkg name
-# $2   - USE flag
-# $3   - extension name
-# $4   - additional setting for configure
-# $5   - alternative message
-
-enable_extension_with_built_with () {
-       local msg=$3
-       [[ -n $5 ]] && msg="$5"
-
-       local param
-       [[ -n $4 ]] && param="=$4"
-
-       if built_with_use $1 $2 ; then
-               my_conf="${my_conf} --with-$3${param}"
-               einfo "  Enabling $msg"
+# @FUNCTION: enable_extension_with_built_with ()
+# @USAGE: <foreign> <flag> <extension> [shared] [extra conf] [msg]
+# @DESCRIPTION:
+# This function is like enable_extension_with(), except that it
+# enables/disables modules based on a USE flag in a foreign package.
+enable_extension_with_built_with() {
+       # legacy workaround
+       if [[ "$4" != "0" && "$4" != "1" ]]; then
+               enable_extension_with_built_with "$1" "$2" "$3" 0 "$4" "$5"
+               return
+       fi
+
+       local my_shared=$(_confutils_shared_suffix $4 $5)
+       local my_msg=${6:-$3}
+
+       if built_with_use $1 $2; then
+               my_conf="${my_conf} --with-${3}${my_shared}"
+               einfo "  Enabling ${my_msg}"
        else
                my_conf="${my_conf} --disable-$3"
-               einfo "  Disabling $msg"
+               einfo "  Disabling ${my_msg}"
        fi
 }