# -*- 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
# python-1.0.tcl
#
# $Id: python-1.0.tcl 28465 2007-08-31 22:59:48Z mww@macports.org $
#
# Copyright (c) 2008 Joshua Root <jmr at macports.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. Neither the name of Apple Computer, Inc. nor the names of its
#    contributors may be used to endorse or promote products derived from
#    this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

# arbitrary 'reasonable' defaults
set python.versions {python24 python25 python26}
set python.default_version python25

proc python.versions {versions} {
    global python.versions
    set python.versions $versions
}

proc python.default_version {version} {
    global python.default_version
    set python.default_version $version
}

categories      python
dist_subdir     python

use_configure   no

build.target    build

destroot.destdir    --prefix=${prefix} --root=${destroot}
pre-destroot    {
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}/examples
}

# select a default version if none set
foreach v ${python.versions} {
    if {[variant_isset $v]} {
        set python.version_chosen yes
    }
}
if {![info exists python.version_chosen]} {
    variant_set ${python.default_version}
}


foreach v ${python.versions} {
    variant $v {}
    if {[variant_isset $v]} {
        depends_lib-append      port:${v}
        set python.dotversion [string range $v 0 end-1].[string index $v end]
        
        set ${v}.bin  ${prefix}/bin/${python.dotversion}
        set ${v}.lib  ${prefix}/lib/lib${python.dotversion}.dylib
        set ${v}.libdir ${prefix}/lib/${python.dotversion}
        set ${v}.pkgd ${prefix}/lib/${python.dotversion}/site-packages
        set ${v}.include  ${prefix}/include/${python.dotversion}
    }
}

build {
    foreach v ${python.versions} {
        if {[variant_isset $v]} {
            copy ${worksrcpath} ${worksrcpath}-${v}
            set buildcmd [set ${v}.bin]
            system "cd ${worksrcpath}-${v} && ${buildcmd} setup.py ${build.target}"
        }
    }
}
destroot {
    foreach v ${python.versions} {
        if {[variant_isset $v]} {
            set destrootcmd [set ${v}.bin]
            system "cd ${worksrcpath}-${v} && ${destrootcmd} setup.py install ${destroot.destdir}"
        }
    }
}

