# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id$

PortSystem      1.0
PortGroup       muniversal 1.0

name            orbit2
set my_name     ORBit2
version         2.14.19
revision        2
set branch      [join [lrange [split ${version} .] 0 1] .]
maintainers     nomaintainer
categories      devel gnome
# executables are GPL, libs are LGPL
license         {GPL-2+ LGPL-2+}
platforms       darwin
description     Code for an ORB written in C will spontaneously evolve here.

long_description \
    ${description}

homepage        http://www.gnome.org/projects/ORBit2/
master_sites    gnome:sources/${my_name}/${branch}/
distname        ${my_name}-${version}
use_bzip2       yes

checksums       md5     7082d317a9573ab338302243082d10d1 \
                sha1    e7c26aa4b82c146b3ec08d490e3469b4913e4e2f \
                rmd160  e16c1697efc4ad3dafca47828954f39438b4a8d4


depends_build   port:pkgconfig \
                port:gtk-doc

depends_lib     path:lib/pkgconfig/glib-2.0.pc:glib2 \
                port:libidl

patchfiles      patch-configure.diff \
                patch-linc2-src-Makefile.in.diff

# This file doesn't merge right for 3-way universal
set merger_dont_diff "${prefix}/include/orbit-2.0/orbit/orbit-config.h"

test.run        yes
test.target     check

if { [variant_isset universal] } {
    # Find architectures which will not run on build platform.
    if { ${os.arch} eq "i386" } {
        if { ${os.major} >= 10 } {
            set cross_archs "ppc ppc64"
        } else {
            set cross_archs "ppc64"
        }
        set host_archs "ppc ppc64"
    } else {
        set cross_archs "i386 x86_64"
        set host_archs "i386 x86_64"
    }
    
    set run_arch [lindex ${universal_archs} 0]
    if { [lsearch ${cross_archs} ${run_arch}] >= 0 } {
        ui_msg "When building a universal binary of ${name}, make sure none of {${cross_archs}} is first in universal_archs in ${prefix}/etc/macports/macports.conf"
        error "incompatible universal_archs value"
    }

    # During configure phase, idl compiler on run_arch will not exist yet, so disable the check for existence.
    # patchfiles-append   patch-configure.diff

    foreach arch ${cross_archs} {
        lappend merger_configure_args(${arch}) \
            --with-idl-compiler=${worksrcpath}-${run_arch}/src/idl-compiler/orbit-idl-2
    }

    if { ${os.arch} eq "i386" } {
        if { ${os.major} >= 10 } {
        lappend merger_configure_env(ppc)      \
            ac_cv_alignof_CORBA_boolean=1      \
            ac_cv_alignof_CORBA_char=1         \
            ac_cv_alignof_CORBA_double=4       \
            ac_cv_alignof_CORBA_float=4        \
            ac_cv_alignof_CORBA_long=4         \
            ac_cv_alignof_CORBA_long_double=4  \
            ac_cv_alignof_CORBA_long_long=4    \
            ac_cv_alignof_CORBA_octet=1        \
            ac_cv_alignof_CORBA_pointer=4      \
            ac_cv_alignof_CORBA_short=2        \
            ac_cv_alignof_CORBA_struct=1       \
            ac_cv_alignof_CORBA_wchar=2        \
            ac_cv_c_bigendian=yes
        }

        lappend merger_configure_env(ppc64)    \
            ac_cv_alignof_CORBA_boolean=1      \
            ac_cv_alignof_CORBA_char=1         \
            ac_cv_alignof_CORBA_double=8       \
            ac_cv_alignof_CORBA_float=4        \
            ac_cv_alignof_CORBA_long=4         \
            ac_cv_alignof_CORBA_long_double=8  \
            ac_cv_alignof_CORBA_long_long=8    \
            ac_cv_alignof_CORBA_octet=1        \
            ac_cv_alignof_CORBA_pointer=8      \
            ac_cv_alignof_CORBA_short=2        \
            ac_cv_alignof_CORBA_struct=1       \
            ac_cv_alignof_CORBA_wchar=2        \
            ac_cv_c_bigendian=yes

    } else {
        lappend merger_configure_env(i386)     \
            ac_cv_alignof_CORBA_boolean=1      \
            ac_cv_alignof_CORBA_char=1         \
            ac_cv_alignof_CORBA_double=4       \
            ac_cv_alignof_CORBA_float=4        \
            ac_cv_alignof_CORBA_long=4         \
            ac_cv_alignof_CORBA_long_double=4  \
            ac_cv_alignof_CORBA_long_long=4    \
            ac_cv_alignof_CORBA_octet=1        \
            ac_cv_alignof_CORBA_pointer=4      \
            ac_cv_alignof_CORBA_short=2        \
            ac_cv_alignof_CORBA_struct=1       \
            ac_cv_alignof_CORBA_wchar=2        \
            ac_cv_c_bigendian=no

        lappend merger_configure_env(x86_64)   \
            ac_cv_alignof_CORBA_boolean=1      \
            ac_cv_alignof_CORBA_char=1         \
            ac_cv_alignof_CORBA_double=8       \
            ac_cv_alignof_CORBA_float=4        \
            ac_cv_alignof_CORBA_long=4         \
            ac_cv_alignof_CORBA_long_double=8  \
            ac_cv_alignof_CORBA_long_long=8    \
            ac_cv_alignof_CORBA_octet=1        \
            ac_cv_alignof_CORBA_pointer=8      \
            ac_cv_alignof_CORBA_short=2        \
            ac_cv_alignof_CORBA_struct=1       \
            ac_cv_alignof_CORBA_wchar=2        \
            ac_cv_c_bigendian=no
    }
}

livecheck.type  gnome
livecheck.name  ${my_name}