wxwidgets.eclass 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: wxwidgets.eclass
  4. # @MAINTAINER:
  5. # wxwidgets@gentoo.org
  6. # @BLURB: Manages build configuration for wxGTK-using packages.
  7. # @DESCRIPTION:
  8. # This eclass sets up the proper environment for ebuilds using the wxGTK
  9. # libraries. Ebuilds using wxPython do not need to inherit this eclass.
  10. #
  11. # More specifically, this eclass controls the configuration chosen by the
  12. # /usr/bin/wx-config wrapper.
  13. #
  14. # Using the eclass is simple:
  15. #
  16. # - set WX_GTK_VER equal to a SLOT of wxGTK
  17. # - call setup-wxwidgets()
  18. #
  19. # The configuration chosen is based on the version required and the flags
  20. # wxGTK was built with.
  21. if [[ -z ${_WXWIDGETS_ECLASS} ]]; then
  22. case ${EAPI} in
  23. 0|1|2|3|4|5)
  24. inherit eutils flag-o-matic multilib
  25. # This was used to set up a sane default for ebuilds so they could
  26. # avoid calling need-wxwidgets if they didn't need a particular build.
  27. # This was a bad idea for a couple different reasons, and because
  28. # get_libdir() is now illegal in global scope in EAPI 6 we can't do it
  29. # anymore. All ebuilds must now use setup-wxwidgets and this code is
  30. # only here for backwards compatability.
  31. if [[ -z ${WX_CONFIG} ]]; then
  32. if [[ -n ${WX_GTK_VER} ]]; then
  33. for _wxtoolkit in mac gtk2 base; do
  34. # newer versions don't have a seperate debug config
  35. for _wxdebug in xxx release- debug-; do
  36. _wxconf="${_wxtoolkit}-unicode-${_wxdebug/xxx/}${WX_GTK_VER}"
  37. [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf} ]] \
  38. || continue
  39. WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf}"
  40. WX_ECLASS_CONFIG="${WX_CONFIG}"
  41. break
  42. done
  43. [[ -n ${WX_CONFIG} ]] && break
  44. done
  45. [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
  46. fi
  47. fi
  48. unset _wxtoolkit
  49. unset _wxdebug
  50. unset _wxconf
  51. ;;
  52. 6)
  53. inherit flag-o-matic multilib
  54. ;;
  55. *)
  56. die "EAPI=${EAPI:-0} is not supported"
  57. ;;
  58. esac
  59. # @FUNCTION: setup-wxwidgets
  60. # @DESCRIPTION:
  61. #
  62. # Call this in your ebuild to set up the environment for wxGTK. Besides
  63. # controlling the wx-config wrapper this exports WX_CONFIG containing
  64. # the path to the config in case it needs to be passed to a build system.
  65. #
  66. # In wxGTK-2.9 and later it also controls the level of debugging output
  67. # from the libraries. In these versions debugging features are enabled
  68. # by default and need to be disabled at the package level. Because this
  69. # causes many warning dialogs to pop up during runtime we add -DNDEBUG to
  70. # CPPFLAGS to disable debugging features (unless your ebuild has a debug
  71. # USE flag and it's enabled). If you don't like this behavior you can set
  72. # WX_DISABLE_NDEBUG to override it.
  73. #
  74. # See: http://docs.wxwidgets.org/trunk/overview_debugging.html
  75. setup-wxwidgets() {
  76. local wxtoolkit wxdebug wxconf
  77. [[ -z ${WX_GTK_VER} ]] \
  78. && die "WX_GTK_VER must be set before calling $FUNCNAME."
  79. case "${WX_GTK_VER}" in
  80. 3.0-gtk3)
  81. wxtoolkit=gtk3
  82. if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
  83. ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
  84. fi
  85. ;;
  86. 2.9|3.0)
  87. wxtoolkit=gtk2
  88. if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
  89. ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
  90. fi
  91. ;;
  92. 2.8)
  93. wxtoolkit=gtk2
  94. wxdebug="release-"
  95. has_version x11-libs/wxGTK:${WX_GTK_VER}[debug] && wxdebug="debug-"
  96. ;;
  97. *)
  98. die "Invalid WX_GTK_VER: must be set to a valid wxGTK SLOT"
  99. ;;
  100. esac
  101. # toolkit overrides
  102. if has_version "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
  103. wxtoolkit="mac"
  104. elif ! has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then
  105. wxtoolkit="base"
  106. fi
  107. wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
  108. [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]] \
  109. && die "Failed to find configuration ${wxconf}"
  110. export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
  111. export WX_ECLASS_CONFIG="${WX_CONFIG}"
  112. echo
  113. einfo "Requested wxWidgets: ${WX_GTK_VER}"
  114. einfo "Using wxWidgets: ${wxconf}"
  115. echo
  116. }
  117. # deprecated
  118. need-wxwidgets() {
  119. setup-wxwidgets
  120. }
  121. _WXWIDGETS_ECLASS=1
  122. fi