PROG=	jmanpath
SRCS=	manpath.c

.if exists(${.OBJDIR}/../lib)
LIBDESTDIR=	${.OBJDIR}/../lib
.else
LIBDESTDIR=	${.CURDIR}/../lib
.endif
DPADD=	${LIBMAN}
LDADD=	${LIBMAN}

.if exists(${.OBJDIR})
MAN1=	${.OBJDIR}/jmanpath.1
EMAN1=	${.OBJDIR}/jmanpath.1.eng.gz
.else
MAN1=	${.CURDIR}/jmanpath.1
EMAN1=	${.CURDIR}/jmanpath.1.eng.gz
.endif

CFLAGS+= -DMAIN -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS
CFLAGS+= -DALT_SYSTEMS -I${.CURDIR}/../lib -I${.OBJDIR}/../lib
CLEANFILES+=	${MAN1} ${EMAN1}
MANDEPEND+=	${MAN1}

${MAN1}: ${.CURDIR}/jmanpath.man
	@${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \
	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}/jmanpath.man > ${MAN1}

${EMAN1}: ${.CURDIR}/jmanpath.man.eng
	@${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \
	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}/jmanpath.man.eng | \
	${compress} > ${EMAN1}

.if !defined(NOMAN)
afterinstall: ${EMAN1}
	${INSTALL} -c -o bin -g bin -m 444 ${EMAN1} \
	    ${DESTDIR}${EMANDIR}1/jmanpath.1.gz
	${INSTALL} -c -o bin -g bin -m 644 ${.CURDIR}/manpath.config \
	    ${PREFIX}${manpath_config_file}.sample
.else
afterinstall:
	${INSTALL} -c -o bin -g bin -m 644 ${.CURDIR}/manpath.config \
	    ${PREFIX}${manpath_config_file}.sample
.endif

.include "../Makefile.inc"

.include <bsd.prog.mk>
