A typical development cycle when working on an Ada program consists of the following steps:
Edit some sources to fix bugs.
Add enhancements.
Compile all sources affected.
Re-bind and re-link.
Test.
The third step can be tricky, because not only do the modified files have to be compiled, but any files depending on these files must also be recompiled. The dependency rules in Ada can be quite complex, especially in the presence of overloading, use clauses, generics and in-lined subprograms.
gnatmake automatically takes care of the third and fourth steps of this process. It determines which sources need to be compiled, compiles them, and binds and links the resulting object files.
Unlike some other Ada make programs, the dependencies are always accurately recomputed from the new sources. The source based approach of the XGC Ada compilation model makes this possible. This means that if changes to the source program cause corresponding changes in dependencies, they will always be tracked exactly correctly by gnatmake.
The gnatmake command has the form:
The only required argument is unit_or_file_name, which specifies the compilation unit that is the main program. There are two ways to specify this:
By giving the lowercase name of the compilation unit (gnatmake unit). In this case gnatmake will use the switches {-aIdir} and {-Idir} to locate the appropriate file.
By giving the name of the source containing it (gnatmake [dir/]file.adb). If no relative or absolute directory dir is specified, the input source file will be searched for in the directory where gnatmake was invoked. gnatmake will not use the switches {-aIdir} and {-Idir} to locate the source file.
All gnatmake output (except when you specify -M) is to stderr. The output produced by the -M switch is send to stdout.