When using a project file, you can invoke gnatmake with one or several main subprograms, by specifying their source files on the command line.
gnatmake ^-P^/PROJECT_FILE=^prj main1.adb main2.adb main3.adb
Each of these needs to be a source file of the same project, except when the switch ^-u^/UNIQUE^ is used.
When ^-u^/UNIQUE^ is not used, all the mains need to be sources of the
same project, one of the project in the tree rooted at the project specified
on the command line. The package
Builder of this common project, the
"main project" is the one that is considered by gnatmake.
When ^-u^/UNIQUE^ is used, the specified source files may be in projects
imported directly or indirectly by the project specified on the command line.
Note that if such a source file is not part of the project specified on the
command line, the ^switches^switches^ found in package
Builder of the
project specified on the command line, if any, that are transmitted
to the compiler will still be used, not those found in the project file of
the source file.
When using a project file, you can also invoke gnatmake without
explicitly specifying any main, and the effect depends on whether you have
Main attribute. This attribute has a string list value,
where each element in the list is the name of a source file (the file
extension is optional) that contains a unit that can be a main subprogram.
Main attribute is defined in a project file as a non-empty
string list and the switch ^-u^/UNIQUE^ is not used on the command
line, then invoking gnatmake with this project file but without any
main on the command line is equivalent to invoking gnatmake with all
the file names in the
Main attribute on the command line.
project Prj is for Main use ("main1.adb", "main2.adb", "main3.adb"); end Prj;
With this project file,
is equivalent to
"gnatmake ^-Pprj^/PROJECT_FILE=PRJ^ main1.adb main2.adb main3.adb".
When the project attribute
Main is not specified, or is specified
as an empty string list, or when the switch -u is used on the command
line, then invoking gnatmake with no main on the command line will
result in all immediate sources of the project file being checked, and
potentially recompiled. Depending on the presence of the switch -u,
sources from other project files on which the immediate sources of the main
project file depend are also checked and potentially recompiled. In other
words, the -u switch is applied to all of the immediate sources of the
main project file.
When no main is specified on the command line and attribute
and includes several mains, or when several mains are specified on the
command line, the default ^switches^switches^ in package
be used for all mains, even if there are specific ^switches^switches^
specified for one or several mains.
But the ^switches^switches^ from package
Linker will be
the specific ^switches^switches^ for each main, if they are specified.