LF Fortran 95

Building Multiple Targets

This example makefile builds a program that directly uses two modules and also links to a library. If the library is out of date, it is updated and the program is relinked. The build process must also make sure that any out of date module is recompiled as well as the procedure that uses it, in the proper order. This makefile depends on the definitions shown in the TOOLS.INI file described in the above section, and assumes that the TOOLS.INI file is either in the current directory, or pointed to by the INIT environment variable.

OBJS = main.obj mod1.obj mod2.obj TARGET = main.exe FLIB = LIB LIBSRCS = one.f90 two.f90 three.f90 LIBTARGET = foo.lib $(TARGET) : $(OBJS) $(LIBTARGET) $(FC) $(OBJS) $(LIBTARGET) -out $@ main.obj : mod1.obj mod2.obj main.f90 mod2.obj : mod2.f90 mod1.obj : mod1.f90 $(LIBTARGET) : $(LIBSRCS) $(FC) $? -out $@

See Also