
#
# 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.4 (Berkeley) 9/5/85
#

OBJS=  \
	accept.o  \
	bind.o  \
	bsdpipe.o  \
	connect.o  \
	fchmod.o  \
	fchown.o  \
	getpeername.o  \
	getsockname.o  \
	getsockopt.o  \
	gettimeofday.o  \
	gtty.o  \
	listen.o  \
	readv.o  \
	recv.o  \
	recvfrom.o  \
	recvmsg.o  \
	select.o  \
	send.o  \
	sendmsg.o  \
	sendto.o  \
	setsockopt.o  \
	shutdown.o  \
	socket.o  \
	socketpair.o  \
	softnetint.o  \
	stty.o  \
	writev.o 

SRCS=  \
	accept.s  \
	bind.s  \
	bsdpipe.s  \
	connect.s  \
	fchmod.s  \
	fchown.s  \
	getpeername.s  \
	getsockname.s  \
	getsockopt.s  \
	gettimeofday.s  \
	gtty.s  \
	listen.s  \
	readv.s  \
	recv.s  \
	recvfrom.s  \
	recvmsg.s  \
	select.s  \
	send.s  \
	sendmsg.s  \
	sendto.s  \
	setsockopt.s  \
	shutdown.s  \
	socket.s  \
	socketpair.s  \
	softnetint.s  \
	stty.s  \
	writev.s 

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

.c.o: 
	${CC} ${CFLAGS} -c $*.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 errs a.out core hostlib hostlib_p profiled/*.o \
		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

# DO NOT DELETE THIS LINE -- make depend uses it
