PROG=		disk
SRCDIR=		${PICOPB_TOP}/test/disk

SRCS+=		disk.pb.c
SRCS+=		disk.c

CLEANFILES+=	disk.pb.c
CLEANFILES+=	disk.pb.h

CPPFLAGS+=	-I${SRCDIR}
CPPFLAGS+=	-I${.OBJDIR}
CPPFLAGS+=	-I${PICOPB_TOP}/lib/libpicopb
CPPFLAGS+=	-I${PICOPB_TOP}/lib/libpicopbprop

LDADD+=		${LIBPICOPB}
DPADD+=		${LIBPICOPB}

LDADD+=		${LIBPICOPBPROP}
DPADD+=		${LIBPICOPBPROP}

LDADD+=		-lprop

WARNS=		6

MKMAN=		no
MKLINT=		no

.include <bsd.prog.mk>

.PHONY: regress
regress: check-out

CLEANFILES+=	disk.out
check-out: .PHONY disk.out disk.out-good
	diff -u ${.ALLSRC}

.SUFFIXES: .out
.SUFFIXES: .pb.c
.SUFFIXES: .pb.h
.SUFFIXES: .plist
.SUFFIXES: .proto

# XXX Some explicit dependencies are necessary to get things moving...
disk.d: disk.pb.h
disk.pb.c: disk.proto
disk.pb.d: disk.pb.h

.proto.pb.c: ${PICOPBC}
	${PICOPBC} -c $@.tmp -H $*.pb.h $< && mv -f $@.tmp $@
.proto.pb.h: ${PICOPBC}
	${PICOPBC} -h $@.tmp -G $*.pb.h $< && mv -f $@.tmp $@

# XXX If ${PROG} is in ${.CURDIR} rather than in ${.OBJDIR}, this won't
# get the right pathname.  ${.ALLSRC} contains the right pathname, but
# it also contains the implied source, not just ${PROG}.  What to do?
# Actually, ${.ALLSRC} doesn't contain the right pathname: we need to
# use ./ if there is no separate objdir, since . won't be in $PATH.
# For now, we'll just assume nobody tries to build with a separate
# objdir and then run tests with no separate objdir, and work out the
# story with cross-compiling and running tests on the target later.
.plist.out: ${PROG}
	${.OBJDIR}/${PROG} -d $< > $@.tmp && mv -f $@.tmp $@

.PATH: ${SRCDIR}
