#	from: @(#)Makefile	5.6 (Berkeley) 9/27/90
#	$Id: Makefile,v 1.12 1996/09/12 08:12:46 sjg Exp $

PROG=	SSLrdist
NOMAN=no

SRCS= gram.y rdist.c client.c child.c docmd.c  distopt.c expand.c \
	lookup.c  isexec.c signal.c rshrcmd.c  common.c message.c setargs.c   

RDISTSRC?=${.CURDIR}/src
.PATH:	${RDISTSRC}/src

CFLAGS+= -U_ANSI_SOURCE 
CFLAGS+=  -I${RDISTSRC}/include -I${RDISTSRC}/config
.if ${MACHINE} == "i386" || ${MACHINE} == "sparc"
CFLAGS+= -DOS_H=\"os-netbsd1.h\"
LDADD+= -L/usr/lib -lcompat
.elif ${MACHINE} == "sun386i"
CFLAGS+= -DOS_H=\"os-sunos4.h\"
.else
CFLAGS+= -DOS_H=\"os-`${RDISTSRC}/config/os-type`.h\"
.endif
.if ${MACHINE} == "HP-UX.9000"
SRCS+= regex.c
.endif

.include <bsd.prog.mk>

BINDIR=/usr/local/bin
CFLAGS+= -D_PATH_RDISTD=\"${BINDIR}/rdistd\" -Dread=read_net -Dwrite=write_net

.if !exists(${.CURDIR}/rdist.c)
rdist.o:	${.CURDIR}/rdist.c
rshrcmd.o:	${.CURDIR}/rshrcmd.c
${.CURDIR}/rdist.c:	${RDISTSRC}/src/rdist.c 
	cd ${RDISTSRC}/src; cp rdist.c rshrcmd.c ${.CURDIR}
	cd ${.CURDIR} && patch < ${.CURDIR}/rdist.patch
.endif

test:
	@mkdir -p /tmp/source /tmp/dest
	@cp ${.CURDIR}/distfile /tmp/source
	@rm -f /tmp/dest/distfile
	./SSLrdist -p ${.CURDIR}/../rdistd/obj.${MACHINE}/rdistd -f ${.CURDIR}/distfile test
	@cmp /tmp/source/distfile /tmp/dest/distfile
