#
#	Aviation navigation program
#	Makefile for Navigation Program
#	Makefile [1.8] from /preflight/src/nav/SCCS/src/s.Makefile
#		Retrieved 16:43:37 88/07/07; latest mod 16:42:29 88/07/07
#
#	amm	Alan M. Marcum		marcum@nescorna.Sun.COM
#	rje	Robert J. Evans		pyramid!tolerant!procase!rje

DEFINED	= -DBIN_SEARCH -DSysV -DSun -DBSD -DBSD4_3
UNDEFINED = -UApollo -UXenix386 -UDynix -UMSC
IFDEFS	= $(DEFINED) $(UNDEFINED)

# If floating point options are available, specify same here.
FLOAT =

# Set BIND to -Bstatic for static linking; comment out entirely
# if such options are unsupported
BIND = -Bdynamic

# Set the optimization level here
OPTIMIZE=-O

# When debugging, invoke with DEBUG=-g
# This is done, rather than using a separate target, to propogate the
# -g flag down through the implicit rules compiling each module.
DEBUG =

HDRS = ../hdr

CPPFLAGS = $(IFDEFS) -I$(HDRS)
CFLAGS	= $(OPTIMIZE) $(FLOAT) -I$(HDRS)
LDFLAGS	= -z $(BIND)

# Following LINTFLAGS are for BSD lint; swap comments for System V
LINTFLAGS = -abchux -DLINT $(IFDEFS) -I$(HDRS)

# Following is for System V
#LINTFLAGS = -u -DLINT $(IFDEFS)

LINT	= lint

CC = cc $(DEBUG)

# "-lnm" refers to a "new math" library.
#LDLIBS	= -lnm
LDLIBS	= -lm

SRCS	= vers.c main.c nav.c file.c scan.c output.c search.c usage.c \
	  getargs.c utils.c procargs.c globals.c output_utils.c \
	  getairports.c getnavaids.c getairways.c

DEFS	= $(HDRS)/Nav.h $(HDRS)/NavGlobals.h
ALL_DEFS	= $(DEFS) $(HDRS)/NavFormat.h $(HDRS)/NavVers.h
C_SOURCES	= $(SRCS) $(ALL_DEFS)
OBJS	= vers.o main.o nav.o file.o scan.o output.o search.o usage.o \
	  getargs.o utils.o procargs.o globals.o output_utils.c \
	  getairports.o getnavaids.o getairways.o

RELEASE_FILE	= ../release

TAGS	= tags tags.index

# If no cscope program, comment out the following
CSCOPE	= cscope.out

SHELL_SRCS	= nav_test.sh	nav_dbs.sh	shar.sh
SHELLS		= nav_test	nav_dbs		shar

FILES		= $(SRCS) $(SHELL_SRCS) Makefile
PRINTFILES	= $(FILES) tags.index ReleaseMap LatestRelease

REL	=
GFLAGS	= $(REL)

nav:	$(OBJS)
	cc -o $@ -I$(HDRS) $(OBJS) $(LDLIBS)

debug:	nav tags

$(OBJS):	$(DEFS)

vers.o:		$(HDRS)/NavVers.h

output.o output_utils.o:	$(DEFS) $(HDRS)/NavFormat.h

$(ALL_DEFS):
	(cd $(HDRS); $(MAKE) $(MFLAGS))

all:	All

All:	nav tags SHAR $(SHELLS)

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

nav.src.shar: $(FILES)
	if [ -r NavTest.A ]; then \
		shar $@ $(FILES) NavTest.?; \
	else \
		shar $@ $(FILES); \
	fi
	split $@ $@-

lint:	$(C_SOURCES)
	$(LINT) $(LINTFLAGS) $(SRCS)
	touch $@

Make-Baseline:	.TESTING
	nav_test -m

Baseline-Test:	.TESTING
	nav_test -b

Installed-Test:	Test

Test:	.TESTING
	nav_test

.TESTING:	nav nav_test

tags:	$(CSCOPE) $(C_SOURCES)
	ctags -t -w $(C_SOURCES)
	ctags -t -w -x $(C_SOURCES) $(ALL_DEFS) > tags.index

cscope.out:  $(C_SOURCES)
	-echo -n | cscope > /dev/null

tidy:
	-rm -f a.out core *.BAK *.CKP nav.src.shar* NavTest.DIFFS ,* SHAR

clean:
	-rm -f nav a.out core *.o *.BAK *.CKP $(SHELLS) NavTest.DIFFS ,*

cleanall:	clean
	-rm -f lint print SHAR $(TAGS) $(CSCOPE) nav.src.shar* NavTest.?
	-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: src/: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:

FORCE:
