.TI F77/MAKE "Sep. 4, 1985"
Make - A System for Program Development and Maintenance

The UNIX utility 'make' is a program development tool that greatly
enhances the construction and maintenance of moderate to large programs
in any language.

\&'Make' is used to find out which object files that a program depends on
are out of date, and to have them automatically recompiled.
To use 'make', you must describe the dependencies within the program in
a file called 'makefile' or 'Makefile'.  Here is a simple 'Makefile'
for a program 'prog' which is made from the source in 'main.f',
\&'sub1.f' and 'sub2.f':

.nf
	prog:	main.o sub1.o sub2.o
		f77 main.o sub1.o sub2.o -o prog
.fi

The first line describes the target, 'prog', and gives the name of
the three object files it depends on.  The second line tells how to
create the target file once the files it depends on are up to date.

\&'Make' requires that the target file name MUST start in column one and
the next line MUST start with a tab (control-I), not with blanks.

To use this makefile, type: 'make'.  Then 'make' will check that the
three object files exist and are more recent than the corresponding
source files; e.g. if 'main.f' was last changed on April 20, 5:02 and
\&'main.o' was last changed on April 20, 4:58, then 'make' will recompile
\&'main.f' to generate an up to date 'main.o'.  If however, 'main.o' is
more recent than 'main.f', it will not be recompiled.

Once the three files named on the first line are up to date, 'make'
checks whether any of them are newer than 'prog'.  If so, it
executes the next line to generate a new version of 'prog';
otherwise, it stops and reports 'prog' is up to date.

For this example, typing 'make' when the object files do not exist
results in:

.nf
	f77    -c main.f
	main.f:
	   MAIN:
	f77    -c sub1.f
	sub1.f:
	   sub1:
	f77    -c sub2.f
	sub2.f:
	   sub2:
	f77 main.o sub1.o sub2.o  -o doit
	Loading prog ...
.fi

If you type 'make' again:

	`prog' is up to date.

If you now edit 'main.f' and then type 'make':

.nf
	f77    -c main.f
	main.f:
	   MAIN:
	f77 main.o sub1.o sub2.o  -o doit
	Loading prog ...
.fi

\&'Make' only performs those steps that are needed to keep 'prog' up to date.
To see what 'make' would do without actually doing it, type 'make -n'.

Here is a more advanced 'Makefile'.  FFLAGS is a special string known
to 'make' in which you can specify f77 compilation flags; here '-g' is
specified to save the symbol table for use with the symbolic debugger.
OBJECTS and SOURCES are defined as lists of file names.

.nf
	FFLAGS = -g
	OBJECTS = main.o sub1.o sub2.o sub3.o sub4.o sub5.o
	SOURCES = main.f sub1.f sub2.f sub3.f sub4.f sub5.f

	prog:	$(OBJECTS)
		f77 -g $(OBJECTS) -o prog  -lf77plot -l4014

	main.o sub1.o:		block1.h
	sub2.o sub3.o sub4.o:	block2.h

	#	to print all the source on the line printer
	print: ; pr block1.h block2.h $(SOURCES) | lpr

	#	to remove all the object files and core dumps
	remove: ; rm -f $(OBJECTS) core
.fi

The linking line specifies the '-g' flag because FFLAGS is used automatically
only for compilations.
This makefile is for a graphics program which runs on a Tektronics 4014
terminal; thus the linking line
specifies \%'-lf77plot' for the f77 graphics interface
library (see "man 3f plot") and \%'-l4014' for the Tektronics 4014
plot library (see "man 3 plot").

The next two lines specify additional
dependencies; both 'main.o' and 'sub1.o' depend on the file 'block1.h'
and three object files depend on 'block2.h'.  These two files define
common blocks and are included via the 'include' statement (see "help
f77 style").  Now if 'block1.h' is changed, 'make' will
automatically recompile 'main.o' and 'sub1.o', and if 'block2.h' is
changed, the three object files depending on it will be recompiled.

The last lines define two new targets, 'print' and 'remove'.  A name is
designated as a target by appearing on a line starting in
column one.  The default when you type 'make' is to make the first
target.
Thus typing 'make' is equivalent to typing 'make prog'.
You can also type 'make print' which will cause all
the source files to be printed or 'make remove' to remove disk files
to save space.

For more on-line information on 'make', see "man make".  For more
extensive written documentation, see "A Guide for VAX UNIX Fortran
Users" and "Make -
A Program for Maintaining Computer Programs".
