1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: gtk-sharp-module.eclass
8 # @BLURB: Manages the modules of the gtk-, gnome-, and gnome-desktop-sharp tarballs
10 # This eclass provides phase functions and helper functions for the modules
11 # of the gtk-sharp, gnome-sharp and gnome-desktop-sharp tarballs.
12 # PLEASE TAKE NOTE: ONLY FOR EAPI-2 EBUILDS
17 inherit eutils mono multilib libtool autotools base versionator
21 *) die "Unknown EAPI." ;;
24 # @ECLASS-VARIABLE: GTK_SHARP_MODULE
26 # The name of the Gtk# module.
27 # Default value: ${PN/-sharp/}
28 GTK_SHARP_MODULE=${GTK_SHARP_MODULE:=${PN/-sharp/}}
30 # @ECLASS-VARIABLE: GTK_SHARP_MODULE_DIR
32 # The subdirectory of S in which GTK_SHARP_MODULE is installed.
33 # Default value: ${PN/-sharp/}
34 GTK_SHARP_MODULE_DIR=${GTK_SHARP_MODULE_DIR:=${PN/-sharp/}}
36 # @ECLASS-VARIABLE: GTK_SHARP_REQUIRED_VERSION
38 # The version of the gtk-sharp tarball this package requires.
40 GTK_SHARP_REQUIRED_VERSION="${GTK_SHARP_REQUIRED_VERSION}"
42 # @ECLASS-VARIABLE: gapi_users_list
44 # List of modules that use one of gapi2-codegen, gapi2-fixup or gapi2-parser
45 # No ebuild-serviceable parts inside.
46 gapi_users_list="art gnome gnomevfs ${gnome_desktop_sharp_module_list} atk gtk gdk glade pango"
48 # @ECLASS-VARIABLE: PV_MAJOR
50 # The first two components of the PV variable.
51 PV_MAJOR=$(get_version_component_range 1-2)
53 # @FUNCTION: add_bdepend
54 # @USAGE: <package atom>
56 # Adds to the DEPEND variable
58 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs ONE (1) argument"
62 # @FUNCTION: add_rdepend
63 # @USAGE: <package atom>
65 # Adds to the RDEPEND variable
67 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs ONE (1) argument"
68 RDEPEND="${RDEPEND} $@"
71 # @FUNCTION: add_depend
72 # @USAGE: <package atom>
74 # Adds to the DEPEND and RDEPEND variables
76 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs ONE (1) argument"
78 RDEPEND="${RDEPEND} $@"
81 # @ECLASS-VARIABLE: TARBALL
83 # The GtkSharp modules are currently divided into three seperate tarball
84 # distributions. The TARBALL variable holds the name of the tarball
85 # to which GTK_SHARP_MODULE belongs.
86 case ${GTK_SHARP_MODULE} in
87 glib|glade|gtk|gdk|atk|pango|gtk-dotnet|gtk-gapi|gtk-docs)
91 SRC_URI="mirror://gentoo/${TARBALL}-2.12.7.patch.bz2"
92 #Upstream: https://bugzilla.novell.com/show_bug.cgi?id=$bugno
93 #Upstream bug #470390 for the gtk-sharp-2.12.7.patch
95 "${WORKDIR}/${TARBALL}-2.12.7.patch"
99 SRC_URI="mirror://gentoo/${TARBALL}-2.12.11.patch.bz2"
101 "${WORKDIR}/${TARBALL}-2.12.11.patch"
108 add_bdepend "=sys-devel/automake-1.10*"
109 add_bdepend ">=sys-devel/autoconf-2.61"
113 art|gnome|gnomevfs|gconf)
114 TARBALL="gnome-sharp"
115 add_depend "=dev-dotnet/gtk-sharp-${GTK_SHARP_REQUIRED_VERSION}*"
116 has "${GTK_SHARP_MODULE}" "${gapi_users_list}" && \
117 add_bdepend "=dev-dotnet/gtk-sharp-gapi-${GTK_SHARP_REQUIRED_VERSION}*"
120 SRC_URI="mirror://gentoo/${TARBALL}-2.24.1.patch.bz2"
121 # Upstream bug: https://bugzilla.novell.com/show_bug.cgi?id=483251
123 "${WORKDIR}/${TARBALL}-2.24.1.patch"
126 add_bdepend "=sys-devel/automake-1.10*"
127 add_bdepend ">=sys-devel/autoconf-2.61"
130 add_depend ">=dev-lang/mono-2.7"
134 gnome-desktop|gnome-print|gnome-panel|gtkhtml|gtksourceview|nautilusburn|rsvg|vte|wnck)
135 TARBALL="gnome-desktop-sharp"
136 add_depend "=dev-dotnet/gtk-sharp-${GTK_SHARP_REQUIRED_VERSION}*"
137 add_depend "=dev-dotnet/gnome-sharp-2.24*"
138 add_depend "gnome-base/gnome-desktop:2"
139 add_bdepend "|| ( >=dev-dotnet/gtk-sharp-2.12.21 =dev-dotnet/gtk-sharp-gapi-${GTK_SHARP_REQUIRED_VERSION}* )"
142 eerror "Huh? Sonny boy, looks like your GTK_SHARP_MODULE is not on the approved list. BAILING!"
143 die "How did we get here!!?"
150 add_depend ">=dev-lang/mono-2.0"
153 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
154 add_depend "dev-perl/XML-LibXML"
157 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
158 add_depend "~dev-dotnet/glib-sharp-${PV}"
159 add_depend "~dev-dotnet/atk-sharp-${PV}"
160 add_depend "~dev-dotnet/gdk-sharp-${PV}"
161 add_depend "~dev-dotnet/pango-sharp-${PV}"
164 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
165 add_depend "~dev-dotnet/glib-sharp-${PV}"
166 add_depend "x11-libs/gtk+:2"
167 add_depend "~dev-dotnet/pango-sharp-${PV}"
168 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
171 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
172 add_depend "~dev-dotnet/glib-sharp-${PV}"
173 add_depend "dev-libs/atk"
174 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
177 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
178 add_depend "dev-libs/glib:2"
181 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
182 add_depend "~dev-dotnet/glib-sharp-${PV}"
183 add_depend "x11-libs/pango"
184 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
187 add_depend "~dev-dotnet/glib-sharp-${PV}"
188 add_depend "~dev-dotnet/gdk-sharp-${PV}"
189 add_depend "~dev-dotnet/pango-sharp-${PV}"
190 add_depend "~dev-dotnet/gtk-sharp-${PV}"
191 add_depend "dev-lang/mono[-minimal]"
192 add_rdepend "!<=dev-dotnet/gtk-sharp-2.12.7:2"
195 add_bdepend "~dev-dotnet/gtk-sharp-gapi-${PV}"
196 add_depend "~dev-dotnet/glib-sharp-${PV}"
197 add_depend "~dev-dotnet/atk-sharp-${PV}"
198 add_depend "~dev-dotnet/gdk-sharp-${PV}"
199 add_depend "~dev-dotnet/gtk-sharp-${PV}"
200 add_depend "~dev-dotnet/pango-sharp-${PV}"
201 add_depend ">=gnome-base/libglade-2.3.6:2.0"
205 add_depend ">=media-libs/libart_lgpl-2.3.20"
208 add_depend ">=gnome-base/libgnomeui-${PV_MAJOR}"
209 add_depend "~dev-dotnet/gnomevfs-sharp-${PV}"
210 add_depend "~dev-dotnet/art-sharp-${PV}"
211 add_depend ">=gnome-base/libgnomecanvas-${GNOMECANVAS_REQUIRED_VERSION}"
212 add_depend ">=x11-libs/gtk+-2.14.0:2"
215 add_depend ">=gnome-base/gconf-${PV_MAJOR}:2"
216 add_depend "=dev-dotnet/glade-sharp-${GTK_SHARP_REQUIRED_VERSION}*"
217 add_depend "~dev-dotnet/gnome-sharp-${PV}"
218 add_depend "~dev-dotnet/art-sharp-${PV}"
221 add_depend ">=gnome-base/gnome-vfs-${PV_MAJOR}:2"
223 #gnome-desktop-sharp tarball
224 gnome-desktop-sharp-*)
225 # NOTE: libgnome-desktop-2.so has been known to make binary-
226 # incompatible changes, requiring .so bumps. gnome-desktop-sharp
227 # is locked to a specific .so.n version, so strict dependencies
228 # may be required in the future (as it has in the past).
229 add_depend ">=gnome-base/gnome-desktop-${PV_MAJOR}:2"
232 add_depend ">=gnome-base/gnome-panel-${PV_MAJOR}"
235 add_depend "gnome-base/libgnomeprint:2.2"
236 add_depend "gnome-base/libgnomeprintui:2.2"
239 #NOTE: gtkhtml dependency must follow gtkhtml-sharp version.
240 #i.e. gtkhtml-sharp-2.24.0 >=gtkhtml-3.24
241 # gtkhtml-sharp-2.16.0 >=gtkhtml-3.16
242 # See bug 249540 for unpleasant side effects.
243 add_depend ">=gnome-extra/gtkhtml-$(($(get_version_component_range 1) + 1 )).$(get_version_component_range 2):3.14"
245 gtksourceview-sharp-*)
246 add_depend ">=x11-libs/gtksourceview-${GTKSOURCEVIEW_REQUIRED_VERSION}:2.0"
248 nautilusburn-sharp-*)
249 add_depend ">=gnome-extra/nautilus-cd-burner-2.24.0"
252 add_depend ">=gnome-base/librsvg-${RSVG_REQUIRED_VERSION}:2"
255 add_depend ">=x11-libs/vte-${VTE_REQUIRED_VERSION}:0"
258 add_depend ">=x11-libs/libwnck-${PV_MAJOR}:1"
262 # @ECLASS-VARIABLE: DESCRIPTION
264 # Default value: GtkSharp's ${GTK_SHARP_MODULE} module of the ${TARBALL} tarball
265 DESCRIPTION="GtkSharp's ${GTK_SHARP_MODULE} module of the ${TARBALL} tarball"
266 # @ECLASS-VARIABLE: HOMEPAGE
268 # Default value: http://www.mono-project.com/GtkSharp
269 HOMEPAGE="http://www.mono-project.com/GtkSharp"
270 # @ECLASS-VARIABLE: LICENSE
272 # Default value: LGPL-2.1
275 add_depend ">=dev-lang/mono-2.0.1"
276 add_bdepend ">=sys-apps/sed-4"
277 add_bdepend "virtual/pkgconfig"
278 add_bdepend ">=app-shells/bash-3.1"
281 # @ECLASS-VARIABLE: S
283 # Default value: ${WORKDIR}/${TARBALL}-${PV}
284 S="${WORKDIR}/${TARBALL}-${PV}"
285 # @ECLASS-VARIABLE: SRC_URI
287 # Default value: mirror://gnome/sources/${TARBALL}/${PV_MAJOR}/${TARBALL}-${PV}.tar.bz2
288 if [[ ${TARBALL} == "gtk-sharp" ]]; then
290 http://download.mono-project.com/sources/gtk-sharp212/${TARBALL}-${PV}.tar.bz2"
293 mirror://gnome/sources/${TARBALL}/${PV_MAJOR}/${TARBALL}-${PV}.tar.bz2"
296 # @FUNCTION: get_sharp_apis
297 # @USAGE: <type> <pkgconfig-package>
298 # @RETURN: .NET API files
300 # Given a valid pkg-config package, will return a list of API xml files.
301 # <type> can be either --prefixed or --bare. If prefixed, each API file
302 # will be prefixed with -I:
304 [[ ${#@} -eq 2 ]] || die "${FUNCNAME} needs two arguments"
305 get_sharp_assemblies "$@"
308 # @FUNCTION: get_sharp_assemblies
309 # @USAGE: <type> <pkgconfig-package>
310 # @RETURN: .NET .dll assemblies
312 # Given a valid pkg-config package, will return a list of .dll assemblies.
313 # <type> can be either --prefixed or --bare. If prefixed, each .dll file
314 # will be prefixed with -r:
315 get_sharp_assemblies() {
316 [[ ${#@} -eq 2 ]] || die "${FUNCNAME} needs two arguments"
317 local string config=libs prefix="-r:"
319 [[ "${FUNCNAME[1]}" = "get_sharp_apis" ]] && config=cflags && prefix="-I:"
320 for string in $(pkg-config --${config} ${2} 2> /dev/null)
322 rvalue+=( ${string#-?:} )
330 for (( i=0 ; i< ${#rvalue[@]} ; i++ ))
332 rvalue[$i]=${prefix}${rvalue[$i]}
336 die "${FUNCNAME}: Unknown parameter"
342 # @FUNCTION: phase_hook
345 # Looks for functions named <prefix>_caller_suffix and executes them.
346 # _caller_suffix is the calling function with the prefix
347 # gtk-sharp-module removed.
349 [[ ${#@} -eq 1 ]] || die "${FUNCNAME} needs one argument"
350 if [[ "$(type -t ${1}${FUNCNAME[1]#gtk-sharp-module})" = "function" ]]
352 ebegin "Phase-hook: Running ${1}${FUNCNAME[1]#gtk-sharp-module}"
353 ${1}${FUNCNAME[1]#gtk-sharp-module}
358 # @FUNCTION: ac_path_prog_override
359 # @USAGE: <PROG> [path]
361 # Override AC_PATH_PROG() autoconf macros. Path will be set to " " if
363 ac_path_prog_override() {
364 if [[ ${#@} -lt 1 || ${#@} -gt 2 ]]
366 eerror "${FUNCNAME[0]} requires at least one parameter and takes at most two:"
367 eerror "AC_PATH_PROG(PARAM1, param2)"
368 die "${FUNCNAME[0]} requires at least one parameter and takes at most two:"
370 export ac_cv_path_${1}="${2:- }"
374 # @FUNCTION: pkg_check_modules_override
375 # @USAGE: <GROUP> [package1] [package2]
377 # Will export the appropriate variables to override PKG_CHECK_MODULES autoconf
378 # macros, with the string " " by default. If packages are specified, they will
379 # be looked up with pkg-config and the appropriate LIBS and CFLAGS substituted.
380 # LIBS and CFLAGS can also be specified per-package with the following syntax:
382 # package=LIBS%CFLAGS
384 # = and % have no effect unless both are specified.
385 # Here is an example:
387 # pkg_check_modules_override GASH "gtk+-2.0=-jule%" gobject-2.0
389 # The above example will do:
390 # export GASH_CFLAGS+=" -jule"
391 # export GASH_LIBS+=" "
392 # export GASH_CFLAGS+=" $(pkg-config --cflags gobject-2.0)"
393 # export GASH_LIBS+=" $(pkg-config --libs gobject-2.0)"
395 # NOTE: If a package is not found, the string " " will be inserted in place of
396 # <GROUP>_CFLAGS and <GROUP>_LIBS
397 pkg_check_modules_override() {
400 local packages="${*:2}"
401 export ${group}_CFLAGS=" "
402 export ${group}_LIBS=" "
406 eerror "${FUNCNAME[0]} requires at least one parameter: GROUP"
407 eerror "PKG_CHECK_MODULES(GROUP, package1 package2 etc)"
408 die "${FUNCNAME[0]} requires at least one parameter: GROUP"
411 for package in $packages
413 if [[ ${package/=} != ${package} && ${package/\%} != ${package} ]]
415 package_cflag_libs=${package##*=}
416 export ${group}_CFLAGS+=" ${package_cflag_libs%%\%*}"
417 export ${group}_LIBS+=" ${package_cflag_libs##*\%}"
419 if pkg-config --exists $package
421 export ${group}_CFLAGS+=" $(pkg-config --cflags $package)"
422 export ${group}_LIBS+=" $(pkg-config --libs $package)"
424 export ${group}_CFLAGS+=" "
425 export ${group}_LIBS+=" "
431 # @FUNCTION: gtk-sharp-tarball-post_src_prepare
433 # Runs a M-m-m-monster sed on GTK_SHARP_MODULE_DIR to convert references to
434 # local assemblies to the installed ones. Is only called by src_prepare when
435 # $GTK_SHARP_MODULE is a member of $gtk_sharp_module_list.
436 gtk-sharp-tarball-post_src_prepare() {
437 has "${EAPI:-0}" 2 && ! use prefix && EPREFIX=
438 cd "${S}/${GTK_SHARP_MODULE_DIR}"
440 -e "s; \$(srcdir)/../glib/glib-api.xml; $(get_sharp_apis --bare glib-sharp-2.0);" \
441 -e "s; ../pango/pango-api.xml; $(get_sharp_apis --bare pango-sharp-2.0);" \
442 -e "s; ../atk/atk-api.xml; $(get_sharp_apis --bare atk-sharp-2.0);" \
443 -e "s; ../gdk/gdk-api.xml; $(get_sharp_apis --bare gdk-sharp-2.0);" \
444 -e "s; ../gtk/gtk-api.xml; $(get_sharp_apis --bare gtk-sharp-2.0);" \
445 -e "s; \.\./glib/glib-sharp.dll; $(get_sharp_assemblies --bare glib-sharp-2.0);g" \
446 -e "s; \.\./pango/pango-sharp.dll; $(get_sharp_assemblies --bare pango-sharp-2.0);g" \
447 -e "s; \.\./atk/atk-sharp.dll; $(get_sharp_assemblies --bare atk-sharp-2.0);g" \
448 -e "s; \.\./gdk/gdk-sharp.dll; $(get_sharp_assemblies --bare gdk-sharp-2.0);g" \
449 -e "s; \.\./gtk/gtk-sharp.dll; $(get_sharp_assemblies --bare gtk-sharp-2.0);g" \
450 -e "s;\$(RUNTIME) \$(top_builddir)/parser/gapi-fixup.exe;${EPREFIX}/usr/bin/gapi2-fixup;" \
451 -e "s;\$(RUNTIME) \$(top_builddir)/generator/gapi_codegen.exe;${EPREFIX}/usr/bin/gapi2-codegen;" \
452 -e "s:\$(SYMBOLS) \$(top_builddir)/parser/gapi-fixup.exe:\$(SYMBOLS):" \
453 -e "s:\$(INCLUDE_API) \$(top_builddir)/generator/gapi_codegen.exe:\$(INCLUDE_API):" \
454 $(find . -name Makefile.in) || die "failed to fix ${TARBALL}-tarball makefiles"
457 # @FUNCTION: gnome-sharp-tarball-post_src_prepare
459 # Runs a M-m-m-monster sed on GTK_SHARP_MODULE_DIR to convert references to
460 # local assemblies to the installed ones. Is only called by src_prepare when
461 # $GTK_SHARP_MODULE is a member of $gnome_sharp_module_list.
462 gnome-sharp-tarball-post_src_prepare() {
463 cd "${S}/${GTK_SHARP_MODULE_DIR}"
465 -e "s; ../gnomevfs/gnome-vfs-api.xml; $(get_sharp_apis --bare gnome-vfs-sharp-2.0);" \
466 -e "s; ../art/art-api.xml; $(get_sharp_apis --bare art-sharp-2.0);" \
467 -e "s; \.\./art/art-sharp.dll; $(get_sharp_assemblies --bare art-sharp-2.0);g" \
468 -e "s; \.\./gnomevfs/gnome-vfs-sharp.dll; $(get_sharp_assemblies --bare gnome-vfs-sharp-2.0);g" \
469 -e "s;/r:\$(top_builddir)/art/art-sharp.dll;$(get_sharp_assemblies --prefixed art-sharp-2.0);" \
470 -e "s;/r:\$(top_builddir)/gnome/gnome-sharp.dll;$(get_sharp_assemblies --prefixed gnome-sharp-2.0);" \
471 $(find . -name Makefile.in) || die "failed to fix ${TARBALL}-tarball makefiles"
474 # @FUNCTION: gtk-sharp-module_src_prepare
476 # Runs autopatch from base.eclass, eautoreconf if EAUTORECONF is set to any
478 # Contains a phase_hook, runs very last.
479 # phase_hook prefix trigger: ${TARBALL}-tarball-post
481 gtk-sharp-module_src_prepare() {
483 # @ECLASS-VARIABLE: EAUTORECONF
485 # If set, EAUTORECONF will be run during src_prepare.
486 [[ ${EAUTORECONF} ]] && eautoreconf
487 phase_hook ${TARBALL}-tarball-post
491 # @FUNCTION: gtk-sharp-tarball_src_configure
493 # Sets some environment variables that will allow us to make the dependencies
494 # for each ebuild be only its own dependencies, without patching configure.
495 # Is only called by gtk-sharp-module_src_configure when $GTK_SHARP_MODULE
496 # is a member of $gtk_sharp_module_list.
497 gtk-sharp-tarball_src_configure() {
498 pkg_check_modules_override GLIB gobject-2.0
499 pkg_check_modules_override GIO gio-2.0
500 pkg_check_modules_override PANGO pango
501 pkg_check_modules_override ATK atk
502 pkg_check_modules_override GTK gtk+-2.0
503 pkg_check_modules_override GLADE libglade-2.0
506 # @FUNCTION: gnome-sharp-tarball_src_configure
508 # Sets some environment variables that will allow us to make the dependencies
509 # for each ebuild be only its own dependencies. Without patching configure.
510 # Is only called by gtk-sharp-module_src_configure when $GTK_SHARP_MODULE
511 # is a member of $gnome_sharp_module_list.
512 gnome-sharp-tarball_src_configure() {
513 has "${EAPI:-0}" 2 && ! use prefix && EPREFIX=
514 pkg_check_modules_override GLADESHARP glade-sharp-2.0
515 pkg_check_modules_override GAPI gapi-2.0
516 ac_path_prog_override GAPI_PARSER "${EPREFIX}"/usr/bin/gapi2-parser
517 ac_path_prog_override GAPI_CODEGEN "${EPREFIX}"/usr/bin/gapi2-codegen
518 ac_path_prog_override GAPI_FIXUP "${EPREFIX}"/usr/bin/gapi2-fixup
521 # @FUNCTION: gtk-sharp-module_src_configure
522 # @USAGE: [econf-arguments]
524 # Calls econf with some default values.
525 # Contains a phase_hook, run before econf.
526 # phase_hook prefix trigger: ${TARBALL}-tarball
528 gtk-sharp-module_src_configure() {
529 phase_hook ${TARBALL}-tarball
530 econf --disable-static \
531 --disable-dependency-tracking \
532 --disable-maintainer-mode \
533 $(use debug &&echo "--enable-debug" ) \
534 ${@} || die "econf failed"
537 # @FUNCTION: gtk-sharp-module_src_compile
539 # Calls emake in the subdir of the module.
540 # Sets CSC=/usr/bin/mcs. Deletes top_srcdir Makefiles to prevent recursing in
541 # case we missed some dll references.
543 gtk-sharp-module_src_compile() {
544 rm -f "${S}"/Makefile* &> /dev/null
545 cd "${S}/${GTK_SHARP_MODULE_DIR}"
546 emake CSC=/usr/bin/mcs || die "emake failed"
549 # @FUNCTION: gtk-sharp-module_src_install
551 # Installs the module. Fixes up lib paths so they're multilib-safe.
552 # Gets rid of .la files.
554 gtk-sharp-module_src_install() {
555 cd "${S}/${GTK_SHARP_MODULE_DIR}"
556 emake DESTDIR="${D}" install || die "emake install failed"
558 find "${D}" -type f -name '*.la' -exec rm -rf '{}' '+' || die "la removal failed"
559 [[ $(find "${D}" -type f|wc -l) -lt 3 ]] && die "Too few files. This smells like a failed install."
562 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install