One problem that might be encountered on big projects is that many operating systems limit the length of the command line. It is thus hard to give gnatmake the list of source and object directories.
This example shows how you can set up environment variables, which will make gnatmake behave exactly as if the directories had been specified on the command line, but have a much higher length limit (or even none on most systems).
It assumes that you have created a list of directories in your Makefile, using one of the methods presented in 17.2 Automatically Creating a List of Directories. For the sake of completeness, we assume that the object path (where the ALI files are found) is different from the sources patch.
Note a small trick in the Makefile below: for efficiency reasons, we create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are expanded immediately by make. This way we overcome the standard make behavior which is to expand the variables only when they are actually used.
# In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH.
# This is the same thing as putting the -I arguments on the command line.
#  only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH).
# You can of course have different values for these variables.