Using Multiple directives.mf Files

You can use multiple directives.mf files to compile using general directives for all files or file types and more specific directives to one or more file subsets.

As it executes, each compiler creates a list of directives based on those defined in directives.mf files located in a hierarchy of directories. First, the compiler looks in the current directory for a directives.mf file marked as @root (see Creating a directives.mf File for details). If not found there, the compiler continues searching in the parent directory, and then on up the hierarchy of directories until it finds the root file, which is typically found at the top level of the source code hierarchy. This establishes the set of subdirectories to use when compiling and the order in which to access additional directives.mf files. The directives found in the root directives.mf file are added to the list, as are the directives found in the directives.mf file in each subdirectory down to the current directory. When the same directive is found to be set in more than one directives.mf file, the last one encountered overrides all other settings.

For example, if your COBOL applications are divided between accessing DB2 and SQL Server databases, you could divide your source files into subdirectories, grouped by which database is required, as follows:

Subdirectory File type Required directive
c:\repos\cobol\db2 COBOL accessing DB2 DB2
c:\repos\cobol\sql COBOL accessing SQL Server SQL

In the c:\repos\cobol\db2 subdirectory, add a directives.mf that contains the DB2 directive. In the c:\repos\cobol\sql subdirectory, add a directives.mf that contains the SQL directive.

To apply a single directive, such as DIALECT(MF), to all files in both subdirectories, add a directives.mf file marked as root and containing the DIALECT(MF) directive to the c:\repos\cobol directory.

Run the compiler from both the db2 and sql subdirectories. DB2 code is compiled with the DB2 and DIALECT(MF) directives, and SQL Server code is compiled with the SQL and DIALECT(MF) directives.