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. Each Makefile is named Makefile_<program_name> and has no file name extension. The format is compatible with gnu make. The Makefiles 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.

An example copy of compiler.make is included in the main fpt installation directory in the file compiler.make.gfortran.

Paths of File Names

By default fpt writes the complete path in file names within makefiles and references the files in the fpt output directories. This behaviour may be modified by the command: EDIT FILE NAMES IN MAKEFILES. The editing commands are executed on all files in the order in which they are written. The commands are:

EDIT FILE NAMES IN MAKEFILES: USE RELATIVE PATHS

and

EDIT FILE NAMES IN MAKEFILES: REPLACE <string> BY <string>

Location of Object and Execuatble files

By default, it is assumed that the make command will be executed in a directory parallel to that which contains the project fsp files. All of the object, .mod and executable files will be written to this directory. The behaviour may be changed by the command COMPILE PRIMARY FILES IN SITU. When this command is made the objects, .mod files and executables are written to the same directories as the primary source files, and the paths specified for compilation and linking are modified accordingly. The editing commands for file names in Makefiles are suppressed when this command is made.

Dollar Characters

Under Linux and Unix dollar characters in file names are doubled to protect them from interpretation as symbol references. Dollar characters in user-defined symbols are not doubled when they are followed by the ( character. Please see the example project fpt/examples/t_edit_makefile for the way in which the editing commands may be used.

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 2024 Software Validation Ltd. All rights reserved.