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

SRCS+=		hdaudio.pb.c
SRCS+=		hdaudio.c

CLEANFILES+=	hdaudio.pb.c
CLEANFILES+=	hdaudio.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+=	pinconfig.out
check-out: .PHONY pinconfig.out pinconfig.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...
hdaudio.d: hdaudio.pb.h
hdaudio.pb.c: hdaudio.proto
hdaudio.pb.d: hdaudio.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}
