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

PortSystem          1.0

name                osxbom
categories          sysutils
maintainers         {gwmail.gwu.edu:egall @cooljeanius} openmaintainer
platforms           darwin
license             public-domain

description         A free re-implementation of the NextSTEP/OSX lsbom \
                    utility
long_description    ${description}. Used by the PureDarwin project \
                    to work with MacPorts binary packages.
homepage            https://cauldrondevelopment.com/svn/${name}/trunk/

livecheck.type      none

fetch.type          svn
svn.url             ${homepage}
svn.revision        3
# Get the version number by applying semantic versioning principles
# to the svn revision: http://semver.org/
version             0.0.${svn.revision}

worksrcdir          trunk

use_configure       no

set CFLAGS         "${configure.cflags} [get_canonical_archflags cc]"

build.env-append    CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    CPP=${configure.cpp}

pre-build {
    reinplace "s|-Werror|${CFLAGS}|" ${worksrcpath}/Makefile
}

destroot {
        xinstall ${worksrcpath}/lsbom ${destroot}${prefix}/bin
        xinstall ${worksrcpath}/bom.h ${destroot}${prefix}/include
}

variant rename description {Stop osxbom from shadowing the system lsbom} {
    destroot {
        xinstall ${worksrcpath}/lsbom ${destroot}${prefix}/bin/${name}
        xinstall -d ${destroot}${prefix}/include/${name}
        xinstall ${worksrcpath}/bom.h ${destroot}${prefix}/include/${name}
    }
}

default_variants    +rename

variant egallager description {Use my GitHub fork for the source} {
    PortGroup                github 1.0

    # My repo is ahead of the main one in terms of versions:
    github.setup             cooljeanius ${name} 0.0.6
    #FIXME: just fetch from the tag instead of doing this:
    fetch.type               git
    git.url                  git://github.com/cooljeanius/${name}.git
    # probably not actually necessary to autoreconf, but whatever:
    use_autoreconf           yes
    autoreconf.args          -fvi -Wall
    # override the previous setting:
    use_configure            yes
    # for trace mode:
    depends_build-append     port:gawk \
                             port:grep
}

variant universal {}
