#
# |-----------------------------------------------------------|
# | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
# | All Rights Reserved                                       |
# |-----------------------------------------------------------|
# |          Restricted Rights Legend                         |
# | Use, duplication, or disclosure by the Government is      |
# | subject to restrictions as set forth in                   |
# | subparagraph (c)(1)(ii) of the Rights in Technical        |
# | Data and Computer Software Clause of DFARS 252.227-7013.  |
# |         MIPS Computer Systems, Inc.                       |
# |         950 DeGuigne Avenue                               |
# |         Sunnyvale, California 94088-3650, USA             |
# |-----------------------------------------------------------|
#
# $Header: Makefile,v 1.8.2.1 92/06/24 14:12:49 marker Exp $
#
# installation information:
#	OWNER	- name (or uid) for the installed executable's owner
#	GROUP	- group name (or gid) for the installed executable's group
#	MODE	- mode for the installed executable (should start with a 0)
#	MANDIR	- directory where the manual page should live
#	TROFF	- most appropriate troff command

SHELL=/bin/sh
DESTROOT =
OWNER  = bin
GROUP  = bin
MODE   = 555
CATDIR = /usr/share/man/catman/u_man/man1
MANDIR = /usr/share/man/u_man/man1
WHEREIGO = $(DESTROOT)/usr/new
DESTCATDIR = $(DESTROOT)$(CATDIR)
DESTMANDIR = $(DESTROOT)$(MANDIR)
TMACDIR =/usr/lib/tmac
TMACFILE=$(TMACDIR)/tmac.an
DESTTMACFILE=$(DESTROOT)$(TMACFILE)

NROFF	=cat $(DESTTMACFILE) - | tbl | nroff | col
TROFF	=cat $(DESTTMACFILE) - | tbl | troff -Ti10 | lpr -n

ETCDIR = /etc
INSTALL = $(ETCDIR)/mipsinstall
ISTRIP = -s
ICOPY = -c
INSTOPTS=$(ICOPY) $(ISTRIP) -m $(MODE) -o $(OWNER) -g $(GROUP)
MANINSTOPTS=$(ICOPY) -m 444 -o $(OWNER) -g bin

WHOAMI = ttcp

DESTROOT=

BASECFLAGS= -O1 -g -D_RISCOS -D_LANGUAGE_C $(ECFLAGS)

CFLAGS= -systype bsd43 $(BASECFLAGS)
LIBRARIES=

SVR3_CFLAGS= -systype sysv $(BASECFLAGS) -DSYSV -DTLI -I$(DESTROOT)/sysv/usr/include/bsd
SVR3_LIBRARIES=-lnsl -lbsd

CC_SVR4=$(CC)

SVR4_CFLAGS= -systype svr4 $(BASECFLAGS) -DSYSV -DTLI
SVR4_LIBRARIES=-lnsl

SVR4_SOCKETS_CFLAGS= -systype svr4 $(BASECFLAGS) -DSYSV
SVR4_SOCKETS_LIBRARIES=-lsocket -lnsl

SRCS= ttcp.c

OBJS= ttcp.o ttcp-svr3.o ttcp-svr4.o ttcp-svr4-sockets.o

TARGETS= ttcp ttcp-svr3 ttcp-svr4 ttcp-svr4-sockets

default: $(TARGETS)

all: $(TARGETS)

ttcp: ttcp.o
	${CC} ${CFLAGS} -o ttcp ttcp.o $(LIBRARIES)

ttcp-svr3.o: ttcp.c
	$(CC) $(SVR3_CFLAGS) -o ttcp-svr3.o -c ttcp.c 

ttcp-svr3: ttcp-svr3.o
	$(CC) $(SVR3_CFLAGS) -o ttcp-svr3 ttcp-svr3.o $(SVR3_LIBRARIES)

ttcp-svr4.o: ttcp.c
	$(CC_SVR4) $(SVR4_CFLAGS) -o ttcp-svr4.o -c ttcp.c 

ttcp-svr4: ttcp-svr4.o
	$(CC_SVR4) $(SVR4_CFLAGS) -o ttcp-svr4 ttcp-svr4.o $(SVR4_LIBRARIES)

ttcp-svr4-sockets.o: ttcp.c
	$(CC_SVR4) $(SVR4_SOCKETS_CFLAGS) -o ttcp-svr4-sockets.o -c ttcp.c 

ttcp-svr4-sockets: ttcp-svr4-sockets.o
	$(CC_SVR4) $(SVR4_SOCKETS_CFLAGS) -o ttcp-svr4-sockets ttcp-svr4-sockets.o \
			$(SVR4_SOCKETS_LIBRARIES)

clean:
	rm -f $(OBJS)

clobber: clean
	rm -f $(TARGETS) 
	rm -f ttcp.cat 

ttcp.cat: ttcp.1
	cat ttcp.1 | $(NROFF) >ttcp.cat

troff: ttcp.1
	cat ttcp.1 | $(TROFF) 

install: $(TARGETS) ttcp.1 ttcp.cat
	for whoami in $(TARGETS) ; \
	{ \
		$(INSTALL) $(INSTOPTS) $$whoami $(WHEREIGO) ; \
	}
	if [ -d $(DESTCATDIR)/. ] ; \
	then \
		$(INSTALL) $(MANINSTOPTS) -f ttcp.cat $(DESTCATDIR)/ttcp.1 ;\
	fi
	if [ -d $(DESTMANDIR)/. ] ; \
	then \
	    if [ ! -d $(DESTCATDIR)/. ] || \
	       [ `(cd $(DESTCATDIR) ; /bin/pwd )` != `(cd $(DESTMANDIR)/. ; /bin/pwd )` ] ; \
	    then \
		$(INSTALL) $(MANINSTOPTS) ttcp.1 $(DESTMANDIR) ;\
	    fi ; \
	fi
