# -*- 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 85290 2011-10-12 10:40:22Z jmr@macports.org $

PortSystem			1.0
name				jam
version				2.5
# The version didn't change, but the binary did because it was upgraded from rc3 to 2.5.
revision			2
categories			devel
license				Permissive
maintainers			nomaintainer
description			a software build tool like make
long_description	Jam is a software build tool (like make) from Perforce. \
					It is very powerful tool and it is used for various \
					projects. It is particularly adapted for C/C++ \
					development, multiplatform projects or builds spread on \
					several processors. Mac OS X developer tools actually \
					include a customized version of it.
homepage			http://www.perforce.com/jam/jam.html
distfiles			${name}-${version}.tar
# avoid md5 mismatches.
dist_subdir			${name}/${version}
master_sites		ftp://ftp.perforce.com/jam/ \
					"http://public.perforce.com:8080/@md=d&cd=//public/jam/&ra=s&c=lAF@//public/jam/"
checksums			md5 c7eb7719d8523c0f819116479492d367 \
					sha1 421c1b308c3c3dc4c95c0640078416af2195d841 \
					rmd160 34497c89ca4bbd1db049627e2dfcc1287138af24
platforms			darwin

universal_variant   yes

# This is a .tar file.
extract.cmd			tar -xf 
extract.pre_args	
extract.post_args	

# Enables post-patch options & Matt Armstrong memory leak patch.
patchfiles			patch-Makefile.diff \
					patch-variable.c.diff

post-patch {
    # fix up reminder of Makefile, depending on variants
    set EXTRA ""
    set CFLAGS "-O3"
    if {[variant_isset debug]} {
        set CFLAGS "-O0"
        set EXTRA "-sDEBUG=1"
    } elseif {[variant_isset mw]} {
        set CFLAGS "-opt all"
        set EXTRA "-sCC=mwccppc"
    }
    reinplace "s|@CFLAGS@|${CFLAGS}|g" ${worksrcpath}/Makefile
    reinplace "s|@EXTRA@|${EXTRA}|g" ${worksrcpath}/Makefile

    # fix up Jamfile to always install to the same directory, no
    # matter if debug or regular build
    reinplace "s@/g@@g" ${worksrcpath}/Jamfile
}

# Jam doesn't have a configure script
use_configure no

pre-build {
    build.cmd-append \
        CC="${configure.cc}" \
        CFLAGS=\"[get_canonical_archflags]\"
}

# Installation.
destroot {
    # retrieve directory name where files are installed
    # (there is only 1 with the name "bin*")
    set bindir [exec find ${worksrcpath} -name "bin*"]

    # install binaries
    xinstall -d -m 755 ${destroot}${prefix}/bin
    xinstall -m 755 ${bindir}/jam ${destroot}${prefix}/bin
    xinstall -m 755 ${bindir}/mkjambase ${destroot}${prefix}/bin

    # install library
    xinstall -d -m 755 ${destroot}${prefix}/lib
    xinstall -m 644 ${bindir}/libjam.a ${destroot}${prefix}/lib

    # install documents
	xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
        Jam.html Jambase.html Jamfile.html README RELNOTES \
        ${destroot}${prefix}/share/doc/${name}
}

variant mw conflicts debug \
description {Use Metrowerks compiler} {}

variant debug conflicts mw \
description {Build with debug options but no optimization} {}

livecheck.type	md5
livecheck.url	ftp://ftp.perforce.com/jam/
livecheck.md5	37e6a5b6516a680c7178b72021d3b706
