PSCF v1.3.1
Build System Files (Overview)

Make and Makefiles (Prev)         Configuration (config.mk) Files (Next)

This file briefly discusses the contents and purpose of different types of makefiles and makefile fragments that are used in the PSCF build system. All files with a filename extension .mk are makefile fragments that are included into makefiles via the make include directive.

File locations

After the configure script is run, but before any source files are compiled, the following types of makefiles and makefile fragments exist in different levels of the src directory tree:

  • The root of the src directory contains a makefile and a file named config.mk
  • Each namespace-level subdirectory of the src directory tree contains a makefile and files named sources.mk and patterns.mk
  • Every subdirectory of the src directory tree that contains compilable source files contains a makefile and a file named sources.mk

In addition, PSCF root directory contains a makefile at this point.

Before the configure script is run, there are not any makefiles or makefile fragments in the bld directory. After the configure script is run, the following types of files will exist in the bld directory tree:

  • The root of the bld directory tree will contains a makefile and a file named config.mk
  • Each namespace-level subdirectory of the bld directory will contains a makefile

The configure script installs the config.mk files in both the src and bld directory, and installs all of the makefiles in the bld directory. The configure script also installs a bash script named "setopts" in the bld directory, by copying the corresponding script in the src directory.

Compilation leads to creation of additional intermediate object, dependency and library files in either the src directory (for in-source compilation) or the bld directory (for out-of-source) compilation, as discussed previously. Each dependency files is a short makefile fragments that can be included into makefiles.

Makefile fragment file types

The names and contents of different types of makefile fragments used in the build system are summarized in the table below:

Type Filename Contents
configuration config.mk configuration file, defines global variables
source list sources.mk list source files and object file targets
pattern rule patterns.mk pattern rules for object files targets
dependency *.d list prerequisites of a single *.o target

Each of these types of file is described in a bit more detail below, and then in greater detail in subsequent pages about different types of file:

  • Configuration (config.mk) Files : Makefile fragments named config.mk that are installed in the bld and src directory are configuration files that assign values to makefile variables that are used in other build system files. Among these are variables whose values give paths to the PSCF root directory and some of its main subdirectories, variables that specify command line options for the compiler, and variables that enable or disable particular features.
  • Source List (sources.mk) Files : The makefile fragment named sources.mk in each directory in the src directory tree defines a pair of makefile variables whose values are, respectively, a list of all of the compilable source files in that directory and all of its subdirectories, and a list of all of the corresponding object file targets. Each source list file in a namespace-level directories also defines a rule to construct a static library.
  • Pattern Rule (patterns.mk) Files : The makefile fragment named patterns.mk in each namespace-level subdirectory of src contains pattern rules that are used to compile all *.cpp and *.cu source files located in that directory and its subdirectories.
  • Dependency (*.d) Files : The *.d dependency file that is created whenever a source file is compiled contains a single makefile rule that lists all of the required prerequisites of the associated object file, with no associated recipe.

Every makefile within a namespace-level subdirectory of the src or bld directory includes a single config.mk configuration file, a single patterns.mk pattern rule file, one or more sources.mk source list files, and multiple *.d dependency files.


Make and Makefiles (Prev)        Build System (Up)         Configuration (config.mk) Files (Next)