Now that our project files are written, let's build our executable. Here is the command we would use from the command line:
gnatmake ^-Pbuild^/PROJECT_FILE=build^
This will automatically build the executables specified through the Main attribute: for each, it will compile or recompile the sources for which the object file does not exist or is not up-to-date; it will then run the binder; and finally run the linker to create the executable itself.
gnatmake only knows how to handle Ada files. By using
gprbuild as a builder, you could automatically manage C files the
same way: create the file utils.c in the common directory,
set the attribute Languages to "(Ada, C)"
, and run
gprbuild ^-Pbuild^/PROJECT_FILE=build^
Gprbuild knows how to recompile the C files and will recompile them only if one of their dependencies has changed. No direct indication on how to build the various elements is given in the project file, which describes the project properties rather than a set of actions to be executed. Here is the invocation of gprbuild when building a multi-language program:
$ gprbuild -Pbuild gcc -c proc.adb gcc -c pack.adb gcc -c utils.c gprbind proc ... gcc proc.o -o proc
Notice the three steps described earlier:
The default output of GPRbuild's execution is kept reasonably simple and easy
to understand. In particular, some of the less frequently used commands are not
shown, and some parameters are abbreviated. So it is not possible to rerun the
effect of the gprbuild command by cut-and-pasting its output. GPRbuild's option
-v
provides a much more verbose output which includes, among other
information, more complete compilation, post-compilation and link commands.