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

name                sccs
version             5.09
categories          devel
license             CDDL
maintainers         {makr @mohd-akram} openmaintainer

conflicts           cssc

description         SCCS version control system

long_description    The UNIX Source Code Control System

homepage            https://sccs.sourceforge.net

master_sites        sourceforge
use_bzip2           yes

checksums           rmd160  707f0bac8377dfb1df0fd22727c3cb3b7df1f489 \
                    sha256  331bf09d1fb2ca01739e5f97cc46c6ef134661535f2ce541f90b5b9548be431b \
                    size    1114069

patchfiles          patch-rules-mklinks.diff \
                    patch-bdiff.diff patch-delta.diff patch-diff.diff \
                    patch-help.diff patch-sccs.diff

configure.cflags-append -std=c89
makefile.override   CFLAGS

build.args          INS_BASE=${prefix} INS_RBASE=${prefix} SCCS_BIN_PRE= \
                    SCCS_HELP_PRE=share/${name}/ GMAKE_NOWARN=true \
                    LDOPTX="${configure.ldflags}"

destroot.args       {*}${build.args}

post-destroot {
    delete ${destroot}${prefix}/ccs/bin/sccspatch
    ln -s spatch ${destroot}${prefix}/bin/sccspatch

    move -force {*}[glob ${destroot}${prefix}/xpg4/bin/*] ${destroot}${prefix}/bin

    xinstall -d ${destroot}${prefix}/libexec/${name}
    move ${destroot}${prefix}/bin/diff ${destroot}${prefix}/libexec/${name}

    delete ${destroot}${prefix}/share/man/man1/diff.1
    delete ${destroot}${prefix}/share/man/man1/patch.1
    delete {*}[glob ${destroot}${prefix}/include/*]
    delete {*}[glob ${destroot}${prefix}/lib/*]
    delete {*}[glob ${destroot}${prefix}/share/man/man3/*]

    reinplace "s|man4/sccschangeset.4|man5/sccschangeset.5|g" \
        ${destroot}${prefix}/share/man/man5/changeset.5
    reinplace "s|/usr/ccs/lib/|${prefix}/share/${name}/lib/|g" \
        ${destroot}${prefix}/share/man/man1/sccs-help.1
    reinplace -E "s|/usr(/ccs)?/bin/(\[a-z\])|\\2|g" \
        {*}[glob ${destroot}${prefix}/share/man/man1/*]
    reinplace "s|/usr/ccs/bin|${prefix}/bin|g" \
        ${destroot}${prefix}/share/man/man1/sccs.1
    reinplace "s|/usr/|${prefix}/|g" \
        {*}[glob ${destroot}${prefix}/share/man/man1/*] \
        {*}[glob ${destroot}${prefix}/share/man/man5/*]
}
