File: makefile.generic

package info (click to toggle)
ftnchek 3.3.1-7
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,684 kB
  • sloc: ansic: 21,908; fortran: 5,748; yacc: 4,071; sh: 3,035; makefile: 895; lisp: 322; f90: 118; perl: 76
file content (783 lines) | stat: -rw-r--r-- 28,747 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
#=======================================================================
# $Id: Makefile.in,v 1.76 2004/11/14 15:52:12 moniot Exp $
#
# UNIX version of Makefile for Fortran program checker ftnchek
#
# User target list:
#	all			build ftnchek and its man page
#	blurb.txt		brief descriptive document about ftnchek
#	check			run validation test suite
#	clean			remove unnecessary intermediate files
#	clobber			make clean, and remove ftnchek executable
#	dcl2inc.doc		plain text form of documentation
#	dcl2inc.ps		PostScript form of documentation
#	distclean		remove everything not in the distribution
#	docs			documentation files
#	fortran.c		translates yacc code to C (made from fortran.y)
#	ftnchek			ftnchek executable program
#	ftnchek.1		UNIX manual page (made from fortran.man)
#	ftnchek.doc		plain text form of documentation
#	ftnchek.hlp		VMS HELP library source
#	ftnchek.ps		PostScript form of documentation
#	htmlclean		remove unneeded files from html directory
#	htmldocs		hypertext form of documentation
#	install			install ftnchek and dcl2inc and their man pages
#	install-exe		install ftnchek and dcl2inc executables
#	install-lisp		install emacs ftnchek-mode lisp file
#	install-man		install man pages on most UNIX systems
#	install-man-sgi		install man pages on SGI systems
#	manpage			same as ftnchek.1
#	mostlyclean		same as clean
#	prog			same as ftnchek
#	realclean		same as clobber
#	uninstall		remove everything "make install" installs
#
# Developer target list:
#	catman			create "cat" format manpages
#	catman.tar		create "cat" format manpage tar file
#	devel			build development version (extra debugging).
#	lint			run lint on source code
#	generic-config		create generic config.h etc for distribution
#	maintainer-clean	distclean, then things maintainer can rebuild
#	pretar			get ready to make distribution tar file
#	spotless		distclean, then remove ps, html and text docs
#	TAGS			emacs editor tags file
#	tags			ex and vi editor tags file
#	tar			distribution tar file
#	testclean		remove unnecessary files from test directory
#	zip			distribution zip file for MS-DOS
#
# Not a target, made by configure:
#	dcl2inc			Shell script to convert decls to includes
#
# Object file targets		see list of objects at OBJS
#
#
#
# Copyright (c) 2001 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 THE AUTHORS OR
# COPYRIGHT HOLDERS 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.
# 
# Acknowledgement: the above permission notice is what is known
# as the "MIT License."
# 
#
# Acknowledgements and thanks to Nelson H. F. Beebe of the University
# of Utah for improvements to this Makefile.
# [25-Apr-1994]
#=======================================================================

# These definitions should be customized for your local conventions
# if you want to do "make install" or "make uninstall".
#  prefix is the root of the destination for installing things.
#  bindir is directory for executables, mandir for man pages.
#  manext is the extension on man pages, including the dot.
#  libdir is the directory for library files (dcl2inc.awk).  It must
#    agree with the libdir defined in dcl2inc as made by configure.
#  lispdir is where to put ftnchek.el.

prefix		= /usr/local
exec_prefix	= ${prefix}
bindir		= ${exec_prefix}/bin
datadir		= ${prefix}/share
mandir		= ${prefix}/man
manext		= .1
sgimansubdir	= /manl
libdir		= ${exec_prefix}/lib/ftnchek
lispdir		= ${datadir}/emacs/site-lisp

# Define suffix for executables, for non-unix systems which have one.
EXE		= 
#EXE		= .exe

# Define suffix for scripts, to go on the end of dcl2inc script.
CMD		= 
#CMD		= .cmd
#CMD		= .bat

