#
# Copyright (c) 1983 Regents of the University of California.
# All rights reserved.  The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
#	@(#)Makefile	5.13 (Berkeley) 3/18/86
#
SRCS=	getnetbyaddr.c getnetent.c getnetbyname.c \
	getproto.c getprotoent.c getprotoname.c \
	getservent.c gtservbyport.c gtservbyname.c \
	rcmd.c rexec.c ruserpass.c \
	res_comp.c res_debug.c res_init.c res_mkquery.c res_send.c res_query.c

OBJS=	getnetbyaddr.o getnetent.o getnetbyname.o \
	getproto.o getprotoent.o getprotoname.o \
	getservent.o gtservbyport.o gtservbyname.o \
	rcmd.o rexec.o ruserpass.o \
	res_comp.o res_debug.o res_init.o res_mkquery.o res_send.o res_query.o

CFLAGS=	-O ${DEFS} -I/bsd
TAGSFILE=tags

.c.o:
	${CC} -c ${CFLAGS} $*.c

../libbsd.a: ${OBJS}
	${AR} rv ../libbsd.a ${OBJS}
	rm -f ${OBJS}

tags:
	cwd=`pwd`; \
	for i in ${SRCS}; do \
		ctags -a -f ${TAGSFILE} $$cwd/$$i; \
	done

clean:
	rm -f *.o profiled/*.o errs a.out core netlib netlib_p \
		tags Makefile.bak

depend:
	for i in ${SRCS}; do \
	    cc -M ${CFLAGS} $$i | oawk ' { if ($$1 != prev) \
		{ if (rec != "") print rec; rec = $$0; prev = $$1; } \
		else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
		else rec = rec " " $$2 } } \
		END { print rec } ' >> makedep; done
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ed - Makefile < eddep
	rm eddep makedep
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	echo '# see make depend above' >> Makefile
