PortSystem 1.0

name		larn
version     12
revision    3
categories	games
maintainers	nomaintainer
description	Text-based cavern exploring game
long_description    Larn is a text-based fantasy role-playing game similar to Rogue, \
            Nethack, etc.
homepage
platforms	darwin
use_bzip2	yes
master_sites	https://www.mirrorservice.org/sites/distfiles.finkmirrors.net/
distname            ${name}-4.6.2-RELEASE
checksums	md5 cea96f48caa057793f6bcaf3394ca388
build.type	bsd
build.args 	CC=${configure.cc}
build.env-append   "CFLAGS=-I${prefix}/include -I${prefix}/include/ncurses -Wno-implicit-function-declaration -Wno-return-type"

depends_lib-append	port:ncurses
		
worksrcdir	${name}
patchfiles	patch-diag.c \
            patch-display.c \
            patch-global.c \
            patch-header.h \
            patch-help.c \
            patch-io.c \
            patch-main.c \
            patch-monster.c \
            patch-moreobj.c \
            patch-movem.c \
            patch-object.c \
            patch-scores.c \
            patch-store.c
            
variant singleuser description {Disables system-wide scoreboards and allows local user installation without root privileges} {}

configure           {
						if {![variant_isset singleuser]} {
							 addgroup games
						}

                        reinplace "s|MAN|MAN6|" ${worksrcpath}/Makefile
                        reinplace "s|LDADD=	-ltermcap -lcompat|LDADD= -lncurses -L${prefix}/lib|" ${worksrcpath}/Makefile
                        
                        reinplace "s|/usr/share/games|${prefix}/share|g" ${worksrcpath}/pathnames.h
                        reinplace "s|/var/games|${prefix}/var/games|g" ${worksrcpath}/pathnames.h
                    }

destroot            {
						if {![variant_isset singleuser]} {
							xinstall -m 775 -g games -d ${destroot}${prefix}/var/games/larn
                        } else {
                        	xinstall -m 775 -d ${destroot}${prefix}/var/games/larn
                        }
                        
                        xinstall -m 755 -d ${destroot}${prefix}/share/larn
                        
						if {![variant_isset singleuser]} {
                        	xinstall -m 2755 -g games -c ${worksrcpath}/larn ${destroot}${prefix}/bin
                        } else {
                        	xinstall -m 755 -c ${worksrcpath}/larn ${destroot}${prefix}/bin
                        }                        
                        
                        xinstall -m 644 -c ${worksrcpath}/larn.6.gz ${destroot}${prefix}/share/man/man6
                        xinstall -m 644 -c ${worksrcpath}/datfiles/larn.help ${destroot}${prefix}/share/larn
                        xinstall -m 644 -c ${worksrcpath}/datfiles/larnmaze ${destroot}${prefix}/share/larn
                    }               

destroot.keepdirs   ${destroot}${prefix}/var/games/larn