# The following definitions are set for your system by configure.
# In non-generic Makefile these should all be path-qualified except
# for *_NAME.  If path is missing then configure didn't find it.
# AWK is any awk; NAWK is the enhanced awk needed by dcl2inc.
# AWK_NAME and YACC_NAME have the pathless names to simplify tests where the
# particular flavor of the utility matters.  NROFF is the nroff program,
# NROFFPLAIN has flags to suppress escape sequences.  PWD_PROG is so named
# to avoid collision with shell variable PWD.  ZIPTEXT is zip program
# with flag for Unix->DOS line-end conversion, ZIP is default mode.
AWK		= gawk
AWK_NAME	= gawk
CC              = cc
CHMOD		= chmod
CMP		= cmp
CP		= cp
DIFF		= diff
EMACS		= emacs
EQN		= eqn
GREP		= grep
LINT		= lint
MANtoHTML	= man2html
MANtoPS		= ./man2ps
MKDIR		= mkdir
MV		= mv
NAWK		= gawk
NROFF		= nroff
NROFFPLAIN	= nroff -c
PATCH		= patch
PWD_PROG	= pwd
RM		= rm -f
RMDIR		= rmdir
SED		= sed
SHELL		= sh
SOELIM		= soelim
STRIP           = strip
TAR		= tar
TBL		= tbl
YACC            = bison
YACC_NAME	= bison
ZIP		= zip
ZIPTEXT		= $(ZIP) -l

# The following is only used for targets ftnchek.doc and ftnchek.hlp
# which are not needed for unix platforms.  It removes control chars
# and converts tabs to blanks.  Normally COL=col -bx but if you don't
# have it, can make do with cat.
COL		= col -bx

# Editor tags file support
CTAGS		= ctags
CTAGSFLAGS	= -t
ETAGS		= etags

# The following suffixes are for making various forms of documentation
.SUFFIXES: .cat .catman .doc .man .ps .i


# Pack is needed only for install-man-sgi target
PACK		= pack

FTNCHEK		= ./ftnchek$(EXE)

# 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

# OPT is optimization level
# CFLAGS is used to define the operating system and options
# LDLIBS gives any system-specific libraries for linker
# LDFLAGS gives linker options
# YFLAGS specifies yacc options
OPT		= -O
CFLAGS          = -DUNIX -O $(OPTIONS) $(DEBUG_FLAGS) $(DEVEL_CFLAGS)
LDLIBS          = 
LDFLAGS         =  $(DEBUG_FLAGS) $(DEVEL_LDFLAGS)
YFLAGS          = -y -d

# fortran.o first because of possible remake if tokdefs.h changes (see below)
OBJS            = fortran.o advance.o argcheck.o calltree.o comcheck.o exprtype.o \
		  forlex.o ftnchek.o include.o intake.o intrins.o \
		  iokeywds.o keywords.o labels.o \
		  loccheck.o makedcls.o makehtml.o message.o options.o pgsymtab.o \
		  plsymtab.o prlists.o prlocsym.o project.o \
		  symspace.o symtab.o symutils.o utils.o

DOCS		= README INSTALL LICENSE PATCHES FAQ ToDo project.magic \
			average.f average.out correct.f \
			blurb.txt dcl2inc.doc dcl2inc.man dcl2inc.ps \
			ftnchek.doc ftnchek.hlp ftnchek.man ftnchek.ps html \
			macro-doc.txt project-doc.tex \
			$$dirname.lsm
#		 the above expands to ftnchek-x.y.z.lsm in make tar

UNIX_BUILDFILES	= Makefile.in configure configure.in config.guess config.sub \
			config.h.in configure.generic install-sh \
			add_html_refs.sh make_html.sh \
			make_blockmatch.pl make_blockmatch.pl.in

VMS_BUILDFILES	= build.com build-vax.com cc.com link.com check.com

OS2_BUILDFILES	= ftnchek.def configure_os2.cmd

OTHER_BUILDFILES= makefile.bcc32 \
			makefile.generic makefile.mpw \
			ftnchek.dsp ftnchek.dsw

