Tailoring your compilation

To tailor a compilation to your needs, you can change a copy of the default configuration file and use it in various ways.

The configuration file /etc/cob2.cfg has sections, called stanzas, that begin cob2:, cob2_j:, and cob2_r:. To list these stanzas, use the command ls /usr/bin/cob2*. The resulting list shows these lines:

/usr/bin/cob2
/usr/bin/cob2_j
/usr/bin/cob2_r

The last two files are linked to the first one. The commands cob2, cob2_j, and cob2_r execute the same module; however, cob2 uses the cob2 stanza, cob2_j uses the cob2_j stanza, and so forth.

You can tailor your compilation by doing the following steps:

  1. Make a copy of the default configuration file /etc/cob2.cfg.
  2. Change your copy to support specific compilation requirements or other COBOL compilation environments.
  3. (Optional) Issue the cob2 command with the -# option to display the effect of your changes.
  4. Use your copy instead of /etc/cob2.cfg.

To selectively use a modified copy of the configuration file for a specific compilation, issue the cob2 (or cob2_j or cob2_r) command with the -F option. For example, to use /u/myhome/myconfig.cfg instead of /etc/cob2.cfg as the configuration file to compile myfile.cbl, issue this command:

cob2 myfile.cbl -F/u/myhome/myconfig.cfg

If you add your own stanza, such as mycob2, you can specify it with the -F option:

cob2 myfile.cbl -F/u/myhome/myconfig.cfg:mycob2

Or you can define a mycob2 command:

ln -s /usr/bin/cob2 /u/myhome/mycob2
mycob2 myfile.cbl -F/u/myhome/myconfig

Or you can add mycob2 to /etc/cob2.cfg:

ln -s /usr/bin/cob2 mycob2
mycob2 myfile.cbl

Whichever directory you name in the ln command (such as /u/myhome above) must be in your PATH environment variable.

For a list of the attributes in each stanza, see the related reference about stanzas. You can change any of the items. For example, to add a library to the list of libraries used by the linker, change the runlib2 attribute.