If you work on a program by compiling single components at a time using
gcc, you typically keep track of the units you modify. In order to
build a consistent system, you compile not only these units, but also any
units that depend on the units you have modified.
For example, in the preceding case,
if you edit gmain.adb, you only need to recompile that file. But if
you edit greetings.ads, you must recompile both
greetings.adb and gmain.adb, because both files contain
units that depend on greetings.ads.
gnatbind will warn you if you forget one of these compilation
steps, so that it is impossible to generate an inconsistent program as a
result of forgetting to do a compilation. Nevertheless it is tedious and
error-prone to keep track of dependencies among units.
One approach to handle the dependency-bookkeeping is to use a
makefile. However, makefiles present maintenance problems of their own:
if the dependencies change as you change the program, you must make
sure that the makefile is kept up-to-date manually, which is also an
gnatmake utility takes care of these details automatically.
Invoke it using either one of the following forms:
$ gnatmake gmain.adb $ gnatmake gmain
The argument is the name of the file containing the main program;
you may omit the extension.
examines the environment, automatically recompiles any files that need
recompiling, and binds and links the resulting set of object files,
generating the executable file, gmain.
In a large program, it
can be extremely helpful to use
gnatmake, because working out by hand
what needs to be recompiled can be difficult.
takes into account all the Ada 95 rules that
establish dependencies among units. These include dependencies that result
from inlining subprogram bodies, and from
generic instantiation. Unlike some other
Ada make tools,
gnatmake does not rely on the dependencies that were
found by the compiler on a previous compilation, which may possibly
be wrong when sources change.
gnatmake determines the exact set of
dependencies from scratch each time it is run.