In our description in this chapter so far we have assumed the main program is in Ada and the task of the binder is to generate a corresponding function main to pass control to this Ada main program. XGC Ada also supports the building of executable programs where the main program is not in Ada, but some of the called routines are written in Ada and compiled using XGC Ada. The following switch is used in this situation:
No main program. The main program is not in Ada.
In this case, most of the functions of the binder are still required, but instead of generating a main program, the binder generates a file containing the following callable routines:
You must call this routine to initialize the Ada part of the program by calling the necessary elaboration routines. A call to adainit is required before the first call to an Ada subprogram.
You must call this routine to perform any library-level finalization required by the Ada subprograms. A call to adafinal is required after the last call to an Ada subprogram, and before the program terminates.
If the -n switch is given, more than one ALI file may appear on the command line for gnatbind. The normal closure calculation is performed for each of the specified units. Calculating the closure means finding out the set of units involved by tracing with references. The reason it is necessary to be able to specify more than one ALI file is that a given program may invoke two or more quite separate groups of Ada subprograms.
The binder takes the name of its output file from the first specified ALI file, unless overridden by the use of the -o file, The output file is a C source file, which must be compiled using the C compiler. This compilation occurs automatically as part of the gnatmake processing.