1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: gtk-sharp-module.eclass
7 # @BLURB: Manages the modules of the gtk-, gnome-, and gnome-desktop-sharp tarballs
9 # This eclass provides phase functions and helper functions for the modules
10 # of the gtk-sharp, gnome-sharp and gnome-desktop-sharp tarballs.
11 # PLEASE TAKE NOTE: ONLY FOR EAPI-2 EBUILDS
16 inherit eutils mono multilib libtool autotools base versionator
20 *) die "Unknown EAPI." ;;
23 # @ECLASS-VARIABLE: GTK_SHARP_MODULE
25 # The name of the Gtk# module.
26 # Default value: ${PN/-sharp/}
27 GTK_SHARP_MODULE=${GTK_SHARP_MODULE:=${PN/-sharp/}}
29 # @ECLASS-VARIABLE: GTK_SHARP_MODULE_DIR
31 # The subdirectory of S in which GTK_SHARP_MODULE is installed.
32 # Default value: ${PN/-sharp/}
33 GTK_SHARP_MODULE_DIR=${GTK_SHARP_MODULE_DIR:=${PN/-sharp/}}
35 # @ECLASS-VARIABLE: GTK_SHARP_REQUIRED_VERSION
37 # The version of the gtk-sharp tarball this package requires.
39 GTK_SHARP_REQUIRED_VERSION="${GTK_SHARP_REQUIRED_VERSION}"
41 # @ECLASS-VARIABLE: gapi_users_list
43 # List of modules that use one of gapi2-codegen, gapi2-fixup or gapi2-parser
44 # No ebuild-serviceable parts inside.
45 gapi_users_list="art gnome gnomevfs ${gnome_desktop_sharp_module_list} atk gtk gdk glade pango"
47 # @ECLASS-VARIABLE: PV_MAJOR
49 # The first two components of the PV variable.
50 PV_MAJOR=$(get_version_component_range 1-2)
52 # @FUNCTION: add_bdepend
53 # @USAGE: <package atom>
55 # Adds to the DEPEND variable
57 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs ONE (1) argument"
61 # @FUNCTION: add_rdepend
62 # @USAGE: <package atom>
64 # Adds to the RDEPEND variable
66 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs ONE (1) argument"
67 RDEPEND="${RDEPEND} $@"
70 # @FUNCTION: add_depend
71 # @USAGE: <package atom>
73 # Adds to the DEPEND and RDEPEND variables
75 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs ONE (1) argument"
77 RDEPEND="${RDEPEND} $@"
80 # @ECLASS-VARIABLE: TARBALL
82 # The GtkSharp modules are currently divided into three seperate tarball
83 # distributions. The TARBALL variable holds the name of the tarball
84 # to which GTK_SHARP_MODULE belongs.
85 case ${GTK_SHARP_MODULE} in
86 glib|glade|gtk|gdk|atk|pango|gtk-dotnet|gtk-gapi|gtk-docs)
90 SRC_URI="mirror://gentoo/${TARBALL}-2.12.7.patch.bz2"
91 #Upstream: https://bugzilla.novell.com/show_bug.cgi?id=$bugno
92 #Upstream bug #470390 for the gtk-sharp-2.12.7.patch
94 "${WORKDIR}/${TARBALL}-2.12.7.patch"
98 SRC_URI="mirror://gentoo/${TARBALL}-2.12.11.patch.bz2"
100 "${WORKDIR}/${TARBALL}-2.12.11.patch"
107 add_bdepend "=sys-devel/automake-1.10*"
108 add_bdepend ">=sys-devel/autoconf-2.61"
112 art|gnome|gnomevfs|gconf)
113 TARBALL="gnome-sharp"
114 add_depend "=dev-dotnet/gtk-sharp-${GTK_SHARP_REQUIRED_VERSION}*"
115 has "${GTK_SHARP_MODULE}" "${gapi_users_list}" && \
116 add_bdepend "=dev-dotnet/gtk-sharp-gapi-${GTK_SHARP_REQUIRED_VERSION}*"
119 SRC_URI="mirror://gentoo/${TARBALL}-2.24.1.patch.bz2"
120 # Upstream bug: https://bugzilla.novell.com/show_bug.cgi?id=483251
122 "${WORKDIR}/${TARBALL}-2.24.1.patch"
125 add_bdepend "=sys-devel/automake-1.10*"
126 add_bdepend ">=sys-devel/autoconf-2.61"
129 add_depend ">=dev-lang/mono-2.7"
133 gnome-desktop|gnome-print|gnome-panel|gtkhtml|gtksourceview|nautilusburn|rsvg|vte|wnck)
134 TARBALL="gnome-desktop-sharp"
135 add_depend "=dev-dotnet/gtk-sharp-${GTK_SHARP_REQUIRED_VERSION}*"
136 add_depend "=dev-dotnet/gnome-sharp-2.24*"
137 add_depend "gnome-base/gnome-desktop:2"
138 add_bdepend "|| ( >=dev-dotnet/gtk-sharp-2.12.21 =dev-dotnet/gtk-sharp-gapi-${GTK_SHARP_REQUIRED_VERSION}* )"
141 eerror "Huh? Sonny boy, looks like your GTK_SHARP_MODULE is not on the approved list. BAILING!"
142 die "How did we get here!!?"
149 add_depend ">=dev-lang/mono-2.0"
152 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
153 add_depend "dev-perl/XML-LibXML"
156 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
157 add_depend "~dev-dotnet/glib-sharp-${PV}"
158 add_depend "~dev-dotnet/atk-sharp-${PV}"
159 add_depend "~dev-dotnet/gdk-sharp-${PV}"
160 add_depend "~dev-dotnet/pango-sharp-${PV}"
163 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
164 add_depend "~dev-dotnet/glib-sharp-${PV}"
165 add_depend "x11-libs/gtk+:2"
166 add_depend "~dev-dotnet/pango-sharp-${PV}"
167 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
170 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
171 add_depend "~dev-dotnet/glib-sharp-${PV}"
172 add_depend "dev-libs/atk"
173 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
176 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
177 add_depend "dev-libs/glib:2"
180 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
181 add_depend "~dev-dotnet/glib-sharp-${PV}"
182 add_depend "x11-libs/pango"
183 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
186 add_depend "~dev-dotnet/glib-sharp-${PV}"
187 add_depend "~dev-dotnet/gdk-sharp-${PV}"
188 add_depend "~dev-dotnet/pango-sharp-${PV}"
189 add_depend "~dev-dotnet/gtk-sharp-${PV}"
190 add_depend "dev-lang/mono[-minimal]"
191 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
194 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
195 add_depend "~dev-dotnet/glib-sharp-${PV}"
196 add_depend "~dev-dotnet/atk-sharp-${PV}"
197 add_depend "~dev-dotnet/gdk-sharp-${PV}"
198 add_depend "~dev-dotnet/gtk-sharp-${PV}"
199 add_depend "~dev-dotnet/pango-sharp-${PV}"
200 add_depend ">=gnome-base/libglade-2.3.6:2.0"
204 add_depend ">=media-libs/libart_lgpl-2.3.20"
207 add_depend ">=gnome-base/libgnomeui-${PV_MAJOR}"
208 add_depend "~dev-dotnet/gnomevfs-sharp-${PV}"
209 add_depend "~dev-dotnet/art-sharp-${PV}"
210 add_depend ">=gnome-base/libgnomecanvas-${GNOMECANVAS_REQUIRED_VERSION}"
211 add_depend ">=x11-libs/gtk+-2.14.0:2"
214 add_depend ">=gnome-base/gconf-${PV_MAJOR}:2"
215 add_depend "=dev-dotnet/glade-sharp-${GTK_SHARP_REQUIRED_VERSION}*"
216 add_depend "~dev-dotnet/gnome-sharp-${PV}"
217 add_depend "~dev-dotnet/art-sharp-${PV}"
220 add_depend ">=gnome-base/gnome-vfs-${PV_MAJOR}:2"
222 #gnome-desktop-sharp tarball
223 gnome-desktop-sharp-*)
224 # NOTE: libgnome-desktop-2.so has been known to make binary-
225 # incompatible changes, requiring .so bumps. gnome-desktop-sharp
226 # is locked to a specific .so.n version, so strict dependencies
227 # may be required in the future (as it has in the past).
228 add_depend ">=gnome-base/gnome-desktop-${PV_MAJOR}:2"
231 add_depend ">=gnome-base/gnome-panel-${PV_MAJOR}"
234 add_depend "gnome-base/libgnomeprint:2.2"
235 add_depend "gnome-base/libgnomeprintui:2.2"
238 #NOTE: gtkhtml dependency must follow gtkhtml-sharp version.
239 #i.e. gtkhtml-sharp-2.24.0 >=gtkhtml-3.24
240 # gtkhtml-sharp-2.16.0 >=gtkhtml-3.16
241 # See bug 249540 for unpleasant side effects.
242 add_depend ">=gnome-extra/gtkhtml-$(($(get_version_component_range 1) + 1 )).$(get_version_component_range 2):3.14"
244 gtksourceview-sharp-*)
245 add_depend ">=x11-libs/gtksourceview-${GTKSOURCEVIEW_REQUIRED_VERSION}:2.0"
247 nautilusburn-sharp-*)
248 add_depend ">=gnome-extra/nautilus-cd-burner-2.24.0"
251 add_depend ">=gnome-base/librsvg-${RSVG_REQUIRED_VERSION}:2"
254 add_depend ">=x11-libs/vte-${VTE_REQUIRED_VERSION}:0"
257 add_depend ">=x11-libs/libwnck-${PV_MAJOR}:1"
261 # @ECLASS-VARIABLE: DESCRIPTION
263 # Default value: GtkSharp's ${GTK_SHARP_MODULE} module of the ${TARBALL} tarball
264 DESCRIPTION="GtkSharp's ${GTK_SHARP_MODULE} module of the ${TARBALL} tarball"
265 # @ECLASS-VARIABLE: HOMEPAGE
267 # Default value: http://www.mono-project.com/GtkSharp
268 HOMEPAGE="http://www.mono-project.com/GtkSharp"
269 # @ECLASS-VARIABLE: LICENSE
271 # Default value: LGPL-2.1
274 add_depend ">=dev-lang/mono-2.0.1"
275 add_bdepend ">=sys-apps/sed-4"
276 add_bdepend "virtual/pkgconfig"
277 add_bdepend ">=app-shells/bash-3.1"
280 # @ECLASS-VARIABLE: S
282 # Default value: ${WORKDIR}/${TARBALL}-${PV}
283 S="${WORKDIR}/${TARBALL}-${PV}"
284 # @ECLASS-VARIABLE: SRC_URI
286 # Default value: mirror://gnome/sources/${TARBALL}/${PV_MAJOR}/${TARBALL}-${PV}.tar.bz2
287 if [[ ${TARBALL} == "gtk-sharp" ]]; then
289 http://download.mono-project.com/sources/gtk-sharp212/${TARBALL}-${PV}.tar.bz2"
292 mirror://gnome/sources/${TARBALL}/${PV_MAJOR}/${TARBALL}-${PV}.tar.bz2"
295 # @FUNCTION: get_sharp_apis
296 # @USAGE: <type> <pkgconfig-package>
297 # @RETURN: .NET API files
299 # Given a valid pkg-config package, will return a list of API xml files.
300 # <type> can be either --prefixed or --bare. If prefixed, each API file
301 # will be prefixed with -I:
303 [[ ${#@} -eq 2 ]] || die "${FUNCNAME} needs two arguments"
304 get_sharp_assemblies "$@"
307 # @FUNCTION: get_sharp_assemblies
308 # @USAGE: <type> <pkgconfig-package>
309 # @RETURN: .NET .dll assemblies
311 # Given a valid pkg-config package, will return a list of .dll assemblies.
312 # <type> can be either --prefixed or --bare. If prefixed, each .dll file
313 # will be prefixed with -r:
314 get_sharp_assemblies() {
315 [[ ${#@} -eq 2 ]] || die "${FUNCNAME} needs two arguments"
316 local string config=libs prefix="-r:"
318 [[ "${FUNCNAME[1]}" = "get_sharp_apis" ]] && config=cflags && prefix="-I:"
319 for string in $(pkg-config --${config} ${2} 2> /dev/null)
321 rvalue+=( ${string#-?:} )
329 for (( i=0 ; i< ${#rvalue[@]} ; i++ ))
331 rvalue[$i]=${prefix}${rvalue[$i]}
335 die "${FUNCNAME}: Unknown parameter"
341 # @FUNCTION: phase_hook
344 # Looks for functions named <prefix>_caller_suffix and executes them.
345 # _caller_suffix is the calling function with the prefix
346 # gtk-sharp-module removed.
348 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs one argument"
349 if [[ "$(type -t ${1}${FUNCNAME[1]#gtk-sharp-module})" = "function" ]]
351 ebegin "Phase-hook: Running ${1}${FUNCNAME[1]#gtk-sharp-module}"
352 ${1}${FUNCNAME[1]#gtk-sharp-module}
357 # @FUNCTION: ac_path_prog_override
358 # @USAGE: <PROG> [path]
360 # Override AC_PATH_PROG() autoconf macros. Path will be set to " " if
362 ac_path_prog_override() {
363 if [[ ${#@} -lt 1 || ${#@} -gt 2 ]]
365 eerror "${FUNCNAME[0]} requires at least one parameter and takes at most two:"
366 eerror "AC_PATH_PROG(PARAM1, param2)"
367 die "${FUNCNAME[0]} requires at least one parameter and takes at most two:"
369 export ac_cv_path_${1}="${2:- }"
373 # @FUNCTION: pkg_check_modules_override
374 # @USAGE: <GROUP> [package1] [package2]
376 # Will export the appropriate variables to override PKG_CHECK_MODULES autoconf
377 # macros, with the string " " by default. If packages are specified, they will
378 # be looked up with pkg-config and the appropriate LIBS and CFLAGS substituted.
379 # LIBS and CFLAGS can also be specified per-package with the following syntax:
381 # package=LIBS%CFLAGS
383 # = and % have no effect unless both are specified.
384 # Here is an example:
386 # pkg_check_modules_override GASH "gtk+-2.0=-jule%" gobject-2.0
388 # The above example will do:
389 # export GASH_CFLAGS+=" -jule"
390 # export GASH_LIBS+=" "
391 # export GASH_CFLAGS+=" $(pkg-config --cflags gobject-2.0)"
392 # export GASH_LIBS+=" $(pkg-config --libs gobject-2.0)"
394 # NOTE: If a package is not found, the string " " will be inserted in place of
395 # <GROUP>_CFLAGS and <GROUP>_LIBS
396 pkg_check_modules_override() {
399 local packages="${*:2}"
400 export ${group}_CFLAGS=" "
401 export ${group}_LIBS=" "
405 eerror "${FUNCNAME[0]} requires at least one parameter: GROUP"
406 eerror "PKG_CHECK_MODULES(GROUP, package1 package2 etc)"
407 die "${FUNCNAME[0]} requires at least one parameter: GROUP"
410 for package in $packages
412 if [[ ${package/=} != ${package} && ${package/\%} != ${package} ]]
414 package_cflag_libs=${package##*=}
415 export ${group}_CFLAGS+=" ${package_cflag_libs%%\%*}"
416 export ${group}_LIBS+=" ${package_cflag_libs##*\%}"
418 if pkg-config --exists $package
420 export ${group}_CFLAGS+=" $(pkg-config --cflags $package)"
421 export ${group}_LIBS+=" $(pkg-config --libs $package)"
423 export ${group}_CFLAGS+=" "
424 export ${group}_LIBS+=" "
430 # @FUNCTION: gtk-sharp-tarball-post_src_prepare
432 # Runs a M-m-m-monster sed on GTK_SHARP_MODULE_DIR to convert references to
433 # local assemblies to the installed ones. Is only called by src_prepare when
434 # $GTK_SHARP_MODULE is a member of $gtk_sharp_module_list.
435 gtk-sharp-tarball-post_src_prepare() {
436 has "${EAPI:-0}" 2 && ! use prefix && EPREFIX=
437 cd "${S}/${GTK_SHARP_MODULE_DIR}"
439 -e "s; \$(srcdir)/../glib/glib-api.xml; $(get_sharp_apis --bare glib-sharp-2.0);" \
440 -e "s; ../pango/pango-api.xml; $(get_sharp_apis --bare pango-sharp-2.0);" \
441 -e "s; ../atk/atk-api.xml; $(get_sharp_apis --bare atk-sharp-2.0);" \
442 -e "s; ../gdk/gdk-api.xml; $(get_sharp_apis --bare gdk-sharp-2.0);" \
443 -e "s; ../gtk/gtk-api.xml; $(get_sharp_apis --bare gtk-sharp-2.0);" \
444 -e "s; \.\./glib/glib-sharp.dll; $(get_sharp_assemblies --bare glib-sharp-2.0);g" \
445 -e "s; \.\./pango/pango-sharp.dll; $(get_sharp_assemblies --bare pango-sharp-2.0);g" \
446 -e "s; \.\./atk/atk-sharp.dll; $(get_sharp_assemblies --bare atk-sharp-2.0);g" \
447 -e "s; \.\./gdk/gdk-sharp.dll; $(get_sharp_assemblies --bare gdk-sharp-2.0);g" \
448 -e "s; \.\./gtk/gtk-sharp.dll; $(get_sharp_assemblies --bare gtk-sharp-2.0);g" \
449 -e "s;\$(RUNTIME) \$(top_builddir)/parser/gapi-fixup.exe;${EPREFIX}/usr/bin/gapi2-fixup;" \
450 -e "s;\$(RUNTIME) \$(top_builddir)/generator/gapi_codegen.exe;${EPREFIX}/usr/bin/gapi2-codegen;" \
451 -e "s:\$(SYMBOLS) \$(top_builddir)/parser/gapi-fixup.exe:\$(SYMBOLS):" \
452 -e "s:\$(INCLUDE_API) \$(top_builddir)/generator/gapi_codegen.exe:\$(INCLUDE_API):" \
453 $(find . -name Makefile.in) || die "failed to fix ${TARBALL}-tarball makefiles"
456 # @FUNCTION: gnome-sharp-tarball-post_src_prepare
458 # Runs a M-m-m-monster sed on GTK_SHARP_MODULE_DIR to convert references to
459 # local assemblies to the installed ones. Is only called by src_prepare when
460 # $GTK_SHARP_MODULE is a member of $gnome_sharp_module_list.
461 gnome-sharp-tarball-post_src_prepare() {
462 cd "${S}/${GTK_SHARP_MODULE_DIR}"
464 -e "s; ../gnomevfs/gnome-vfs-api.xml; $(get_sharp_apis --bare gnome-vfs-sharp-2.0);" \
465 -e "s; ../art/art-api.xml; $(get_sharp_apis --bare art-sharp-2.0);" \
466 -e "s; \.\./art/art-sharp.dll; $(get_sharp_assemblies --bare art-sharp-2.0);g" \
467 -e "s; \.\./gnomevfs/gnome-vfs-sharp.dll; $(get_sharp_assemblies --bare gnome-vfs-sharp-2.0);g" \
468 -e "s;/r:\$(top_builddir)/art/art-sharp.dll;$(get_sharp_assemblies --prefixed art-sharp-2.0);" \
469 -e "s;/r:\$(top_builddir)/gnome/gnome-sharp.dll;$(get_sharp_assemblies --prefixed gnome-sharp-2.0);" \
470 $(find . -name Makefile.in) || die "failed to fix ${TARBALL}-tarball makefiles"
473 # @FUNCTION: gtk-sharp-module_src_prepare
475 # Runs autopatch from base.eclass, eautoreconf if EAUTORECONF is set to any
477 # Contains a phase_hook, runs very last.
478 # phase_hook prefix trigger: ${TARBALL}-tarball-post
480 gtk-sharp-module_src_prepare() {
482 # @ECLASS-VARIABLE: EAUTORECONF
484 # If set, EAUTORECONF will be run during src_prepare.
485 [[ ${EAUTORECONF} ]] && eautoreconf
486 phase_hook ${TARBALL}-tarball-post
490 # @FUNCTION: gtk-sharp-tarball_src_configure
492 # Sets some environment variables that will allow us to make the dependencies
493 # for each ebuild be only its own dependencies, without patching configure.
494 # Is only called by gtk-sharp-module_src_configure when $GTK_SHARP_MODULE
495 # is a member of $gtk_sharp_module_list.
496 gtk-sharp-tarball_src_configure() {
497 pkg_check_modules_override GLIB gobject-2.0
498 pkg_check_modules_override GIO gio-2.0
499 pkg_check_modules_override PANGO pango
500 pkg_check_modules_override ATK atk
501 pkg_check_modules_override GTK gtk+-2.0
502 pkg_check_modules_override GLADE libglade-2.0
505 # @FUNCTION: gnome-sharp-tarball_src_configure
507 # Sets some environment variables that will allow us to make the dependencies
508 # for each ebuild be only its own dependencies. Without patching configure.
509 # Is only called by gtk-sharp-module_src_configure when $GTK_SHARP_MODULE
510 # is a member of $gnome_sharp_module_list.
511 gnome-sharp-tarball_src_configure() {
512 has "${EAPI:-0}" 2 && ! use prefix && EPREFIX=
513 pkg_check_modules_override GLADESHARP glade-sharp-2.0
514 pkg_check_modules_override GAPI gapi-2.0
515 ac_path_prog_override GAPI_PARSER "${EPREFIX}"/usr/bin/gapi2-parser
516 ac_path_prog_override GAPI_CODEGEN "${EPREFIX}"/usr/bin/gapi2-codegen
517 ac_path_prog_override GAPI_FIXUP "${EPREFIX}"/usr/bin/gapi2-fixup
520 # @FUNCTION: gtk-sharp-module_src_configure
521 # @USAGE: [econf-arguments]
523 # Calls econf with some default values.
524 # Contains a phase_hook, run before econf.
525 # phase_hook prefix trigger: ${TARBALL}-tarball
527 gtk-sharp-module_src_configure() {
528 phase_hook ${TARBALL}-tarball
529 econf --disable-static \
530 --disable-dependency-tracking \
531 --disable-maintainer-mode \
532 $(use debug &&echo "--enable-debug" ) \
533 ${@} || die "econf failed"
536 # @FUNCTION: gtk-sharp-module_src_compile
538 # Calls emake in the subdir of the module.
539 # Sets CSC=/usr/bin/mcs. Deletes top_srcdir Makefiles to prevent recursing in
540 # case we missed some dll references.
542 gtk-sharp-module_src_compile() {
543 rm -f "${S}"/Makefile* &> /dev/null
544 cd "${S}/${GTK_SHARP_MODULE_DIR}"
545 emake CSC=/usr/bin/mcs || die "emake failed"
548 # @FUNCTION: gtk-sharp-module_src_install
550 # Installs the module. Fixes up lib paths so they're multilib-safe.
551 # Gets rid of .la files.
553 gtk-sharp-module_src_install() {
554 cd "${S}/${GTK_SHARP_MODULE_DIR}"
555 emake DESTDIR="${D}" install || die "emake install failed"
557 find "${D}" -type f -name '*.la' -exec rm -rf '{}' '+' || die "la removal failed"
558 [[ $(find "${D}" -type f|wc -l) -lt 3 ]] && die "Too few files. This smells like a failed install."
561 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install