# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # # NOTE - THIS IS INCOMPLETE # @ECLASS: wxwidgets.eclass # @MAINTAINER: # dirtyepic@gentoo.org # wxwindows@gentoo.org # @BLURB: Manages build configuration for wxGTK-using packages. # @DESCRIPTION: # The wxGTK libraries come in several different possible configurations # (release/debug, ansi/unicode, etc.), most of which can be installed # side-by-side. The purpose of this eclass is to give ebuilds the ability to # specify what particular flavour they require to build against without # interfering with the user-set system library configuration. # # Ebuilds that use wxGTK must inherit this eclass. Otherwise the system # default will be used, which would be anything the user set it to. # # Ebuilds are also required set the global variable WX_GTK_VER, containing the # wxGTK SLOT the ebuild requires. # # # Simple Usage: # # inherit wxwidgets # DEPEND="=x11-libs/wxGTK-2.6*" # WX_GTK_VER="2.6" # # That's it. The eclass will select a sane default configuration to use. In # wxGTK-2.6 the default is ansi. In wxGTK-2.8 and later it's unicode. These # are the defaults because they are always guaranteed to exist. (Note: we lock # the DEPEND to the needed SLOT to prevent another SLOT from fulfilling the # dependency.) # # You'll often find yourself in need of a bit more control. For that see the # need-wxwidgets function below. inherit eutils flag-o-matic multilib # We do this globally so ebuilds can get sane defaults just by inheriting. They # can be overridden with need-wxwidgets later if need be. if [[ -n ${WX_GTK_VER} ]]; then if [[ "${WX_GTK_VER}" == "2.6" ]]; then wxchar="ansi" elif [[ "${WX_GTK_VER}" == "2.8" ]]; then wxchar="unicode" else : fi for wxtoolkit in gtk2 base; do debug-print "global outer loop - wxtoolkit is ${wxtoolkit}" for wxdebug in release debug; do debug-print "global inner loop - wxdebug is ${wxdebug}" wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" debug-print "testing for config ${wxconf}" [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]] || continue debug-print "found config ${wxconf} - setting WX_CONFIG" WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" # needed for the wx-config wrapper WX_ECLASS_CONFIG="${WX_CONFIG}" break done [[ -n ${WX_CONFIG} ]] && break done [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG fi # @FUNCTION: need-wxwidgets # @USAGE: # @DESCRIPTION: # need-wxwidgets is called with one argument, the wxGTK configuration to use. # # Available configurations are: # # ansi # unicode # base-ansi # base-unicode # # Note that in >=wxGTK-2.8, only the unicode versions are available. The # eclass will automatically map ansi to unicode if WX_GTK_VER is set to 2.8 or # later. # # There are two other configurations, gtk2 and base, which correspond with ansi # and base-ansi. They are around for historical reasons and shouldn't be used # by new ebuilds. # # This function will set the variable WX_CONFIG to the path of the wx-config # script to use. In most cases you shouldn't have to use it since the # /usr/bin/wx-config wrapper points to ${WX_CONFIG} when called from portage. need-wxwidgets() { debug-print-function $FUNCNAME $* local wxtoolkit wxchar wxdebug wxconf append-flags -fno-strict-aliasing [[ -n ${WX_GTK_VER} ]] \ || _wxerror "WX_GTK_VER must be set before calling" if [[ "${WX_GTK_VER}" != "2.6" \ && "${WX_GTK_VER}" != "2.8" ]]; then _wxerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid SLOT" fi debug-print "WX_GTK_VER is ${WX_GTK_VER}" case $1 in ansi) debug-print-section ansi if [[ ${WX_GTK_VER} == 2.6 ]]; then wxchar="ansi" else wxchar="unicode" fi check_wxuse X ;; unicode) debug-print-section unicode check_wxuse X [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode wxchar="unicode" ;; base-ansi) debug-print-section base-ansi if [[ ${WX_GTK_VER} == 2.6 ]]; then wxchar="ansi" else wxchar="unicode" fi ;; base-unicode) debug-print-section base-unicode [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode wxchar="unicode" ;; # backwards compatibility gtk2) debug-print-section gtk2 if [[ ${WX_GTK_VER} == 2.6 ]]; then wxchar="ansi" else wxchar="unicode" fi check_wxuse X ;; base) debug-print-section base if [[ ${WX_GTK_VER} == 2.6 ]]; then wxchar="ansi" else wxchar="unicode" fi ;; *) _wxerror "called with invalid argument: $1" ;; esac debug-print "wxchar is ${wxchar}" # base can be provided by both gtk2 and base installations # since we're no longer in global scope we can test it and save a loop if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X); then wxtoolkit="gtk2" else wxtoolkit="base" fi debug-print "wxtoolkit is ${wxtoolkit}" if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug); then wxdebug="debug" else wxdebug="release" fi debug-print "wxdebug is ${wxdebug}" # put it all together wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" debug-print "wxconf is ${wxconf}" # if this doesn't work, something is seriously screwed if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then _wxerror "Failed to find configuration ${wxconf}" fi debug-print "Found config ${wxconf} - setting WX_CONFIG" export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" # Some more for good measure (seen in the wild) export WXCONFIG="${WX_CONFIG}" export WX_CONFIG_NAME="${wxconf}" debug-print "WX_CONFIG is ${WX_CONFIG}" # Used by the wx-config wrapper export WX_ECLASS_CONFIG="${WX_CONFIG}" echo ewarn "Requested: ${1} ${WX_GTK_VER}" ewarn "Using: ${wxconf}" echo } # @FUNCTION: check_wxuse # @USAGE: # @DESCRIPTION: # Provides a consistant way to check if wxGTK was built with a particular USE # flag enabled. check_wxuse() { debug-print-function $FUNCNAME $* [[ -n ${WX_GTK_VER} ]] \ || _wxerror "WX_GTK_VER must be set before calling" ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support" if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* ${1}); then eend 0 else eend 1 echo eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to" eerror "have been built into x11-libs/wxGTK." eerror eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled." die "Missing USE flags." fi } # internal error handling function # TODO - make pretties _wxerror() { echo eerror "${1}" echo die "${1}" }