Fortran Programming Guide

Overriding of Macro Values

The initial values of make macros can be overridden with command-line options to make. For example:


FFLAGS=-u 
OBJ = pattern.o computepts.o startupcore.o
pattern: $(OBJ)
      f77 $(FFLAGS) $(OBJ) -lcore77 -lcore -lsunwindow \
      -lpixrect -o pattern 
pattern.o: pattern.f commonblock
      f77 $(FFLAGS) -c pattern.f
computepts.o:
      f77 $(FFLAGS) -c computepts.f

Now a simple make command without arguments uses the value of FFLAGS set above. However, this can be overridden from the command line:


demo% make "FFLAGS=-u -O" 

Here, the definition of the FFLAGS macro on the make command line overrides the makefile initialization, and both the -O flag and the -u flag are passed to f77. Note that "FFLAGS=" can also be used on the command to reset the macro to a null string so that it has no effect.