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

MLINKS= japropos.1 jwhatis.1

MANDEPEND=	${MAN1}

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

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

depend rcsfreeze tags all:
	@echo -n

${TARG}: ${.CURDIR}/apropos.sh
	sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
	    -e 's,%pager%,${pager},' \
		${.CURDIR}/apropos.sh > ${.TARGET}

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

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

install: ${TARG} maninstall after_maninstall
	${INSTALL} -c -o bin -g bin -m 555 ${TARG} ${DESTDIR}${BINDIR}
	ln -f ${DESTDIR}${BINDIR}/japropos ${DESTDIR}${BINDIR}/jwhatis

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