############## Makefile for pcserver #########################
# This file is part of
# PCSERVER - a Transputer to Network interface
# Copyright (C) 1991 Dip. di Ingegneria dell'Informazione,
#                    Univ. di PISA
#
# version 0.40 - Luigi Rizzo (luigi@iet.unipi.it)
# 05-Jun-91 lr  last revision
# 30-May-91 sp mb lr
#   modified to be nmake/ultrix2/ultrix4 compatible
# 29-May-91 lr
#
### files:
#
# afproto.c	afserver protocol routines
# iolink.asm	DOS link handling (assembler)
# isproto.c	iserver protocol routines
# lbuffer.c	net-to-link buffer handling
# link.c	DOS link handling (C)
# nbuffer.c	link-to-net buffer handling
# main.c	main program
# net.c		ncsa net routines
# netdata.c	htons and similar routines
# rawproto.c	raw protocol routines
# unixnet.c	net files, for unix version (debug only)
# unixlink.c	link files, for unix version (debug only)
#
# fakeserv.c	afserver/iserver simulator
# fakelink.c	link simulator
# uxfilter.c	link monitor program

############## generic definitions ################
INCL=glob.h					# include files
GENSRC=main.c lbuffer.c nbuffer.c		# generic sources
PROTOSRC=afproto.c isproto.c rawproto.c		# protocols
IOSRC=net.c link.c netdata.c			# io functions

UXIOSRC=unixnet.c unixlink.c			# unix i/o
DEBUGSRC=fakelink.c fakeserv.c uxfilter.c	# test programs

OSRC=COPYING README iolink.asm Makefile pcserver.tex 	# other sources

############## objects definition #################
CSRC= $(GENSRC) $(IOSRC) $(PROTOSRC)		# MSDOS src
TSRC= $(GENSRC) $(UXIOSRC) $(PROTOSRC)		# Unix (test) src

SRC=$(INCL) $(GENSRC) $(PROTOSRC) $(IOSRC) $(UXIOSRC) $(DEBUGSRC) $(OSRC)

############## MSDOS definitions (nmake) ##################
DOSINCDIR=/ncsa/include
DOSCFLAGS=-DMSDOS -AL -I$(DOSINCDIR) -Gs -Ze -DREV_A_FIX
#DOSCFLAGS=-DMSDOS -AL -qc -I$(DOSINCDIR) -Gs -Ze -DREV_A_FIX -DDEBUG
#DOSCFLAGS=-DMSDOS -AL -qc -I$(DOSINCDIR) -Gs -Ze -DREV_A_FIX
DOSCC=cl
LIBS=common+nsnet+tcp+sess+enet
DOSOBJ=$(CSRC:.c=.obj)

############## Unix definitions ####################
UXINCDIR=/home/lr/ncsa.2.3b15/include
UXCFLAGS= -DDEBUG -DUNIX -I$(UXINCDIR)
UXCC=cc
#
# Ultrix 2.2 doesn't understand rewriting rules...
UXOBJS=main.o lbuffer.o nbuffer.o afproto.o isproto.o rawproto.o\
	unixnet.o unixlink.o
OBJS=$(UXOBJS)	# default, otherwise Ultrix2.2 complains

###### main targets ############

pcserver.exe : $(OBJS)
	link /ST:0x8000 main+lbuffer+nbuffer+afproto+isproto+rawproto+net+$(LINK)+netdata,pcserver,,$(LIBS);

uxserver: $(OBJS)
	$(CC) -o $@ $(OBJS)

iolink.obj:	iolink.asm Makefile
	masm iolink;

$(OBJS): $(INCL) Makefile


.c.obj:
	$(CC) -c $(CFLAGS) $*.c

.c.o:
	$(CC) -c $(CFLAGS) $*.c


########## these are only valid in unix ##########

fakelink: fakelink.c Makefile
	$(CC) -o $@ $@.c

fakeserv: fakeserv.c Makefile
	$(CC) -o $@ $@.c

pcs.tar.Z: $(SRC)
	- rm pcs.tar*
	tar cvf pcs.tar $(SRC)
	compress pcs.tar

clean:
	- rm core *.out pcserver uxserver fakelink fakeserv
	- rm *.o
	- rm *.log *.aux *.dvi

uxlint.out: $(TSRC)
	- rm uxlint.out
	lint $(TSRC) > uxlint.out

pclint.out: $(CSRC)
	- rm pclint.out
	lint -I$(UXINCDIR) $(CSRC) > pclint.out

# msdos version
msdos:
	nmake pcserver.exe "CFLAGS=$(DOSCFLAGS)" "OBJS= $(DOSOBJ)" "CC=$(DOSCC)" "LINK=link"

# this uses assembler link IO routines
fastdos:
	nmake pcserver.exe "CFLAGS=$(DOSCFLAGS) -DquickIO" "OBJS=$(DOSOBJ) iolink.obj" "CC=$(DOSCC)" "LINK=link+iolink"

#
# Unix version (debug only)
ultrix2:
	make uxserver "CFLAGS=$(UXCFLAGS)" \
	"OBJS= $(UXOBJS)" "CC=$(UXCC)"
sparc:
	make uxserver "CFLAGS=$(UXCFLAGS) -DNIS" \
	"OBJS= $(UXOBJS)" "CC=$(UXCC)"
######### end of Makefile for pcserver - unix version ######
