# -*- 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$

PortSystem          1.0

name                gpodder
version             2.20
revision            1
categories          gnome audio
license             GPL-3
maintainers         elelay
platforms           darwin
description         A media aggregator and podcast client

long_description    gPodder is a standalone podcast manager. \
                    It provides anything to manage feeds and podcasts \
                    but requires an external player to actually listen/view \
                    the content, e.g. Apple QuickTime Player.

homepage            http://gpodder.org
master_sites        http://gpodder.org/src/

checksums           md5     4c09c1e2c3a3c291b5d1e9d185b59655 \
                    sha1    21ae1255c63b69a8da2114d752ded07094097a8e \
                    rmd160  d9553e196d462d4210f46deebda41ccce68ff7a3


depends_build       port:help2man\
                    port:intltool

depends_lib         port:vorbis-tools\
                    port:lame

variant python25 conflicts python26 description {Use Python 2.5} {
    depends_lib-append  port:py25-feedparser\
                        port:py25-pil\
                        port:dbus-python25\
                        port:py25-mygpoclient \
                        port:py25-gtk

    post-patch {
        reinplace s|python|${prefix}/bin/python2.5|g ${worksrcpath}/Makefile
    }

    destroot.args PREFIX=${prefix}
}


set my_python "DUMMY_VALUE_WILL_BE_OVERWRITTEN"

variant python26 conflicts python25 description {Use Python 2.6} {
    depends_lib-append  port:py26-feedparser\
                        port:py26-pil\
                        port:dbus-python26\
                        port:py26-mygpoclient \
                        port:py26-gtk
    
    set my_python "${frameworks_dir}/Python.framework/Versions/2.6"

    post-patch {
        reinplace s|python|${my_python}/bin/python|g ${worksrcpath}/Makefile
    }
    
    # install in python 2.6 prefix, see bug #22522
    destroot.args PREFIX=${frameworks_dir}/Python.framework/Versions/2.6
    
    # Install the 2.6 apps in the standard path :
    # the 2 variants can't be active simultaneously.
    post-destroot {
    	foreach {app} {gpodder gpo gpodder-backup} {
    		ln -s ${my_python}/bin/${app} ${destroot}${prefix}/bin/${app}
        }
    }
}

variant python27 conflicts python26 conflicts python25 description {Use Python 2.7} {
    depends_lib-append  port:py27-feedparser\
                        port:py27-pil\
                        port:dbus-python27\
                        port:py27-mygpoclient \
                        port:py27-gtk

    set my_python "${frameworks_dir}/Python.framework/Versions/2.7"
    
    post-patch {
        reinplace s|python|${my_python}/bin/python|g ${worksrcpath}/Makefile
    }

    # install in python 2.7 prefix, see bug #22522
    destroot.args PREFIX=${frameworks_dir}/Python.framework/Versions/2.7

    # Install the 2.7 apps in the standard path :
    # the 2 variants can't be active simultaneously.
    post-destroot {
        foreach {app} {gpodder gpo gpodder-backup} {
            ln -s ${my_python}/bin/${app} ${destroot}${prefix}/bin/${app}
        }
    }
}

if {![variant_isset python25] && ![variant_isset python26] && ![variant_isset python27]} {
    default_variants +python27
}

variant quartz {
    depends_lib-append  port:gtk-osx-application
}

variant html_notes description {Use WebkitGtk+ to show episode notes in HTML format} {
	if {[variant_isset python25]} {
		depends_lib-append  port:py25-webkitgtk
	} elseif {[variant_isset python26]} {
		depends_lib-append  port:py26-webkitgtk
	} else {
		depends_lib-append  port:py27-webkitgtk
	}
}

use_configure       no

build {}

post-destroot {

    # build a MacOS X application
	if {[variant_isset python26] || [variant_isset python27]} {
		set install_path "${my_python}"
	} else {
		set install_path "${prefix}"
	}

	system "cd ${worksrcpath}/data/osx && make \
		GPODDERSCRIPT=\"${install_path}/bin/gpodder\"\
		APPLICATIONSDIR=\"${destroot}${applications_dir}\"\
		VERSION=\"${version}\"\
		OSXVERSION=\"${os.platform}${os.major}\" all"
}

# compatibility with gtk-osx-application >= 1.0.1
patchfiles-append   patch-src-gpodder-gui-py.diff

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "gpodder-(\\d+(?:\\.\\d+)*)${extract.suffix}"