.if exists(${.CURDIR}/obj)
MAN1=  ${.CURDIR}/obj/jmakewhatis.1
EMAN1=  ${.CURDIR}/obj/jmakewhatis.1.eng.gz
MAN8=  ${.CURDIR}/obj/jmakewhatis.local.8
EMAN8=  ${.CURDIR}/obj/jmakewhatis.local.8.eng.gz
TARG=  ${.CURDIR}/obj/jmakewhatis
TARG2=  ${.CURDIR}/obj/jmakewhatis.local
.else
MAN1=  ${.CURDIR}/jmakewhatis.1
EMAN1=  ${.CURDIR}/jmakewhatis.1.eng.gz
MAN8=  ${.CURDIR}/jmakewhatis.local.8
EMAN8=  ${.CURDIR}/jmakewhatis.local.8.eng.gz
TARG=  ${.CURDIR}/jmakewhatis
TARG2=  ${.CURDIR}/jmakewhatis.local
.endif

MLINKS= jmakewhatis.local.8 jcatman.local.8

MANDEPEND=	${MAN1} ${MAN8}

CLEANFILES+=	${TARG} ${TARG2} ${MAN1} ${EMAN1} ${MAN8} ${EMAN8}

all:	${TARG} ${TARG2} ${MAN1} ${EMAN1} ${MAN8} ${EMAN8}

depend rcsfreeze tags all:
	@echo -n

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

${TARG2}: ${.CURDIR}/makewhatis.local.sh
	cp ${.CURDIR}/makewhatis.local.sh ${.TARGET}
	chmod 755 ${.TARGET}

${MAN1}: ${.CURDIR}/jmakewhatis.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}/jmakewhatis.man > ${.TARGET}

${EMAN1}: ${.CURDIR}/jmakewhatis.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}/jmakewhatis.man.eng | \
	${compress} > ${.TARGET}

${MAN8}: ${.CURDIR}/jmakewhatis.local.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}/jmakewhatis.local.man > ${.TARGET}

${EMAN8}: ${.CURDIR}/jmakewhatis.local.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}/jmakewhatis.local.man.eng | \
	${compress} > ${.TARGET}

install: ${TARG} ${TARG2} maninstall after_maninstall
	${INSTALL} -c -o bin -g bin -m 555 ${TARG} ${DESTDIR}${BINDIR}
	${INSTALL} -c -o bin -g bin -m 555 ${TARG2} ${DESTDIR}${libexecdir}
	ln -f ${DESTDIR}${libexecdir}/jmakewhatis.local \
	    ${DESTDIR}${libexecdir}/jcatman.local

.if !defined(NOMAN)
after_maninstall: ${EMAN1} ${EMAN8}
	${INSTALL} -c -o bin -g bin -m 444 ${EMAN1} \
	    ${DESTDIR}${EMANDIR}1/jmakewhatis.1.gz
	${INSTALL} -c -o bin -g bin -m 444 ${EMAN8} \
	    ${DESTDIR}${EMANDIR}8/jmakewhatis.local.8.gz
	ln -f ${DESTDIR}${EMANDIR}8/jmakewhatis.local.8.gz \
	    ${DESTDIR}${EMANDIR}8/jcatman.local.8.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>
