#
#	Aviation navigation program
#	Makefile for Databases
#	Makefile [1.6] from /preflight/src/nav/SCCS/dbs/s.Makefile
#		Retrieved 16:27:48 88/07/07; latest mod 16:04:10 88/07/07
#
#	Alan M. Marcum		marcum@nescorna.Sun.COM
#	Robert J. Evans		pyramid!tolerant!procase!rje

.SUFFIXES:	.rdb .rdb~ .nav .record_length .nav.record_length~

SRCS	= padit.c

DBS		= airports.nav vors.nav airways.nav
DBS_SRCS	= airports.rdb vors.rdb airways.rdb
DBS_RECORD_LENGTHS	= airports.nav.record_length \
			  vors.nav.record_length \
			  airways.nav.record_length
DBS_DIRECTORY	= ./Databases

FILES		= Makefile $(SRCS) $(DBS_SRCS) $(DBS_RECORD_LENGTHS)
PRINTFILES	= $(FILES)

REL	=
GFLAGS	= $(REL)

CFLAGS	= -O

all:	databases

databases:	$(DBS)
	@echo "Databases current as of `date`" | tee $@

# The $$ in the following dependency delays interpretation of the
#  macro until the appropriate time.  This prevents the, um, interesting
#  possibility of vors.nav apparently requiring updating, for example,
#  when airways.nav.record_length changes.
#
# (In essence, the XYZ.nav databases depends on XYZ.rdb and on
#  XYZ.nav.record_length; MAKE gives no other good way to express
#  this sort of dependency.)

$(DBS):	$$@.record_length padit

SHAR:	nav.dbs.shar
	echo "Shell archive current as of `date`" >> $@

DBS_SHAR	= $(FILES)
nav.dbs.shar:	$(FILES)
	shar $@ $(FILES)

clean:
	-rm -f a.out padit core *.o *.BAK *.CKP $(DBS) ,*

cleanall:	clean
	-rm -f print databases SHAR nav.dbs.shar
	-sccs clean

print:	$(PRINTFILES)
	@echo Printing $?
	pr $? | lpr
	@echo `date` Printed $? >> print

printall: $(PRINTFILES)
	@echo Printing all
	pr $(PRINTFILES) | lpr
	@echo `date` Printed all >> print

.delta:
	-sccs delta `sccs tell -u` < $(RELBASE).com >> $(RELBASE).tmp
	sccs prs -d"Module: dbs/:M:	:I:	:D: :T:  :P:" -r SCCS >> \
		$(RELBASE).info

checkpoint:
	@echo -n "Enter SCCS comments: "
	@line > Make.CheckPoint.com
	$(MAKE) $(MFLAGS) .checkpoint SCCSCOMMENTS=Make.CheckPoint.com
	-rm Make.CheckPoint.com

.checkpoint:
	sccs tell -u > Make.CheckPoint.tmp
	-sccs deledit `cat Make.CheckPoint.tmp` < $(SCCSCOMMENTS)
	sleep 2
	-touch `cat Make.CheckPoint.tmp`
	-rm Make.CheckPoint.tmp

editall:
	sccs edit $(FILES) > /dev/null

getall:

.rdb~.rdb:
	$(GET) -G$*.rdb $(GFLAGS) $<

.rdb~.nav:
	$(GET) -G$*.rdb $(GFLAGS) $<
	sort $*.rdb | padit `cat $*.record_length` > $*.nav

.rdb.nav:
	sort $*.rdb | padit `cat $*.nav.record_length` > $*.nav

.nav.record_length~.nav.record_length:
	$(GET) -G$@ $(GFLAGS) $<

