fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

WRITE MAKEFILE

Syntax:

[DO NOT] WRITE MAKEFILE[S] [DO NOT] MAKE MAKEFILE[S] MKMF

Function:

FPT writes a Makefile for each program in the project. The Makefile contains compilation and linking commands and describes the dependencies on include files and Fortran modules. The Makefiles are named Makefile_<program_name> and have no file name extensions. The format is compatible with gnu make. They are written to the primary output directory.

Compilation switches for the primary Fortran files may optionally be specified in the fsp file. The file name may be followed by the keyword FCFLAGS= followed by the compilation switches written as a quoted string. The switches may be specified explicitly or as a symbol, for example:

ball_main.f90 FCFLAGS="-c -O0" ball_dynamic.f90 FCFLAGS="$(FLAGS_OPTIMISE)"

If no specification is made for the compilation flags, fpt uses the default symbolic name $(FCFLAGS)

The Makefile begins with an include statement for the file compiler.make. This file is supplied by the user and contains definitions of the symbols::

  1. FC which is the Fortran compiler.
  2. LN which is the linker.
  3. FCFLAGS which specifies the default compilation flags. The default flags may be overriddem by specifications in the .fsp file as described above.
  4. ADDITIONAL_OBJECTS which are additional objects and libraries required for the link.
  5. Definitions of any other symbolic compilation flags specified in compiler.make or the fsp file.

Where to Use this Command

Operating system command line Yes
Configuration file, config.fsp Yes
Specification (fsp) files, *.fsp Yes
Interactively, to FPT> prompt Yes
Interactive command files Yes
Embedded in the Fortran code Yes

Default

Makefiles are not generated by default (Note that defaults may be changed in the configuration file).

Examples

The file ball.fsp is set up for a model of a cannon ball. There are four primary files, three of which, ball_init.f90, ball_dynamic.f90 and ball_terminal.f90 include two INCLUDE files.

! ball.fsp 13-Jan-17 John Collins % input directory ..\original_source % primary input file name extension: ".f90" % include input file name extension: ".i90" % free format input ball_main.f90 FCFLAGS="-c -O0" ball_init.f90 ball_dynamic.f90 FCFLAGS="$(FLAGS_OPTIMISE)" ball_terminal.f90 % free format output % lower case symbols % space before "::" % space after "::" % space before "=" % space after "=" % keep file name extensions % output directory ..\build % overwrite changed files % make makefile ! End of ball.fsp

Note that compilation flags are specified explicitly for ball_main.f90 and symbolically for ball_dynamic.f90. The fsp file contains the command %make makefile.

The Makefile generated is shown below:

# ***************************************************************************** # File: ..\BUILD\\Makefile # Output by fpt 4.1-b Win32 On 13-JAN-17 At 15:32:05 # Licensee: SimCon: Development version. # ***************************************************************************** include compiler.make ball_main.exe: \ ball_main.o \ ball_init.o \ ball_dynamic.o \ ball_terminal.o $(LN) -o ball_main.exe \ 'ball_main.o' \ 'ball_init.o' \ 'ball_dynamic.o' \ 'ball_terminal.o' \ $(ADDITIONAL_OBJECTS) ball_main.o: E:\Users\john\ball\build\ball_main.f90 $(FC) -c -O0 '$<' ball_init.o: E:\Users\john\ball\build\ball_init.f90 \ E:\Users\john\ball\build\ic.i90 \ E:\Users\john\ball\build\coords.i90 $(FC) $(FCFLAGS) '$<' ball_dynamic.o: E:\Users\john\ball\build\ball_dynamic.f90 \ E:\Users\john\ball\build\ic.i90 \ E:\Users\john\ball\build\coords.i90 $(FC) $(FLAGS_OPTIMISE) '$<' ball_terminal.o: E:\Users\john\ball\build\ball_terminal.f90 \ E:\Users\john\ball\build\ic.i90 \ E:\Users\john\ball\build\coords.i90 $(FC) $(FCFLAGS) '$<' # End of Makefile *************************************************************

Note that the dependencies of the executable on the objects and of the objects on the INCLUDE files are represented. fpt also tracks USE dependencies on and between Fortran modules.

Note also that file names in the link command and the specification $< are enclosed in quotes. This protects the names, which may contain $ characters from interpretation by the shell. Where appropriate, $ characters in names are doubled for the same reason.

The file compiler.make is supplied by the user. In this case it is:

# compiler.make 14-Jan-17 John Collins # ============================================================================= LN=gfortran FC=gfortran # Default value of flags FCFLAGS=-c -O0 -ffree-form FLAGS_OPTIMISE =-c -O3 -ffree-form # end of compiler.make ========================================================

Copyright ©1995 to 2022 Software Validation Ltd. All rights reserved.