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

# Adapted from https://bitbucket.org/seanfarley/scienceports/src/de7cc636fbec/devel/codesearch/Portfile?at=default

PortSystem          1.0
PortGroup           github 1.0

github.setup        google codesearch a45d81b
version             20150717
# Epoch 1: Migration to github
epoch               1
revision            1
categories          devel
maintainers         nomaintainer
description         Indexed regular expression-based search
long_description \
    Code Search is a tool for indexing and then performing regular \
    expression searches over large bodies of source code. It is a \
    set of command-line programs written in Go

license             BSD

checksums \
    rmd160  f87db6cc7d131a25096c74434474ff924f34dca7 \
    sha256  9db1fa9f7f984cd9a03e593d32855ed76da56ac3525284894a70becd1467a54c

platforms           darwin

depends_lib         port:go

worksrcdir          src/github.com/google/codesearch

post-extract {
    xinstall -d ${workpath}/src/github.com/google
    move ${workpath}/${name}-${github.version} \
        ${worksrcpath}
}

use_configure       no
set progs           [list cgrep csearch cindex]

build {
    foreach prog ${progs} {
        system -W ${worksrcpath} \
          "GOPATH=${workpath} ${prefix}/bin/go build cmd/${prog}/${prog}.go"
    }
}

destroot {
    xinstall -W ${worksrcpath} {*}${progs} ${destroot}${prefix}/bin

    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/LICENSE \
        ${destroot}${prefix}/share/doc/${name}/
}