# This is a highly cut down and modified version of the ftnchek Makefile
# for distribution with Sunsort. If you want to run ftnchek stand alone
# and you want the documentation, then contanct S.M.Singer@bham.ac.uk, or
# pull the latest version off the web.

# Copyright (c) 1998 by Robert K. Moniot.
# 
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# ROBERT K. MONIOT OR FORDHAM UNIVERSITY BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# 
# Except as contained in this notice, the name of ftnchek shall not be used
# in advertising or otherwise to promote the sale, use or other dealings in
# this Software without prior written authorization from the author.
# 
#
# Acknowledgements and thanks to Nelson H. F. Beebe of the University
# of Utah for improvements to this Makefile.
# [25-Apr-1994]
#=======================================================================

YACC            = bison -y

# OPTIONS is used to define various characteristics.  Most commonly
# needed ones are given below; uncomment whichever you like.
# See ftnchek.h for others, with their defaults and explanations.
# OPTIONS shouldn't include things controlled by "configure".
# To include your own options without touching the Makefile, say
#              make "OPTIONS= <your-list-of-options>"

# If you want -f77=all to be the default, uncomment this.
#OPTIONS        = -DSTRICT_SYNTAX


# CFLAGS is used to define the operating system and options
# LDFLAGS gives linker options
# YFLAGS specifies yacc options
CFLAGS          = -DUNIX -Xc $(OPTFLAG)  $(OPTIONS)
LDFLAGS         = 
YFLAGS          = -d

# fortran.o first because of possible remake if tokdefs.h changes (see below)
OBJS            = fortran.o exprtype.o forlex.o ftnchek.o \
		  pgsymtab.o plsymtab.o project.o symtab.o

#=======================================================================

lint:
	lint $(LINTFLAGS) $(OBJS:.o=.c) -lm

# Remove intermediate files that are not required after the program is
# built.
clean:
	-rm -f *.o \#* a.out *[~%] core y.tab.h

ftnchek: $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o ftnchek $(OBJS) -lm

# N.B. tokdefs.h is copy of y.tab.h used to avoid remaking stuff when
# grammar changes but not tokens.
# The following copies y.tab.h to tokdefs.h if changed, then aborts make,
# since dependencies may have changed.
fortran.c: fortran.y
	$(YACC) $(YFLAGS) fortran.y
	mv y.tab.c fortran.c
	@if cmp -s y.tab.h tokdefs.h ; then true ; else \
		echo; echo tokdefs.h changed -- repeat make ; \
		cp y.tab.h tokdefs.h; \
		false ; \
	fi

install:	ftnchek
	mv ftnchek ..
	-strip ../ftnchek

uninstall:
	-rm ../ftnchek


#=======================================================================
# Object file dependencies on include files

ftnchek.o:	config.h ftnchek.h

exprtype.o:	config.h ftnchek.h symtab.h tokdefs.h

forlex.o:	config.h ftnchek.h keywords.h symtab.h tokdefs.h

fortran.o:	config.h ftnchek.h symtab.h fortran.c

pgsymtab.o:	config.h ftnchek.h symtab.h

plsymtab.o:	config.h ftnchek.h symtab.h

project.o:	config.h ftnchek.h symtab.h

symtab.o:	config.h ftnchek.h iokeywds.h intrins.h symtab.h tokdefs.h
