1#=======================================================================
2# $Id: Makefile.in,v 1.76 2004/11/14 15:52:12 moniot Exp $
3#
4# UNIX version of Makefile for Fortran program checker ftnchek
5#
6# User target list:
7#	all			build ftnchek and its man page
8#	blurb.txt		brief descriptive document about ftnchek
9#	check			run validation test suite
10#	clean			remove unnecessary intermediate files
11#	clobber			make clean, and remove ftnchek executable
12#	dcl2inc.doc		plain text form of documentation
13#	dcl2inc.ps		PostScript form of documentation
14#	distclean		remove everything not in the distribution
15#	docs			documentation files
16#	fortran.c		translates yacc code to C (made from fortran.y)
17#	ftnchek			ftnchek executable program
18#	ftnchek.1		UNIX manual page (made from fortran.man)
19#	ftnchek.doc		plain text form of documentation
20#	ftnchek.hlp		VMS HELP library source
21#	ftnchek.ps		PostScript form of documentation
22#	htmlclean		remove unneeded files from html directory
23#	htmldocs		hypertext form of documentation
24#	install			install ftnchek and dcl2inc and their man pages
25#	install-exe		install ftnchek and dcl2inc executables
26#	install-lisp		install emacs ftnchek-mode lisp file
27#	install-man		install man pages on most UNIX systems
28#	install-man-sgi		install man pages on SGI systems
29#	manpage			same as ftnchek.1
30#	mostlyclean		same as clean
31#	prog			same as ftnchek
32#	realclean		same as clobber
33#	uninstall		remove everything "make install" installs
34#
35# Developer target list:
36#	catman			create "cat" format manpages
37#	catman.tar		create "cat" format manpage tar file
38#	devel			build development version (extra debugging).
39#	lint			run lint on source code
40#	generic-config		create generic config.h etc for distribution
41#	maintainer-clean	distclean, then things maintainer can rebuild
42#	pretar			get ready to make distribution tar file
43#	spotless		distclean, then remove ps, html and text docs
44#	TAGS			emacs editor tags file
45#	tags			ex and vi editor tags file
46#	tar			distribution tar file
47#	testclean		remove unnecessary files from test directory
48#	zip			distribution zip file for MS-DOS
49#
50# Not a target, made by configure:
51#	dcl2inc			Shell script to convert decls to includes
52#
53# Object file targets		see list of objects at OBJS
54#
55#
56#
57# Copyright (c) 2001 by Robert K. Moniot.
58#
59# Permission is hereby granted, free of charge, to any person
60# obtaining a copy of this software and associated documentation
61# files (the "Software"), to deal in the Software without
62# restriction, including without limitation the rights to use,
63# copy, modify, merge, publish, distribute, sublicense, and/or
64# sell copies of the Software, and to permit persons to whom the
65# Software is furnished to do so, subject to the following
66# conditions:
67#
68# The above copyright notice and this permission notice shall be
69# included in all copies or substantial portions of the
70# Software.
71#
72# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
73# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
74# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
75# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
76# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
77# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
78# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
79# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
80#
81# Acknowledgement: the above permission notice is what is known
82# as the "MIT License."
83#
84#
85# Acknowledgements and thanks to Nelson H. F. Beebe of the University
86# of Utah for improvements to this Makefile.
87# [25-Apr-1994]
88#=======================================================================
89
90# These definitions should be customized for your local conventions
91# if you want to do "make install" or "make uninstall".
92#  prefix is the root of the destination for installing things.
93#  bindir is directory for executables, mandir for man pages.
94#  manext is the extension on man pages, including the dot.
95#  libdir is the directory for library files (dcl2inc.awk).  It must
96#    agree with the libdir defined in dcl2inc as made by configure.
97#  lispdir is where to put ftnchek.el.
98
99prefix		= /usr/local
100exec_prefix	= ${prefix}
101bindir		= ${exec_prefix}/bin
102datadir		= ${prefix}/share
103mandir		= ${prefix}/man
104manext		= .1
105sgimansubdir	= /manl
106libdir		= ${exec_prefix}/lib/ftnchek
107lispdir		= ${datadir}/emacs/site-lisp
108
109# Define suffix for executables, for non-unix systems which have one.
110EXE		=
111#EXE		= .exe
112
113# Define suffix for scripts, to go on the end of dcl2inc script.
114CMD		=
115#CMD		= .cmd
116#CMD		= .bat
117
118# The following definitions are set for your system by configure.
119# In non-generic Makefile these should all be path-qualified except
120# for *_NAME.  If path is missing then configure didn't find it.
121# AWK is any awk; NAWK is the enhanced awk needed by dcl2inc.
122# AWK_NAME and YACC_NAME have the pathless names to simplify tests where the
123# particular flavor of the utility matters.  NROFF is the nroff program,
124# NROFFPLAIN has flags to suppress escape sequences.  PWD_PROG is so named
125# to avoid collision with shell variable PWD.  ZIPTEXT is zip program
126# with flag for Unix->DOS line-end conversion, ZIP is default mode.
127AWK		= gawk
128AWK_NAME	= gawk
129CC              = cc
130CHMOD		= chmod
131CMP		= cmp
132CP		= cp
133DIFF		= diff
134EMACS		= emacs
135EQN		= eqn
136GREP		= grep
137LINT		= lint
138MANtoHTML	= man2html
139MANtoPS		= ./man2ps
140MKDIR		= mkdir
141MV		= mv
142NAWK		= gawk
143NROFF		= nroff
144NROFFPLAIN	= nroff -c
145PATCH		= patch
146PWD_PROG	= pwd
147RM		= rm -f
148RMDIR		= rmdir
149SED		= sed
150SHELL		= sh
151SOELIM		= soelim
152STRIP           = strip
153TAR		= tar
154TBL		= tbl
155YACC            = bison
156YACC_NAME	= bison
157ZIP		= zip
158ZIPTEXT		= $(ZIP) -l
159
160# The following is only used for targets ftnchek.doc and ftnchek.hlp
161# which are not needed for unix platforms.  It removes control chars
162# and converts tabs to blanks.  Normally COL=col -bx but if you don't
163# have it, can make do with cat.
164COL		= col -bx
165
166# Editor tags file support
167CTAGS		= ctags
168CTAGSFLAGS	= -t
169ETAGS		= etags
170
171# The following suffixes are for making various forms of documentation
172.SUFFIXES: .cat .catman .doc .man .ps .i
173
174
175# Pack is needed only for install-man-sgi target
176PACK		= pack
177
178FTNCHEK		= ./ftnchek$(EXE)
179
180# OPTIONS is used to define various characteristics.  Most commonly
181# needed ones are given below; uncomment whichever you like.
182# See ftnchek.h for others, with their defaults and explanations.
183# OPTIONS shouldn't include things controlled by "configure".
184# To include your own options without touching the Makefile, say
185#              make "OPTIONS= <your-list-of-options>"
186
187# If you want -f77=all to be the default, uncomment this.
188#OPTIONS        = -DSTRICT_SYNTAX
189
190# OPT is optimization level
191# CFLAGS is used to define the operating system and options
192# LDLIBS gives any system-specific libraries for linker
193# LDFLAGS gives linker options
194# YFLAGS specifies yacc options
195OPT		= -O
196CFLAGS          = -DUNIX -O $(OPTIONS) $(DEBUG_FLAGS) $(DEVEL_CFLAGS)
197LDLIBS          =
198LDFLAGS         =  $(DEBUG_FLAGS) $(DEVEL_LDFLAGS)
199YFLAGS          = -y -d
200
201# fortran.o first because of possible remake if tokdefs.h changes (see below)
202OBJS            = fortran.o advance.o argcheck.o calltree.o comcheck.o exprtype.o \
203		  forlex.o ftnchek.o include.o intake.o intrins.o \
204		  iokeywds.o keywords.o labels.o \
205		  loccheck.o makedcls.o makehtml.o message.o options.o pgsymtab.o \
206		  plsymtab.o prlists.o prlocsym.o project.o \
207		  symspace.o symtab.o symutils.o utils.o
208
209DOCS		= README INSTALL LICENSE PATCHES FAQ ToDo project.magic \
210			average.f average.out correct.f \
211			blurb.txt dcl2inc.doc dcl2inc.man dcl2inc.ps \
212			ftnchek.doc ftnchek.hlp ftnchek.man ftnchek.ps html \
213			macro-doc.txt project-doc.tex \
214			$$dirname.lsm
215#		 the above expands to ftnchek-x.y.z.lsm in make tar
216
217UNIX_BUILDFILES	= Makefile.in configure configure.in config.guess config.sub \
218			config.h.in configure.generic install-sh \
219			add_html_refs.sh make_html.sh \
220			make_blockmatch.pl make_blockmatch.pl.in
221
222VMS_BUILDFILES	= build.com build-vax.com cc.com link.com check.com
223
224OS2_BUILDFILES	= ftnchek.def configure_os2.cmd
225
226OTHER_BUILDFILES= makefile.bcc32 \
227			makefile.generic makefile.mpw \
228			ftnchek.dsp ftnchek.dsw
229
230BUILDFILES	= $(UNIX_BUILDFILES) $(VMS_BUILDFILES) $(OS2_BUILDFILES) \
231			$(OTHER_BUILDFILES)
232
233SRCS            = advance.c advance.h argcheck.c block_match.h \
234		  calltree.c comcheck.c config-generic.h config-win32.h exprtype.c \
235		  forlex.c forlex.h fortran.y fortran.c ftnchek.c ftnchek.h \
236		  include.c intake.c intrins.c intrins.h iokeywds.h \
237		  iokeywds_enum.h iokeywds.c \
238		  keywords.c labels.c \
239		  loccheck.c loccheck.h makedcls.c makehtml.c message.c options.c \
240		  options.h pgsymtab.c pgsymtab.h plsymtab.c plsymtab.h \
241		  prlists.c prlocsym.c project.c symspace.c \
242		  symspace.h symtab.c symtab.h symutils.c symutils.h tokdefs.h \
243			utils.h utils.c
244SCRIPTS		= dcl2inc dcl2inc.in dcl2inc.awk dcl2inc.awk.in \
245		  man2ps ftnchek.el
246TESTDIR		= test
247HTMLDIR		= html
248# The following defines all files to go into distribution tar file
249DISTFILES	= $(DOCS) $(BUILDFILES) $(SRCS) $(SCRIPTS) $(TESTDIR)
250# The following defines all files to go into MS-DOS distribution zip file.
251# BINARY_ZIPFILES are those that should not undergo the LF->CR-LF replacement.
252ZIPFILES	= $(DISTFILES)
253BINARY_ZIPFILES= configure_os2.cmd test/*.bat test/cmp.exe
254
255# The following defines all files that go into the auxiliary catman tar file
256CATMAN		= dcl2inc.catman ftnchek.catman
257
258# Files in the following list are created by the configure script.
259# Generic versions for the distribution are made by the generic-config
260# target.
261CONFIGURED_FILES = makefile.generic dcl2inc.awk dcl2inc make_blockmatch.pl \
262			test/Makefile test/Compare.sh config-generic.h
263#=======================================================================
264#  Rule to run source thru preprocessor only; useful for tracing down
265#  compilation problems.  Blank lines are removed for convenient viewing.
266.c.i:
267	$(CC) -E -I. $(DEFS) $(CPPFLAGS) $(CFLAGS) $< 2>&1 | \
268		grep -v '^[ 	]*$$' > $@
269
270#=======================================================================
271all:	prog manpage
272
273# N.B. dcl2inc is also a prog but it is made by configure.  A generic
274# copy of it is provided with the distribution also, in case the user
275# doesn't want to or can't use configure.
276prog:	ftnchek$(EXE)
277
278# The manpage target is a "clean-ed up" version of the Unix man page,
279# with conditional text, used by developer to create other forms of
280# documentation, removed.
281manpage: ftnchek$(manext)
282
283#  Development version includes debugging machinery not normally used.  It
284#  evaluates some floating-point expressions including sqrt, so needs math lib.
285devel:
286	$(MAKE) prog DEVEL_CFLAGS='-DDEVELOPMENT' LDLIBS='$(LDLIBS) -lm'
287
288check: prog
289	cd $(TESTDIR); $(MAKE) NAWK="$(NAWK)" -s precheck
290	cd $(TESTDIR); $(MAKE) NAWK="$(NAWK)" -i -s check
291
292lint:
293	$(LINT) $(LINTFLAGS) $(OBJS:.o=.c) -lm
294
295# Remove intermediate files that are not required after the program is
296# built.
297clean mostlyclean:
298	-$(RM) *.o
299	-$(RM) \#*
300	-$(RM) a.out
301	-$(RM) *~
302	-$(RM) core
303	-$(RM) y.tab.h
304	-$(RM) config.status config.log config.cache
305	-$(RM) ftnchek.html.orig ftnchek.html.rej
306
307# Remove almost everything that make can rebuild.  We do not remove
308# fortran.c since some places don't have yacc or bison.
309clobber realclean:	clean
310	-$(RM) ftnchek$(EXE)
311
312# Remove everything that make can rebuild, preparatory to making a
313# distribution version.  We intentionally do NOT remove .ps and .doc
314# files, because some UNIX systems lack nroff/troff/groff.
315distclean:	realclean testclean htmlclean
316	-$(RM) *.dcl
317	-$(RM) cscope.out
318	-$(RM) tags
319	-$(RM) TAGS
320	-$(RM) ftnchek$(manext)
321	-$(RM) dcl2inc.cat ftnchek.cat
322
323testclean:
324	cd $(TESTDIR); $(MAKE) distclean
325
326htmlclean:
327	cd $(HTMLDIR); $(MAKE) -f ../Makefile clean
328
329maintainer-clean:	distclean
330	@echo "This command is intended for maintainers to use;"
331	@echo "it deletes files that may require special tools to rebuild."
332	-$(RM) Makefile
333	-$(RM) configure
334	-$(RM) fortran.c
335	-$(RM) *.catman
336
337ftnchek$(EXE): $(OBJS)
338	$(CC) $(CFLAGS) $(LDFLAGS) -o ftnchek$(EXE) $(OBJS) $(LDLIBS)
339
340# N.B. tokdefs.h is copy of y.tab.h used to avoid remaking stuff when
341# grammar changes but not tokens.  If the parser is made by bison,
342# it is edited to make token names in "parse error" messages more readable.
343# Also concatenate backslash-continued #if lines, which some older
344# compilers don't like.
345# The following copies y.tab.h to tokdefs.h if changed, then aborts make,
346# since dependencies may have changed.
347fortran.c: fortran.y
348	$(YACC) $(YFLAGS) fortran.y
349	@if test "$(YACC_NAME)" = "bison$(EXE)" ; \
350	then \
351	  $(SED) -e '/yytname\[] =/,/^};/s/tok_//g' \
352	         -e '/yytname\[] =/,/^};/s/_/ /g' \
353	         -e '/yytname\[] =/,/^};/s/EOS/end of statement/g' \
354		 -e  ':CAT'  -e '/^# *if.*\\$$/N' -e 's/\\\n//' -e tCAT \
355		y.tab.c > fortran.c ; \
356	  $(RM) y.tab.c ; \
357	else \
358	  $(MV) y.tab.c fortran.c ; \
359	fi
360	@if $(CMP) -s y.tab.h tokdefs.h ; then true ; else \
361		echo; echo tokdefs.h changed -- repeat make ; \
362		$(CP) y.tab.h tokdefs.h; \
363		false ; \
364	fi
365
366# If tokdefs.h changes, update the lookup table used by block-balancing code.
367block_match.h: tokdefs.h
368	./make_blockmatch.pl > block_match.h
369
370# This target makes an enum type for doing reverse lookup in the iokeywords table.
371# The uniq filter is needed since some keywords may have alternate definitions depending
372# on #defines.  These are always adjacent.  The last sed command removes
373# comma from last item in enum list, in accordance with c89.
374iokeywds_enum.h: iokeywds.h
375	sed -n '/^} io_keywords\[\]={/,/^};$$/s/^{"\([^"]*\).*$$/IOKW_\1,/p' iokeywds.h \
376		| uniq \
377		| sed '$$s/,$$//' > $@
378
379# Documentation targets: If you make changes to the documentation,
380# you should edit only ftnchek.man and then re-make these targets.
381# If ftnchek.1 fails to make, ftnchek.man is usable directly (after
382# applying soelim) except that some troff-like processors may not
383# give satisfactory results.
384
385docs:	average.out blurb.txt ftnchek.doc ftnchek.hlp \
386	htmldocs ftnchek.ps dcl2inc.doc dcl2inc.ps
387
388
389# Following sed script trims out the if-else machinery contained in
390# ftnchek.man to produce a clean nroff document.  The lines of the
391# sed script correspond to the following actions:
392#	1. remove text between lines of form ``.if \nh \{'' or .ie \nh \{''
393#	   and lines of form ``\}'' (these are the help-related additions)
394#	2. remove lines of form ``.if !\nh \{''  (these preface man text)
395#	   Also remove ``.if !\nb \{'' which are for blurb.
396#	3. remove lines of form ``.el \{''  (start of the else sections of
397#	   the .if's of step 1)
398#	4. remove lines of form ``\}'' (closures of step 3 lines)
399#	5. remove lines of form ``.ie \nh text'' (one-liner help text)
400#	6. change lines of form ``.el \nh text'' to ``text'' (these are
401#	   one-liner man text)
402#	7. change lines of form ``.if !\nh text'' to ``text'' (ditto)
403ftnchek$(manext):	ftnchek.man average.f average.out correct.f
404	@if test -x $(SOELIM) ; \
405	then \
406	  echo "Making cleaned-up manpage ftnchek$(manext)" ; \
407	  $(SOELIM) ftnchek.man | \
408	  $(SED) -e '/^\.i[fe] \\nh \\{/,/^\\}$$/d' \
409	    -e '/^\.if !\\n[bh] \\{/d' \
410	    -e '/^\.el \\{/d' \
411	    -e '/^\\}/d' \
412	    -e '/^\.i[fe] \\nh /d' \
413	    -e 's/^\.el *\(.*\)$$/\1/' \
414	    -e 's/^\.if !\\nh *\(.*\)$$/\1/' \
415			> ftnchek$(manext) ; \
416	else \
417	  echo "$(SOELIM) not available: cannot make cleaned-up manpage ftnchek$(manext)." ; \
418	  echo "You must use the catman documentation (provided separately)." ; \
419	fi
420
421# .doc files are ascii text form of documentation.
422.man.doc:
423	$(TBL) $< | $(NROFFPLAIN) -man | $(COL) > $@
424
425# ftnchek.ps is PostScript form of documentation.  For ftnchek.ps we use
426# cleaner ftnchek.1 rather than ftnchek.man.
427ftnchek.ps:	ftnchek$(manext)
428	$(TBL) <ftnchek$(manext) | $(EQN) | $(MANtoPS) >ftnchek.ps
429
430# Other man files are clean enough as they are.
431.man.ps:
432	$(TBL) < $< | $(EQN) | $(MANtoPS) > $@
433
434# $(HTMLDIR)/toc.html represents all the files in the html directory.  They
435# are built from ftnchek.html by the script make_html.sh whenever
436# ftnchek.html changes.  Note: edits should be done to ftnchek.man if
437# they affect content, to ftnchek.html if they affect html form.  Do
438# not edit anything in html directory.
439
440htmldocs: $(HTMLDIR)/toc.html
441
442$(HTMLDIR)/toc.html: ftnchek.html
443	./make_html.sh ftnchek.html
444
445# ftnchek.html is produced from ftnchek.1 by MANtoHTML followed by a
446# simple script to add internal links to option descriptions, then
447# lightly edited.  Edits were initially by hand, now are saved in
448# ftnchek.html.patch (not distributed) to be re-applied each time.
449# Any time new edits are done to ftnchek.html, the patch file should
450# be remade.  Also make ftnchek.html.patch after editing ftnchek.man,
451# so that the patch offsets don't get too large for patch to succeed.
452
453ftnchek.html:	ftnchek.html.orig
454	$(CP) ftnchek.html.orig ftnchek.html
455	if test -f ftnchek.html.patch ; \
456	then \
457	   $(PATCH) < ftnchek.html.patch ; \
458	fi
459
460ftnchek.html.orig: ftnchek$(manext)
461	$(MANtoHTML) ftnchek$(manext) | ./add_html_refs.sh > ftnchek.html.orig
462
463ftnchek.html.patch: ftnchek.html.orig ftnchek.html
464	@echo "It is normal for the next command to report an error"
465	-$(DIFF) -c ftnchek.html.orig ftnchek.html > ftnchek.html.patch
466
467# blurb.txt is an ascii file for informational mailings.
468blurb.txt:	ftnchek.man
469	$(TBL) ftnchek.man | $(NROFFPLAIN) -man -rb1 | $(COL) >blurb.txt
470
471# ftnchek.hlp is a VMS HELP library source document:
472# create ftnchek.hlb with $ LIBR/CREATE/HELP FTNCHEK.HLB FTNCHEK.HLP
473# The leading and trailing newlines in ftnchek.hlp should be removed.
474ftnchek.hlp:	ftnchek.man
475	$(SED) -e '1d' ftnchek.man | \
476	$(TBL) | $(NROFFPLAIN) -man -rh1 | $(COL) | \
477	$(SED) -e 's/^-\([a-zA-Z][a-zA-Z]*\)/\/\1/' \
478	    -e 's/\([^a-zA-Z]\)-\([a-zA-Z][a-zA-Z]*\)/\1\/\2/g' \
479	>ftnchek.hlp
480
481
482# Rebuild average.out when version changes.  (We don't put the
483# dependency on ftnchek to avoid building ftnchek just for docs.)
484average.out: ftnchek.h
485	$(FTNCHEK) -list -symtab average > average.out
486
487# Install program and documentation on system.  Obsolete fcl2vcg script
488# & doc is removed if present.  Old program is first deleted, in case
489# it is a hard link to specific previous version, so that version does
490# not get overwritten.
491install:	install-exe install-man install-lisp
492
493install-exe:	ftnchek$(EXE) dcl2inc$(CMD)
494	-$(RM) $(bindir)/ftnchek$(EXE)
495	-$(MKDIR) -p $(bindir)
496	$(CP) ftnchek$(EXE) $(bindir)
497	-$(STRIP) $(bindir)/ftnchek$(EXE)
498	$(CHMOD) 755 $(bindir)/ftnchek$(EXE)
499	-$(MKDIR) -p $(libdir)
500	$(CP) dcl2inc.awk $(libdir)/dcl2inc.awk
501	$(CHMOD) 644 $(libdir)/dcl2inc.awk
502	$(CP) dcl2inc$(CMD) $(bindir)/dcl2inc$(CMD)
503	$(CHMOD) 755 $(bindir)/dcl2inc$(CMD)
504	-$(RM) $(bindir)/fcl2vcg
505
506# Install man pages, taking care to remove old formatted ones, because
507# many man implentations fail to compare time stamps of raw and
508# formatted files, and will show out-of-date formatted files.
509install-man: ftnchek$(manext)
510	-$(MKDIR) -p $(mandir)/man1
511	$(CP) dcl2inc.man $(mandir)/man1/dcl2inc$(manext)
512	-$(RM) $(mandir)/cat1/dcl2inc$(manext)
513	$(CHMOD) 644 $(mandir)/man1/dcl2inc$(manext)
514	$(CP) ftnchek$(manext) $(mandir)/man1/ftnchek$(manext)
515	-$(RM) $(mandir)/cat1/ftnchek$(manext)
516	$(CHMOD) 644 $(mandir)/man1/ftnchek$(manext)
517	-$(RM) $(mandir)/man1/fcl2vcg$(manext)
518	-$(RM) $(mandir)/cat1/fcl2vcg$(manext)
519
520# IRIX uses pre-formatted, packed man pages and nroff is not bundled with it.
521install-man-sgi: catman
522	if $(PACK) dcl2inc.cat ; \
523	then \
524		$(MV) dcl2inc.cat.z $(mandir)$(sgimansubdir)/dcl2inc.z ; \
525		$(CHMOD) 644 $(mandir)$(sgimansubdir)/dcl2inc.z ; \
526	fi
527	if $(PACK) ftnchek.cat ; \
528	then \
529		$(MV) ftnchek.cat.z $(mandir)$(sgimansubdir)/ftnchek.z ; \
530		$(CHMOD) 644 $(mandir)$(sgimansubdir)/ftnchek.z ; \
531	fi
532	-$(RM) $(mandir)/fcl2vcg.z
533
534# The catman target makes formatted ("cat") versions of the manpages
535# for use in install-man-sgi.  These files are not in the standard
536# distribution but are available separately (with suffix catman) for
537# sites that do not have nroff.  If this Unix does not have nroff,
538# then if user has obtained the catman versions, use them.  Otherwise
539# inform them and use the flat ascii files as fallback.
540catman: dcl2inc.cat ftnchek.cat
541
542.man.cat:
543	@if test -x $(TBL) -a  -x $(NROFF) ; then \
544	  echo '$(TBL) $< | $(NROFF) -man > $@' ; \
545	  $(TBL) $< | $(NROFF) -man > $@ ; \
546	else \
547	  if test -f $*.catman ; then \
548	    echo cp $*.catman $@ ; \
549	    cp $*.catman $@ ; \
550	  else \
551	    echo "--> No catman documentation found -- see INSTALL." ; \
552	    echo "Using plain text documentation instead." ; \
553	    echo cp $*.doc $@ ; \
554	    cp $*.doc $@ ; \
555	  fi ; \
556	fi
557
558#  The emacs lisp file will be installed only if lispdir exists.  It will
559#  be byte-compiled if emacs is present.
560install-lisp:
561	@if test -d "$(lispdir)" ; \
562	then \
563	  echo $(CP) ftnchek.el $(lispdir)/ftnchek.el ; \
564	  if $(CP) ftnchek.el $(lispdir)/ftnchek.el ; \
565	  then \
566	     if test -x "$(EMACS)" ; \
567	     then \
568	       $(EMACS) -batch -f batch-byte-compile $(lispdir)/ftnchek.el ; \
569	     else \
570	       echo "If desired, use emacs to byte-compile $(lispdir)/ftnchek.el"; \
571	     fi \
572	  fi \
573	else \
574	  echo "$(lispdir) does not exist -- ftnchek.el not installed." ; \
575	  echo "If you want to install ftnchek.el, create $(lispdir)" ; \
576	  echo "or re-run make install with 'lispdir=path-to-site-lisp'" ; \
577	fi
578
579# Remove everything that the install target installed.
580uninstall:
581	-$(RM) $(bindir)/dcl2inc$(CMD)
582	-$(RM) $(bindir)/ftnchek$(CMD)
583	-$(RM) $(libdir)/dcl2inc.awk
584	-$(RM) $(mandir)/cat1/dcl2inc$(manext)
585	-$(RM) $(mandir)/cat1/ftnchek$(manext)
586	-$(RM) $(mandir)/dcl2inc.z $(mandir)/ftnchek.z # SGI
587	-$(RM) $(mandir)/man1/dcl2inc$(manext)
588	-$(RM) $(mandir)/man1/ftnchek$(manext)
589	-$(RM) $(lispdir)/ftnchek.el
590	-$(RMDIR) $(libdir)
591
592# WARNING: do NOT execute this target, unless you have nroff/troff or groff
593# to recreate the formatted documentation files.
594spotless:	distclean
595	$(RM) blurb.txt
596	$(RM) dcl2inc.doc ftnchek.doc
597	$(RM) dcl2inc.ps ftnchek.ps
598	$(RM) ftnchek.hlp
599
600# ex and vi editor tags file
601tags:	$(SRCS)
602	$(CTAGS) $(CTAGSFLAGS) $(SRCS)
603
604# emacs editor tags file
605TAGS:	$(SRCS)
606	$(ETAGS) $(SRCS)
607
608#=======================================================================
609# Object file dependencies on include files
610
611advance.o:	config.h ftnchek.h symtab.h tokdefs.h forlex.h advance.h
612
613argcheck.o:	config.h ftnchek.h pgsymtab.h symtab.h
614
615calltree.o:	config.h ftnchek.h pgsymtab.h symtab.h
616
617comcheck.o:	config.h ftnchek.h pgsymtab.h symtab.h
618
619exprtype.o:	config.h ftnchek.h symtab.h tokdefs.h
620
621forlex.o:	config.h ftnchek.h symtab.h tokdefs.h forlex.h advance.h
622
623fortran.o:	config.h ftnchek.h symtab.h block_match.h fortran.c
624
625ftnchek.o:	config.h ftnchek.h intrins.h options.h utils.h
626
627include.o:	config.h ftnchek.h symtab.h forlex.h advance.h
628
629intake.o:	config.h ftnchek.h symtab.h tokdefs.h forlex.h advance.h
630
631intrins.o:	config.h ftnchek.h intrins.h symtab.h
632
633iokeywds.o:	config.h ftnchek.h symtab.h tokdefs.h iokeywds.h iokeywds_enum.h utils.h
634
635keywords.o:	config.h ftnchek.h symtab.h tokdefs.h forlex.h
636
637labels.o:	config.h ftnchek.h plsymtab.h symtab.h
638
639loccheck.o:	config.h ftnchek.h loccheck.h plsymtab.h symtab.h
640
641makedcls.o:	config.h ftnchek.h plsymtab.h symtab.h
642
643makehtml.o:     config.h ftnchek.h plsymtab.h symtab.h tokdefs.h advance.h
644
645message.o:	config.h ftnchek.h
646
647options.o:	config.h ftnchek.h options.h utils.h
648
649pgsymtab.o:	config.h ftnchek.h pgsymtab.h symtab.h
650
651plsymtab.o:	config.h ftnchek.h plsymtab.h symtab.h
652
653prlists.o:	config.h ftnchek.h symtab.h symutils.h
654
655prlocsym.o:	config.h ftnchek.h loccheck.h plsymtab.h symtab.h
656
657project.o:	config.h ftnchek.h symtab.h
658
659symspace.o:	config.h ftnchek.h symtab.h symspace.h symutils.h
660
661symtab.o:	config.h ftnchek.h iokeywds.h intrins.h symtab.h \
662		symspace.h symutils.h tokdefs.h
663
664symutils.o:	config.h ftnchek.h symtab.h symutils.h
665
666utils.o:	config.h utils.h
667
668#=======================================================================
669# The configure.generic script creates generic versions of CONFIGURED_FILES
670# for users on deficient Unix systems or using GNU software on non-Unix
671# platforms.  It tries to put reasonably generic values in for all the
672# things that the configure script is supposed to handle.  Pathnames
673# are removed since these may vary wildly.  The rule also checks for
674# any unsubstituted items indicating configure.generic needs to be
675# updated.  The config-generic.h produced here should need few if any
676# changes to serve as config.h on most recent 32-bit systems.
677# This target has no dependencies since its purpose is
678# to replace the developer's configured versions with the generic ones,
679# regardless of whether the .in files have changed.  Note that
680# makefile.generic.in and config-generic.h.in are treated specially:
681# they are copies of Makefile.in and config.h.in respectively, but the
682# generic configured versions are not named Makefile and config.h, because
683# these are deliberately left out of the distribution.
684generic-config:
685	$(CP) Makefile.in makefile.generic.in
686	$(CP) config.h.in config-generic.h.in
687	./configure.generic $(CONFIGURED_FILES)
688	$(RM) makefile.generic.in
689	$(RM) config-generic.h.in
690	chmod +x dcl2inc test/Compare.sh
691	@if $(GREP) \
692	   '@[^*@]*@' $(CONFIGURED_FILES) ; \
693	then \
694	    echo '####################################################' ; \
695	    echo '## FIX configure.generic TO SUBSTITUTE THE ABOVE. ##' ; \
696	    echo '####################################################' ; \
697	fi
698
699# Here we provide rules for making the two CONFIGURED_FILES that are
700# not generated by "configure".  This is mainly a convenience for the
701# new developer since it is not so obvious where they come from.  They
702# are not needed for development but only for the distribution.  They
703# are normally made by generic-config.
704makefile.generic: Makefile.in
705	$(CP) Makefile.in makefile.generic.in
706	./configure.generic makefile.generic
707	$(RM) makefile.generic.in
708
709config-generic.h: config.h.in
710	$(CP) config.h.in config-generic.h.in
711	./configure.generic config-generic.h
712	$(RM) config-generic.h.in
713
714#=======================================================================
715#  This target warns if VMS build command files are out of date.  The sed
716#  command concatenates continuation lines, marked by "-" as last character.
717checkvmsbuild:
718	@-for obj in $(OBJS:.o=) ; \
719	do \
720	  for com in build.com build-vax.com ; \
721	  do \
722	    if grep -q "^\$$ @CC.* $$obj[	 ]" $$com ; \
723	    then true; else \
724		echo "Source $$obj missing from CC in $$com" ; \
725	    fi ; \
726	    if sed -e ':CAT' -e '/-$$/N'  -e 's/-\n//' -e tCAT \
727		   -e s/$$/,/ $$com | \
728		grep -q "^\$$ @LINK.*[ ,]$$obj," ; \
729	    then true; else \
730		echo "Object $$obj missing from LINK in $$com" ; \
731	    fi ; \
732	  done; \
733	done
734
735# Target to make sure the DOS versions of test master files are
736# up to date
737dosokay:
738	cd $(TESTDIR); $(MAKE) dosokay
739
740#=======================================================================
741# Making the distribution tar file.  Dirname is name of current
742# directory.  Makefile is not distributed because it is supposed
743# to be created by local configure.  Files to archive are explicitly
744# named so that detritus from development will not be accidentally
745# included.  However, test files are not listed separately so one
746# should make clean in $(TESTDIR)/ first.
747#
748# This target assumes GNU tar for the --exclude option.  If you don't
749# have it, remove test/Makefile manually and use ``make tar TAR_EXCLUDE=''
750
751TAR_EXCLUDE	= --exclude $$dirname/$(TESTDIR)/Makefile
752
753tar:
754	dirname=`$(PWD_PROG)|$(SED) 's%.*/%%'` ; cd .. ; \
755	  $(TAR) -cf $$dirname.tar $(TAR_EXCLUDE) \
756	  `echo " "$(DISTFILES) | $(SED) "s% % $$dirname/%g"`
757
758#  This target is for maintainer: generates the catman tar file for separate
759#  distribution.
760catman.tar: $(CATMAN)
761	dirname=`$(PWD_PROG)|$(SED) 's%.*/%%'` ; \
762	$(TAR) -cf ../$$dirname.catman.tar $(CATMAN)
763
764.cat.catman:
765	$(CP) $< $@
766
767#  Make a distribution zipfile for MS-DOS/Windows/OS2.  The -l changes \n
768#  to \r\n.  Then binary files and text files that already have \r\n are
769#  replaced in binary mode.
770#  Note that unlike tar, zip file names are relative to current directory.
771#  Rule renames ftnchek-x.x.x to ftnchek-x_x_x for zip and lsm files.
772zip:
773	dirname=`$(PWD_PROG)|$(SED) 's%.*/%%'` ; \
774	dosname=`echo $$dirname|$(SED) -e 's/\./_/g'` ; \
775	$(CP) $$dirname.lsm $$dosname.lsm ; \
776	dirname=$$dosname ; \
777	$(RM) ../$$dirname.zip ; \
778	$(ZIPTEXT) -r ../$$dirname.zip $(ZIPFILES) ; \
779	$(ZIP)     ../$$dirname.zip $(BINARY_ZIPFILES)
780
781# Targets that should be freshened prior to making tar (so I don't put
782# stale ones into the distribution).
783pretar:	docs generic-config clean testclean checkvmsbuild dosokay
784