PROGS	= tdump
DATAS	= lsvpd-functions.bash debug.bash

LIBS	= libvpd.a

TESTS	= test_growbuf test_growbuf.out

LIBOBJS	= growbuf.o util.o

AR	= ar cq
RANLIB	= ranlib

INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -m 644

all:		$(PROGS) $(LIBS)

tdump:		tdump.o util.o

tdump.o:	tdump.c util.h

libvpd.a:	$(LIBOBJS)
		$(RM) $@
		$(AR) $@ $(LIBOBJS)
		$(RANLIB) $@

growbuf.o:	growbuf.c growbuf.h

vpd_common.o:	vpd_common.c vpd_common.h

util.o:		util.c util.h

test_growbuf:	test_growbuf.o growbuf.o

test:		test_growbuf
		./test_growbuf < test_growbuf.c > test_growbuf.out
		diff -u test_growbuf.c test_growbuf.out

install:	all
	@ for f in $(PROGS) ; do \
		$(INSTALL_PROGRAM) $$f $(DESTDIR)$(libdir) ;\
	done
	@ for f in $(DATAS) ; do \
		$(INSTALL_DATA) $$f $(DESTDIR)$(libdir) ;\
	done

clean:
	rm -f $(PROGS) $(LIBS) $(TESTS) *.o *~
