# Description: The GNU troff text-formatting system
# URL:         http://www.gnu.org/software/groff/groff.html
# Maintainer:  CRUX System Team, core-ports at crux dot nu

name=groff
version=1.22.3
release=2
source=(http://ftpmirror.gnu.org/gnu/$name/$name-$version.tar.gz)

build() {
    cd $name-$version

    # we install only the Base14 and EURO pdf fonts
    # and don't lookup for fonts in the filesystem
    # https://savannah.gnu.org/bugs/?38029
    sed -r -e '/^EURO\|/s/N/Y/' \
           -e '/^[A-Z]+\|N/d' \
           -e '/\(gs\)/d' \
           -i font/devpdf/Foundry.in
    
    ./configure --prefix=/usr \
                --without-x

    make -j1
    make DESTDIR=$PKG install

    sed -e 's|^\(papersize\).*|\1 /etc/papersize|' \
        -i $PKG/usr/share/groff/current/font/*/DESC
    
    install -d $PKG/etc
    echo 'letter' > $PKG/etc/papersize

    rm -rf $PKG/usr/share/{info,doc}

    ln -s eqn $PKG/usr/bin/geqn
    ln -s tbl $PKG/usr/bin/gtbl
    ln -s soelim $PKG/usr/bin/zsoelim
}
