# -*- 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
PortGroup           gitlab 1.0

gitlab.setup        fbb-git icmake 9.03.01
revision            1
categories          devel
license             GPL-3
maintainers         {larryv @larryv}

description         The Icmake program maintenance utility
long_description    Icmake is a hybrid between a 'make' utility and \
                    a 'shell script' language. Originally, it was \
                    written to provide a useful tool for automatic \
                    program maintenance and system administrative \
                    tasks on old MS-DOS platforms. (Not to be confused \
                    with Kitware's CMake build system.)
homepage            https://${gitlab.author}.gitlab.io/${gitlab.project}/

installs_libs       no

checksums           rmd160  3536565ea1662b0a7a43998c27968a87fdc98c0d \
                    sha256  1da9c8f34c1dce2d8fa083e37a322421a543a7b36a5d0707193799e7b77bd38a \
                    size    304992

worksrcdir          ${worksrcdir}/${name}

# $ git clone -b macports https://gitlab.com/larryv/icmake.git &&
#   git -C icmake format-patch -o "$(port dir icmake)"/files origin/master
patchfiles          0001-Use-strictly-compliant-POSIX-BREs-in-build.patch \
                    0002-Call-find-1-with-an-explicit-path-in-build.patch \
                    0003-Index-common-symbols-in-static-archives-in-Mac-build.patch \
                    0004-Correct-some-minor-documentation-errors.patch \
                    0005-Build-verbosely.patch \
                    0006-Use-MacPorts-install-locations.patch \
                    exit.patch
patch.pre_args-replace  -p0 -p2
post-patch {
    reinplace -W ${worksrcpath} s|__MACPORTS__|${prefix}|g \
            doc/icmake.1 \
            doc/icmbuild.1 \
            doc/icmconf.7 \
            doc/icmstart.1 \
            doc/icmstart.rc.7 \
            examples/am \
            examples/bup \
            examples/defines \
            examples/ds \
            examples/ftpxfer \
            examples/idir \
            examples/initialization \
            examples/killprog \
            examples/nesteddirectives \
            examples/r \
            examples/tolower
}

compiler.c_standard 1999

configure.cmd       ./icm_prepare
configure.pre_args  ${prefix}
# contains.c: error: ‘for’ loop initial declaration used outside C99 mode
configure.cflags-append \
                    -std=gnu99

build.env           CC=${configure.cc} \
                    "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"
build.cmd           ./icm_bootstrap
build.pre_args      x

destroot.cmd        ./icm_install
destroot.target     all
destroot.destdir    ${destroot}
