Notes on the Command Line (GNAT User’s Guide for Native Platforms)

#### 4.1.4 Notes on the Command Line ¶

This section contains some additional useful notes on the operation of the `gnatmake` command.

- If `gnatmake` finds no ALI files, it recompiles the main program and all other units required by the main program. This means that `gnatmake` can be used for the initial compile, as well as during subsequent steps of the development cycle.
- If you enter `gnatmake foo.adb`, where `foo` is a subunit or body of a generic unit, `gnatmake` recompiles `foo.adb` (because it finds no ALI) and stops, issuing a warning.
- In `gnatmake` the switch `-I` is used to specify both source and library file paths. Use `-aI` instead if you just want to specify source paths only and `-aO` if you want to specify library paths only.
- `gnatmake` will ignore any files whose ALI file is write-protected. This may conveniently be used to exclude standard libraries from consideration and in particular it means that the use of the `-f` switch will not recompile these files unless `-a` is also specified.
- `gnatmake` has been designed to make the use of Ada libraries particularly convenient. Assume you have an Ada library organized as follows: ‘obj-dir’ contains the objects and ALI files for of your Ada compilation units, whereas ‘include-dir’ contains the specs of these units, but no bodies. Then to compile a unit stored in `main.adb`, which uses this Ada library you would just type:

      $ gnatmake -aI`include-dir`  -aL`obj-dir`  main

- Using `gnatmake` along with the `-m (minimal recompilation)` switch provides a mechanism for avoiding unnecessary recompilations. Using this switch, you can update the comments/format of your source files without having to recompile everything. Note, however, that adding or deleting lines in a source files may render its debugging info obsolete. If the file in question is a spec, the impact is rather limited, as that debugging info will only be useful during the elaboration phase of your program. For bodies the impact can be more significant. In all events, your debugger will warn you if a source file is more recent than the corresponding object, and alert you to the fact that the debugging information may be out of date.