BUILDFILES	= $(UNIX_BUILDFILES) $(VMS_BUILDFILES) $(OS2_BUILDFILES) \
			$(OTHER_BUILDFILES)

SRCS            = advance.c advance.h argcheck.c block_match.h \
		  calltree.c comcheck.c config-generic.h config-win32.h exprtype.c \
		  forlex.c forlex.h fortran.y fortran.c ftnchek.c ftnchek.h \
		  include.c intake.c intrins.c intrins.h iokeywds.h \
		  iokeywds_enum.h iokeywds.c \
		  keywords.c labels.c \
		  loccheck.c loccheck.h makedcls.c makehtml.c message.c options.c \
		  options.h pgsymtab.c pgsymtab.h plsymtab.c plsymtab.h \
		  prlists.c prlocsym.c project.c symspace.c \
		  symspace.h symtab.c symtab.h symutils.c symutils.h tokdefs.h \
			utils.h utils.c
SCRIPTS		= dcl2inc dcl2inc.in dcl2inc.awk dcl2inc.awk.in \
		  man2ps ftnchek.el
TESTDIR		= test
HTMLDIR		= html
# The following defines all files to go into distribution tar file
DISTFILES	= $(DOCS) $(BUILDFILES) $(SRCS) $(SCRIPTS) $(TESTDIR)
# The following defines all files to go into MS-DOS distribution zip file.
# BINARY_ZIPFILES are those that should not undergo the LF->CR-LF replacement.
ZIPFILES	= $(DISTFILES)
BINARY_ZIPFILES= configure_os2.cmd test/*.bat test/cmp.exe

# The following defines all files that go into the auxiliary catman tar file
CATMAN		= dcl2inc.catman ftnchek.catman

# Files in the following list are created by the configure script.
# Generic versions for the distribution are made by the generic-config
# target.
CONFIGURED_FILES = makefile.generic dcl2inc.awk dcl2inc make_blockmatch.pl \
			test/Makefile test/Compare.sh config-generic.h
#=======================================================================
#  Rule to run source thru preprocessor only; useful for tracing down
#  compilation problems.  Blank lines are removed for convenient viewing.
.c.i:
	$(CC) -E -I. $(DEFS) $(CPPFLAGS) $(CFLAGS) $< 2>&1 | \
		grep -v '^[ 	]*$$' > $@

#=======================================================================
all:	prog manpage

# N.B. dcl2inc is also a prog but it is made by configure.  A generic
# copy of it is provided with the distribution also, in case the user
# doesn't want to or can't use configure.
prog:	ftnchek$(EXE)

# The manpage target is a "clean-ed up" version of the Unix man page,
# with conditional text, used by developer to create other forms of
# documentation, removed.
manpage: ftnchek$(manext)

#  Development version includes debugging machinery not normally used.  It
#  evaluates some floating-point expressions including sqrt, so needs math lib.
devel:
	$(MAKE) prog DEVEL_CFLAGS='-DDEVELOPMENT' LDLIBS='$(LDLIBS) -lm'

check: prog
	cd $(TESTDIR); $(MAKE) NAWK="$(NAWK)" -s precheck
	cd $(TESTDIR); $(MAKE) NAWK="$(NAWK)" -i -s check

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

# Remove intermediate files that are not required after the program is
# built.
clean mostlyclean:
	-$(RM) *.o
	-$(RM) \#*
	-$(RM) a.out
	-$(RM) *~
	-$(RM) core
	-$(RM) y.tab.h
	-$(RM) config.status config.log config.cache
	-$(RM) ftnchek.html.orig ftnchek.html.rej

# Remove almost everything that make can rebuild.  We do not remove
# fortran.c since some places don't have yacc or bison.
clobber realclean:	clean
	-$(RM) ftnchek$(EXE)

# Remove everything that make can rebuild, preparatory to making a
# distribution version.  We intentionally do NOT remove .ps and .doc
# files, because some UNIX systems lack nroff/troff/groff.
distclean:	realclean testclean htmlclean
	-$(RM) *.dcl
	-$(RM) cscope.out
	-$(RM) tags
	-$(RM) TAGS
	-$(RM) ftnchek$(manext)
	-$(RM) dcl2inc.cat ftnchek.cat

testclean:
	cd $(TESTDIR); $(MAKE) distclean

htmlclean:
	cd $(HTMLDIR); $(MAKE) -f ../Makefile clean

maintainer-clean:	distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
	-$(RM) Makefile
	-$(RM) configure
	-$(RM) fortran.c
	-$(RM) *.catman

ftnchek$(EXE): $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o ftnchek$(EXE) $(OBJS) $(LDLIBS)

# N.B. tokdefs.h is copy of y.tab.h used to avoid remaking stuff when
# grammar changes but not tokens.  If the parser is made by bison,
# it is edited to make token names in "parse error" messages more readable.
# Also concatenate backslash-continued #if lines, which some older
# compilers don't like.
# 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
	@if test "$(YACC_NAME)" = "bison$(EXE)" ; \
	then \
	  $(SED) -e '/yytname\[] =/,/^};/s/tok_//g' \
	         -e '/yytname\[] =/,/^};/s/_/ /g' \
	         -e '/yytname\[] =/,/^};/s/EOS/end of statement/g' \
		 -e  ':CAT'  -e '/^# *if.*\\$$/N' -e 's/\\\n//' -e tCAT \
		y.tab.c > fortran.c ; \
	  $(RM) y.tab.c ; \
	else \
	  $(MV) y.tab.c fortran.c ; \
	fi
	@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

# If tokdefs.h changes, update the lookup table used by block-balancing code.
block_match.h: tokdefs.h
	./make_blockmatch.pl > block_match.h

# This target makes an enum type for doing reverse lookup in the iokeywords table.
# The uniq filter is needed since some keywords may have alternate definitions depending
# on #defines.  These are always adjacent.  The last sed command removes
# comma from last item in enum list, in accordance with c89.
iokeywds_enum.h: iokeywds.h
	sed -n '/^} io_keywords\[\]={/,/^};$$/s/^{"\([^"]*\).*$$/IOKW_\1,/p' iokeywds.h \
		| uniq \
		| sed '$$s/,$$//' > $@

# Documentation targets: If you make changes to the documentation,
# you should edit only ftnchek.man and then re-make these targets.
# If ftnchek.1 fails to make, ftnchek.man is usable directly (after
# applying soelim) except that some troff-like processors may not
# give satisfactory results.

docs:	average.out blurb.txt ftnchek.doc ftnchek.hlp \
	htmldocs ftnchek.ps dcl2inc.doc dcl2inc.ps


# Following sed script trims out the if-else machinery contained in
# ftnchek.man to produce a clean nroff document.  The lines of the
# sed script correspond to the following actions:
#	1. remove text between lines of form ``.if \nh \{'' or .ie \nh \{''
#	   and lines of form ``\}'' (these are the help-related additions)
#	2. remove lines of form ``.if !\nh \{''  (these preface man text)
#	   Also remove ``.if !\nb \{'' which are for blurb.
#	3. remove lines of form ``.el \{''  (start of the else sections of
#	   the .if's of step 1)
#	4. remove lines of form ``\}'' (closures of step 3 lines)
#	5. remove lines of form ``.ie \nh text'' (one-liner help text)
#	6. change lines of form ``.el \nh text'' to ``text'' (these are
#	   one-liner man text)
#	7. change lines of form ``.if !\nh text'' to ``text'' (ditto)
ftnchek$(manext):	ftnchek.man average.f average.out correct.f
	@if test -x $(SOELIM) ; \
	then \
	  echo "Making cleaned-up manpage ftnchek$(manext)" ; \
	  $(SOELIM) ftnchek.man | \
	  $(SED) -e '/^\.i[fe] \\nh \\{/,/^\\}$$/d' \
	    -e '/^\.if !\\n[bh] \\{/d' \
	    -e '/^\.el \\{/d' \
	    -e '/^\\}/d' \
	    -e '/^\.i[fe] \\nh /d' \
	    -e 's/^\.el *\(.*\)$$/\1/' \
	    -e 's/^\.if !\\nh *\(.*\)$$/\1/' \
			> ftnchek$(manext) ; \
	else \
	  echo "$(SOELIM) not available: cannot make cleaned-up manpage ftnchek$(manext)." ; \
	  echo "You must use the catman documentation (provided separately)." ; \
	fi

# .doc files are ascii text form of documentation.
.man.doc:
	$(TBL) $< | $(NROFFPLAIN) -man | $(COL) > $@

# ftnchek.ps is PostScript form of documentation.  For ftnchek.ps we use
# cleaner ftnchek.1 rather than ftnchek.man.
ftnchek.ps:	ftnchek$(manext)
	$(TBL) <ftnchek$(manext) | $(EQN) | $(MANtoPS) >ftnchek.ps

# Other man files are clean enough as they are.
.man.ps:
	$(TBL) < $< | $(EQN) | $(MANtoPS) > $@

# $(HTMLDIR)/toc.html represents all the files in the html directory.  They
# are built from ftnchek.html by the script make_html.sh whenever
# ftnchek.html changes.  Note: edits should be done to ftnchek.man if
# they affect content, to ftnchek.html if they affect html form.  Do
# not edit anything in html directory.

htmldocs: $(HTMLDIR)/toc.html

$(HTMLDIR)/toc.html: ftnchek.html
	./make_html.sh ftnchek.html

# ftnchek.html is produced from ftnchek.1 by MANtoHTML followed by a
# simple script to add internal links to option descriptions, then
# lightly edited.  Edits were initially by hand, now are saved in
# ftnchek.html.patch (not distributed) to be re-applied each time.
# Any time new edits are done to ftnchek.html, the patch file should
# be remade.  Also make ftnchek.html.patch after editing ftnchek.man,
# so that the patch offsets don't get too large for patch to succeed.

ftnchek.html:	ftnchek.html.orig
	$(CP) ftnchek.html.orig ftnchek.html
	if test -f ftnchek.html.patch ; \
	then \
	   $(PATCH) < ftnchek.html.patch ; \
	fi

ftnchek.html.orig: ftnchek$(manext)
	$(MANtoHTML) ftnchek$(manext) | ./add_html_refs.sh > ftnchek.html.orig

ftnchek.html.patch: ftnchek.html.orig ftnchek.html
	@echo "It is normal for the next command to report an error"
	-$(DIFF) -c ftnchek.html.orig ftnchek.html > ftnchek.html.patch

# blurb.txt is an ascii file for informational mailings.
blurb.txt:	ftnchek.man
	$(TBL) ftnchek.man | $(NROFFPLAIN) -man -rb1 | $(COL) >blurb.txt

# ftnchek.hlp is a VMS HELP library source document:
# create ftnchek.hlb with $ LIBR/CREATE/HELP FTNCHEK.HLB FTNCHEK.HLP
# The leading and trailing newlines in ftnchek.hlp should be removed.
ftnchek.hlp:	ftnchek.man
	$(SED) -e '1d' ftnchek.man | \
	$(TBL) | $(NROFFPLAIN) -man -rh1 | $(COL) | \
	$(SED) -e 's/^-\([a-zA-Z][a-zA-Z]*\)/\/\1/' \
	    -e 's/\([^a-zA-Z]\)-\([a-zA-Z][a-zA-Z]*\)/\1\/\2/g' \
	>ftnchek.hlp


# Rebuild average.out when version changes.  (We don't put the
# dependency on ftnchek to avoid building ftnchek just for docs.)
average.out: ftnchek.h
	$(FTNCHEK) -list -symtab average > average.out

# Install program and documentation on system.  Obsolete fcl2vcg script
# & doc is removed if present.  Old program is first deleted, in case
# it is a hard link to specific previous version, so that version does
# not get overwritten.
install:	install-exe install-man install-lisp

install-exe:	ftnchek$(EXE) dcl2inc$(CMD)
	-$(RM) $(bindir)/ftnchek$(EXE)
	-$(MKDIR) -p $(bindir)
	$(CP) ftnchek$(EXE) $(bindir)
	-$(STRIP) $(bindir)/ftnchek$(EXE)
	$(CHMOD) 755 $(bindir)/ftnchek$(EXE)
	-$(MKDIR) -p $(libdir)
	$(CP) dcl2inc.awk $(libdir)/dcl2inc.awk
	$(CHMOD) 644 $(libdir)/dcl2inc.awk
	$(CP) dcl2inc$(CMD) $(bindir)/dcl2inc$(CMD)
	$(CHMOD) 755 $(bindir)/dcl2inc$(CMD)
	-$(RM) $(bindir)/fcl2vcg

# Install man pages, taking care to remove old formatted ones, because
# many man implentations fail to compare time stamps of raw and
# formatted files, and will show out-of-date formatted files.
install-man: ftnchek$(manext)
	-$(MKDIR) -p $(mandir)/man1
	$(CP) dcl2inc.man $(mandir)/man1/dcl2inc$(manext)
	-$(RM) $(mandir)/cat1/dcl2inc$(manext)
	$(CHMOD) 644 $(mandir)/man1/dcl2inc$(manext)
	$(CP) ftnchek$(manext) $(mandir)/man1/ftnchek$(manext)
	-$(RM) $(mandir)/cat1/ftnchek$(manext)
	$(CHMOD) 644 $(mandir)/man1/ftnchek$(manext)
	-$(RM) $(mandir)/man1/fcl2vcg$(manext)
	-$(RM) $(mandir)/cat1/fcl2vcg$(manext)

# IRIX uses pre-formatted, packed man pages and nroff is not bundled with it.
install-man-sgi: catman
	if $(PACK) dcl2inc.cat ; \
	then \
		$(MV) dcl2inc.cat.z $(mandir)$(sgimansubdir)/dcl2inc.z ; \
		$(CHMOD) 644 $(mandir)$(sgimansubdir)/dcl2inc.z ; \
	fi
	if $(PACK) ftnchek.cat ; \
	then \
		$(MV) ftnchek.cat.z $(mandir)$(sgimansubdir)/ftnchek.z ; \
		$(CHMOD) 644 $(mandir)$(sgimansubdir)/ftnchek.z ; \
	fi
	-$(RM) $(mandir)/fcl2vcg.z

# The catman target makes formatted ("cat") versions of the manpages
# for use in install-man-sgi.  These files are not in the standard
# distribution but are available separately (with suffix catman) for
# sites that do not have nroff.  If this Unix does not have nroff,
# then if user has obtained the catman versions, use them.  Otherwise
# inform them and use the flat ascii files as fallback.
catman: dcl2inc.cat ftnchek.cat

.man.cat:
	@if test -x $(TBL) -a  -x $(NROFF) ; then \
	  echo '$(TBL) $< | $(NROFF) -man > $@' ; \
	  $(TBL) $< | $(NROFF) -man > $@ ; \
	else \
	  if test -f $*.catman ; then \
	    echo cp $*.catman $@ ; \
	    cp $*.catman $@ ; \
	  else \
	    echo "--> No catman documentation found -- see INSTALL." ; \
	    echo "Using plain text documentation instead." ; \
	    echo cp $*.doc $@ ; \
	    cp $*.doc $@ ; \
	  fi ; \
	fi

#  The emacs lisp file will be installed only if lispdir exists.  It will
#  be byte-compiled if emacs is present.
install-lisp:
	@if test -d "$(lispdir)" ; \
	then \
	  echo $(CP) ftnchek.el $(lispdir)/ftnchek.el ; \
	  if $(CP) ftnchek.el $(lispdir)/ftnchek.el ; \
	  then \
	     if test -x "$(EMACS)" ; \
	     then \
	       $(EMACS) -batch -f batch-byte-compile $(lispdir)/ftnchek.el ; \
	     else \
	       echo "If desired, use emacs to byte-compile $(lispdir)/ftnchek.el"; \
	     fi \
	  fi \
	else \
	  echo "$(lispdir) does not exist -- ftnchek.el not installed." ; \
	  echo "If you want to install ftnchek.el, create $(lispdir)" ; \
	  echo "or re-run make install with 'lispdir=path-to-site-lisp'" ; \
	fi

# Remove everything that the install target installed.
uninstall:
	-$(RM) $(bindir)/dcl2inc$(CMD)
	-$(RM) $(bindir)/ftnchek$(CMD)
	-$(RM) $(libdir)/dcl2inc.awk
	-$(RM) $(mandir)/cat1/dcl2inc$(manext)
	-$(RM) $(mandir)/cat1/ftnchek$(manext)
	-$(RM) $(mandir)/dcl2inc.z $(mandir)/ftnchek.z # SGI
	-$(RM) $(mandir)/man1/dcl2inc$(manext)
	-$(RM) $(mandir)/man1/ftnchek$(manext)
	-$(RM) $(lispdir)/ftnchek.el
	-$(RMDIR) $(libdir)

# WARNING: do NOT execute this target, unless you have nroff/troff or groff
# to recreate the formatted documentation files.
spotless:	distclean
	$(RM) blurb.txt
	$(RM) dcl2inc.doc ftnchek.doc
	$(RM) dcl2inc.ps ftnchek.ps
	$(RM) ftnchek.hlp

# ex and vi editor tags file
tags:	$(SRCS)
	$(CTAGS) $(CTAGSFLAGS) $(SRCS)

# emacs editor tags file
TAGS:	$(SRCS)
	$(ETAGS) $(SRCS)

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

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

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

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

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

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

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

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

ftnchek.o:	config.h ftnchek.h intrins.h options.h utils.h

include.o:	config.h ftnchek.h symtab.h forlex.h advance.h

intake.o:	config.h ftnchek.h symtab.h tokdefs.h forlex.h advance.h

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

iokeywds.o:	config.h ftnchek.h symtab.h tokdefs.h iokeywds.h iokeywds_enum.h utils.h

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

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

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

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

makehtml.o:     config.h ftnchek.h plsymtab.h symtab.h tokdefs.h advance.h

message.o:	config.h ftnchek.h

options.o:	config.h ftnchek.h options.h utils.h

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

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

prlists.o:	config.h ftnchek.h symtab.h symutils.h

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

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

symspace.o:	config.h ftnchek.h symtab.h symspace.h symutils.h

symtab.o:	config.h ftnchek.h iokeywds.h intrins.h symtab.h \
		symspace.h symutils.h tokdefs.h

symutils.o:	config.h ftnchek.h symtab.h symutils.h

utils.o:	config.h utils.h

#=======================================================================
# The configure.generic script creates generic versions of CONFIGURED_FILES
# for users on deficient Unix systems or using GNU software on non-Unix
# platforms.  It tries to put reasonably generic values in for all the
# things that the configure script is supposed to handle.  Pathnames
# are removed since these may vary wildly.  The rule also checks for
# any unsubstituted items indicating configure.generic needs to be
# updated.  The config-generic.h produced here should need few if any
# changes to serve as config.h on most recent 32-bit systems.
# This target has no dependencies since its purpose is
# to replace the developer's configured versions with the generic ones,
# regardless of whether the .in files have changed.  Note that
# makefile.generic.in and config-generic.h.in are treated specially:
# they are copies of Makefile.in and config.h.in respectively, but the
# generic configured versions are not named Makefile and config.h, because
# these are deliberately left out of the distribution.
generic-config:
	$(CP) Makefile.in makefile.generic.in
	$(CP) config.h.in config-generic.h.in
	./configure.generic $(CONFIGURED_FILES)
	$(RM) makefile.generic.in
	$(RM) config-generic.h.in
	chmod +x dcl2inc test/Compare.sh
	@if $(GREP) \
	   '@[^*@]*@' $(CONFIGURED_FILES) ; \
	then \
	    echo '####################################################' ; \
	    echo '## FIX configure.generic TO SUBSTITUTE THE ABOVE. ##' ; \
	    echo '####################################################' ; \
	fi

# Here we provide rules for making the two CONFIGURED_FILES that are
# not generated by "configure".  This is mainly a convenience for the
# new developer since it is not so obvious where they come from.  They
# are not needed for development but only for the distribution.  They
# are normally made by generic-config.
makefile.generic: Makefile.in
	$(CP) Makefile.in makefile.generic.in
	./configure.generic makefile.generic
	$(RM) makefile.generic.in

config-generic.h: config.h.in
	$(CP) config.h.in config-generic.h.in
	./configure.generic config-generic.h
	$(RM) config-generic.h.in

#=======================================================================
#  This target warns if VMS build command files are out of date.  The sed
#  command concatenates continuation lines, marked by "-" as last character.
checkvmsbuild:
	@-for obj in $(OBJS:.o=) ; \
	do \
	  for com in build.com build-vax.com ; \
	  do \
	    if grep -q "^\$$ @CC.* $$obj[	 ]" $$com ; \
	    then true; else \
		echo "Source $$obj missing from CC in $$com" ; \
	    fi ; \
	    if sed -e ':CAT' -e '/-$$/N'  -e 's/-\n//' -e tCAT \
		   -e s/$$/,/ $$com | \
		grep -q "^\$$ @LINK.*[ ,]$$obj," ; \
	    then true; else \
		echo "Object $$obj missing from LINK in $$com" ; \
	    fi ; \
	  done; \
	done

# Target to make sure the DOS versions of test master files are
# up to date
dosokay:
	cd $(TESTDIR); $(MAKE) dosokay

#=======================================================================
# Making the distribution tar file.  Dirname is name of current
# directory.  Makefile is not distributed because it is supposed
# to be created by local configure.  Files to archive are explicitly
# named so that detritus from development will not be accidentally
# included.  However, test files are not listed separately so one
# should make clean in $(TESTDIR)/ first.
#
# This target assumes GNU tar for the --exclude option.  If you don't
# have it, remove test/Makefile manually and use ``make tar TAR_EXCLUDE=''

TAR_EXCLUDE	= --exclude $$dirname/$(TESTDIR)/Makefile

tar:
	dirname=`$(PWD_PROG)|$(SED) 's%.*/%%'` ; cd .. ; \
	  $(TAR) -cf $$dirname.tar $(TAR_EXCLUDE) \
	  `echo " "$(DISTFILES) | $(SED) "s% % $$dirname/%g"`

