.if exists(${.CURDIR}/obj)
MAN1=  ${.CURDIR}/obj/jcatman.1
EMAN1=  ${.CURDIR}/obj/jcatman.1.eng.gz
TARG=  ${.CURDIR}/obj/jcatman
.else
MAN1=  ${.CURDIR}/jcatman.1
EMAN1=  ${.CURDIR}/jcatman.1.eng.gz
TARG=  ${.CURDIR}/jcatman
.endif

MANDEPEND=	${MAN1}

CLEANFILES+=	${TARG} ${MAN1} ${EMAN1}

all:	${TARG} ${MAN1} ${EMAN1}

depend rcsfreeze tags all:
	@echo -n

${TARG}: ${.CURDIR}/catman.perl
	sed -e 's,#nroff#,${nroff},' \
	    -e 's,#zcat#,${zcat},' -e 's,#tbl#,${tbl},' \
	    -e 's,#compress#,${compress},' \
	${.CURDIR}/catman.perl > ${.TARGET}
	chmod 755 ${.TARGET}

${MAN1}: ${.CURDIR}/jcatman.man
	sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
	    -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
	    -e 's,%manpath_config_file%,${manpath_config_file},' \
		${.CURDIR}/jcatman.man > ${.TARGET}

${EMAN1}: ${.CURDIR}/jcatman.man.eng
	sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
	    -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
	    -e 's,%manpath_config_file%,${manpath_config_file},' \
		${.CURDIR}/jcatman.man.eng | \
	${compress} > ${.TARGET}

install: ${TARG} maninstall after_maninstall
	${INSTALL} -c -o bin -g bin -m 555 ${TARG} ${DESTDIR}${BINDIR}

.if !defined(NOMAN)
after_maninstall: ${EMAN1}
	${INSTALL} -c -o bin -g bin -m 444 ${EMAN1} \
	    ${DESTDIR}${EMANDIR}1/jcatman.1.gz
.else
after_maninstall:
.endif

.include "../Makefile.inc"

.if make(maninstall) || make(install)
.if !defined(NOMAN)
.include <bsd.man.mk>
.elif !target(maninstall)
maninstall:
.endif
.endif

.include <bsd.prog.mk>
