Sun Studio 12: Fortran Programming Guide

3.1.4 Overriding 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)
      f95 $(FFLAGS) $(OBJ) -lcore95 -lcore -lsunwindow \
      -lpixrect -o pattern
pattern.o: pattern.f commonblock
      f95 $(FFLAGS) -c pattern.f
computepts.o:
      f95 $(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 f95. Note that "FFLAGS=" can also be used on the command to reset the macro to a null string so that it has no effect.