#	This file is part of the magtape handling package MAG.
#	Written by Dick Grune, Vrije Universiteit, Amsterdam.
#

#	A system for handling magtapes, real or in tape image form.
#
#	make all:	make all the shell commands and run a superficial test
#	make install:	install all the shell commands
#	make libt:	install C-routine library
#	make NOS:	install NOSsplit et al. for reading Cyber tapes
#	make man:	install the manuals
#	make lint:	`lint' everything
#	make clean:	clean up the generated files
#

#	P A R A M E T E R S
USR =		/user1/dick

BIN =		$(USR)/bin#		# where to store the binaries
LIB =		$(USR)/lib#		# where to store libt.a
INC =		$(USR)/src#		# where to store tp.h for public use
MAN1 =		$(USR)/man#		# where to store manual pages(1)
MAN3 =		$(USR)/man#		# where to store manual pages(3)

CC =		cc#			# the C compiler to be used
CFLAGS =	-O -s#			# its flags
LINT =		lint#			# lint to be used, including flags

#	P U B L I C   E N T R I E S
PRG =		survey rawtp cptp ansir ansiw
NOS =		NOSsplit NOStr

all:		$(PRG) $(NOS) test.image
	./ansir -f test.image
	cmp READ_ME READ_ME.TEST
	rm READ_ME.TEST

install:	$(PRG)
	for F in $(PRG); do cp $$F $(BIN)/$$F; done

libt:		tp.h libt.a
	cp tp.h $(INC)/tp.h
	cp libt.a $(LIB)/libt.a

NOS:		$(NOS)
	for F in $(NOS); do cp $$F $(BIN)/$$F; done

#	M A N U A L S
MAN1_SRC =	ansir.1 ansiw.1 cptp.1 rawtp.1 survey.1 mag.1 \
		NOSsplit.1 NOStr.1
MAN3_SRC =	mag.3
MAN_SRC =	$(MAN1_SRC) $(MAN3_SRC)

man:
	for F in $(MAN1_SRC); do cp $$F $(MAN1)/$$F; done
	for F in $(MAN3_SRC); do cp $$F $(MAN3)/$$F; done

#	L I B R A R Y
LIB_OBJ =	tpread.o tpwrite.o tpopen.o tpclose.o tpname.o tperr.o \
		tploc.o tprdloc.o tpwloc.o tpwtmloc.o sys.o
LIB_SRC =	tpread.c tpwrite.c tpopen.c tpclose.c tpname.c tperr.c \
		tploc.c tprdloc.c tpwloc.c tpwtmloc.c sys.c
LIB_HDR =	aux.h tp.h tploc.h tpsys.h sys.h
LIB_AUX =	tpdummy.c llib-lmag.c

libt.a:		$(LIB_OBJ)
	ar cr libt.a $(LIB_OBJ)
	if /bin/test -f /usr/bin/ranlib ; then ranlib libt.a ; fi


#	P R O G R A M S
PRG_SRC =	ansi.c etoa.c ansir.c ansiw.c cptp.c rawtp.c survey.c \
		NOSsplit.c NOStr.c
PRG_HDR =	ansi.h etoa.h options.h

ansir:		ansir.o ansi.o etoa.o libt.a
	$(CC) $(CFLAGS) ansir.o ansi.o etoa.o libt.a -o ansir

ansiw:		ansiw.o ansi.o libt.a
	$(CC) $(CFLAGS) ansiw.o ansi.o libt.a -o ansiw

cptp:		cptp.o libt.a
	$(CC) $(CFLAGS) cptp.o libt.a -o cptp

rawtp:		rawtp.o libt.a
	$(CC) $(CFLAGS) rawtp.o libt.a -o rawtp

survey:		survey.o etoa.o libt.a
	$(CC) $(CFLAGS) survey.o etoa.o libt.a -o survey

NOSsplit:	NOSsplit.o libt.a
	$(CC) $(CFLAGS) NOSsplit.o libt.a -o NOSsplit

NOStr:		NOStr.o
	$(CC) $(CFLAGS) NOStr.o -o NOStr

#	S E R V I C E   E N T R I E S
lint:
	$(LINT) $(LIB_SRC) tpdummy.c
	$(LINT) tpdummy.c llib-lmag.c
	$(LINT) rawtp.c llib-lmag.c
	$(LINT) cptp.c llib-lmag.c
	$(LINT) ansir.c ansi.c llib-lmag.c
	$(LINT) ansiw.c ansi.c llib-lmag.c
	$(LINT) NOSsplit.c llib-lmag.c
	$(LINT) NOStr.c

Files:		Makefile
	ls Makefile READ_ME $(MAN_SRC) $(LIB_HDR) $(LIB_SRC) $(LIB_AUX) \
		$(PRG_HDR) $(PRG_SRC) >Files

shar:		shar1 shar2
SHAR1 =		READ_ME Makefile $(MAN_SRC) $(LIB_HDR) $(LIB_SRC) $(LIB_AUX)
SHAR2 =		$(PRG_HDR) $(PRG_SRC)

shar1:		Makefile $(SHAR1)
	shar $(SHAR1) >shar1

shar2:		Makefile $(SHAR2)
	shar $(SHAR2) >shar2

tags:		$(LIB_SRC) $(PRG_SRC)
	ctags $(LIB_SRC) $(PRG_SRC) >tags

test.image:	ansiw READ_ME
	cp READ_ME READ_ME.TEST
	./ansiw -f test.image READ_ME.TEST
	rm READ_ME.TEST

clean:
	rm -f *.o libt.a $(PRG) $(NOS) \
		test.image shar1 shar2 tags


#----------------------------------------------------------------
NOSsplit.o: aux.h options.h tp.h
NOStr.o: aux.h
ansi.o: ansi.h aux.h tp.h
ansir.o: ansi.h aux.h etoa.h options.h tp.h
ansiw.o: ansi.h aux.h options.h sys.h tp.h tploc.h
cptp.o: aux.h options.h tp.h
rawtp.o: aux.h options.h tp.h
survey.o: aux.h etoa.h options.h tp.h
sys.o: aux.h
tpclose.o: aux.h tp.h tpsys.h
tpdummy.o: options.h sys.h tp.h
tperr.o: aux.h tp.h tpsys.h
tploc.o: tploc.h
tpname.o: aux.h tp.h tpsys.h
tpopen.o: tp.h tpsys.h
tprdloc.o: tp.h tploc.h tpsys.h
tpread.o: tp.h tpsys.h
tpwloc.o: tp.h tploc.h tpsys.h
tpwrite.o: tp.h tpsys.h
tpwtmloc.o: aux.h tp.h tpsys.h