#  This target is for maintainer: generates the catman tar file for separate
#  distribution.
catman.tar: $(CATMAN)
	dirname=`$(PWD_PROG)|$(SED) 's%.*/%%'` ; \
	$(TAR) -cf ../$$dirname.catman.tar $(CATMAN)

.cat.catman:
	$(CP) $< $@

#  Make a distribution zipfile for MS-DOS/Windows/OS2.  The -l changes \n
#  to \r\n.  Then binary files and text files that already have \r\n are
#  replaced in binary mode.
#  Note that unlike tar, zip file names are relative to current directory.
#  Rule renames ftnchek-x.x.x to ftnchek-x_x_x for zip and lsm files.
zip:
	dirname=`$(PWD_PROG)|$(SED) 's%.*/%%'` ; \
	dosname=`echo $$dirname|$(SED) -e 's/\./_/g'` ; \
	$(CP) $$dirname.lsm $$dosname.lsm ; \
	dirname=$$dosname ; \
	$(RM) ../$$dirname.zip ; \
	$(ZIPTEXT) -r ../$$dirname.zip $(ZIPFILES) ; \
	$(ZIP)     ../$$dirname.zip $(BINARY_ZIPFILES)

# Targets that should be freshened prior to making tar (so I don't put
# stale ones into the distribution).
pretar:	docs generic-config clean testclean checkvmsbuild dosokay