# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# $Id: Portfile 55651 2009-08-16 07:34:11Z krischik@macports.org $
# vim: set fileencoding=utf-8 tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab filetype=tcl :

PortSystem	    1.0

name		    sigil
version		    0.1.2
#epoch		    20090114
revision	    0
platforms	    darwin
categories	    editors
maintainers	    macports.org:krischik
description	    Sigil, the ePub editor
long_description					\
    Sigil is a multi-platform WYSIWYG ebook editor. It	\
    is designed to edit books in ePub format

homepage	    http://code.google.com/p/sigil
master_sites	    googlecode

distfiles	    Sigil_code_${version}.zip
worksrcdir	    Sigil_code_${version}

checksums           md5     5a51565fd12234b381eecabe728b5376 \
                    sha1    f9fd494558e477c3ab966bf5756c202ec4a4cf9e \
                    rmd160  274a7897c1d698b7ff8bcc4cad7349a5f018ba73

use_zip		    yes
use_parallel_build  yes

depends_build       bin:cmake:cmake \
		    bin:gmake:gmake
depends_lib	    port:qt4-mac

configure.env	    PATH="$env(PATH):${prefix}/libexec/qt4-mac/bin"
build.env	    PATH="$env(PATH):${prefix}/libexec/qt4-mac/bin"

platform x86_64 {
    pre-configure {
	reinplace "s|ppc;i386|x86_64|g" ${worksrcpath}/CMakeLists.txt
    }
}

platform powerpc {
    pre-configure {
	reinplace "s|ppc;i386|ppc|g" ${worksrcpath}/CMakeLists.txt
    }
}

platform i386 {
    pre-configure {
	reinplace "s|ppc;i386|i386|g" ${worksrcpath}/CMakeLists.txt
    }
}

configure {
    system "
	PATH=$env(PATH):${prefix}/libexec/qt4-mac/bin
	mkdir -p ${workpath}/build;
	pushd ${workpath}/build;
	    cmake -G \"Unix Makefiles\" ${workpath}/${worksrcdir};
	popd;
    "
}

build {
    system "
	PATH=$env(PATH):${prefix}/libexec/qt4-mac/bin
	pushd ${workpath}/build;
	    gmake Sigil;
	popd;
    "
}

destroot {
    xinstall -d ${destroot}${applications_dir}

    copy					\
	${workpath}/build/bin/Sigil.app		\
	${destroot}${applications_dir}
}

