# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 79733 2011-06-24 16:28:42Z jeremyhu@macports.org $

PortSystem          1.0

name                libnotify
version             0.5.2
revision            1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          devel gnome
maintainers         nomaintainer
description         pop-up notification library
long_description \
   The Desktop Notifications framework provides a standard way of doing \
   passive pop-up notifications.

platforms           darwin

homepage            http://library.gnome.org/devel/libnotify/
master_sites        gnome:sources/${name}/${branch}

use_bzip2           yes

checksums           sha1    bb088a318cfccb4261674065838860fa940fc04a \
                    rmd160  97c7d295683d6a093e46611d354fe8bfd799fb7d

variant quartz {
    patchfiles-append   patch-libnotify-notification-c.diff
}

# This port installs ${prefix}/lib/libnotify.dylib which gets
# picked up at link time instead of /usr/lib/system/libnotify.dylib
# leading to many build failures across MacPorts when it is installed.
#
# Because of this, we block installation in fetch and activate.
#
# ***DANGEROUS*** WORKAROUND
# There is a workaround for this issue which is recomended for *expert* users.
# Implementing this workaround and being lazy about it can (read: most likely
# *will*) result in a completely horked system after a software update.
#
# If do not follow this advise exactly, and your system becomes non-booting,
# shame on you for not listening to me.
#
# If you do follow this advise exactly, and your system becomes non-booting,
# shame on you for listening to me.
#
# Can I make this any clearer?  If you are inclinded to blame anyone *but*
# yourself if your system fails to boot, then DON'T DO THIS!
#
# You have been warned.
#
# It is your responsibility to verify the sanity of what you are about to do!
#
# PROCEED DO AT YOUR OWN PERIL
#
# UNDO THIS WORKAROUND BEFORE ANY APPLE SOFTWARE UPDATE!
#
# To work around this issue (make sure this is really necessary before doing it):
# sudo cp /usr/lib/system/libnotify.dylib /usr/lib/system/libsystem_notify.dylib
# sudo install_name_tool -id /usr/lib/system/libsystem_notify.dylib /usr/lib/system/libsystem_notify.dylib
# for f in /usr/lib/system/*dylib /usr/lib/libSystem.B.dylib ; do sudo install_name_tool -change /usr/lib/system/libnotify.dylib /usr/lib/system/libsystem_notify.dylib ${f} ; done
# sudo /usr/bin/update_dyld_shared_cache
# sudo reboot
# sudo mv /usr/lib/system/libnotify.dylib /usr/lib/system/libnotify.dylib.bak
#
# To undo:
# sudo mv /usr/lib/system/libnotify.dylib.bak /usr/lib/system/libnotify.dylib
# for f in /usr/lib/system/*dylib /usr/lib/libSystem.B.dylib ; do sudo install_name_tool -change /usr/lib/system/libsystem_notify.dylib /usr/lib/system/libnotify.dylib ${f} ; done
# sudo install_name_tool -id /usr/lib/system/libnotify.dylib /usr/lib/system/libnotify.dylib
# sudo /usr/bin/update_dyld_shared_cache
# sudo reboot
# sudo rm /usr/lib/system/libsystem_notify.dylib
#
platform darwin {
    if { [file exists /usr/lib/system/libnotify.dylib ] } {
        pre-fetch {
            ui_error "This port causes problems on Lion, so it will not be installed."
            return -code error "libnotify is not supported on Lion."
        }

        pre-activate {
            ui_error "This port causes problems on Lion, so it will not be installed."
            return -code error "libnotify is not supported on Lion."
        }
    }
}

depends_build       port:pkgconfig
depends_lib         port:gtk2 port:dbus-glib

livecheck.type      regex
livecheck.url       http://ftp.gnome.org/pub/GNOME/sources/${name}/${branch}/
livecheck.regex     ${name}-(\[0-9.\]+)\\.tar
