Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Use Makefiles for Compilation

This topic describes the use of makefiles to compile your application. You can use makefiles to specify a number of files with various paths, and to save this information for multiple compilations.

Linux

To run make from the command line using the compiler, make sure that /usr/bin and /usr/local/bin are in your PATH environment variable.

If you use the C shell, you can edit your .cshrc file and add the following:

setenv PATH /usr/bin:/usr/local/bin:$PATH

Then you can compile using the following syntax:

make -f yourmakefile

Where -f is the make command option to specify a particular makefile name.

Windows

To use a makefile to compile your source files, use the nmake command. For example, if your project is your_project.mak, you can use the following syntax:

Example:

nmake /f [makefile_name.mak] FPP=[compiler_name] LINK32=[linker_name]
For example:
nmake /f your_project.mak FPP=ifx LINK32=xilink

Argument

Description

/f

The nmake option to specify a makefile.

your_project.mak

The makefile used to generate object and executable files.

FPP

The preprocessor/compiler that generates object and executable files. (The name of this macro may be different for your makefile.)

LINK32

The linker that is used.

The nmake command creates object files (.obj) and executable files () from the information specified in the your_project.mak makefile.

Generate Build Dependencies for Compilation

Use the gen-dep compiler option to generate build dependencies for compilation.

Build dependencies include a list of all files included with INCLUDE statements and .mod files accessed with USE statements. The resulting output can be used to create a makefile to with the appropriate dependencies resolved.

Consider a source file that contains the following:

 module b
 	include 'gendep001b.inc'
 	end module b

 	program gendep001
 	use b
 	a_global = b_global
end

When you compile the source using the gen-dep option, the following output is produced:

 b.mod : \
 	gendep001.f90
gendep001.obj : \
 	gendep001.f90 gendep001b.inc

This output indicates that the generated file, b.mod, depends on the source file, gendep001.f90. Similarly, the generated file, gendep001.obj, depends on the files, gendpe001.f90 and gendep001b.inc.