Next: , Previous: , Up: Format of Makefile.am   [Contents][Index]

5.1.5 Automake include directive

Automake supports an include directive that can be used to include other Makefile fragments when automake is run. Note that these fragments are read and interpreted by automake, not by make. As with conditionals, make has no idea that include is in use.

There are two forms of include:

include $(srcdir)/file

Include a fragment that is found relative to the current source directory.

include $(top_srcdir)/file

Include a fragment that is found relative to the top source directory.

Note that if a fragment is included inside a conditional, then the condition applies to the entire contents of that fragment.

Inside a fragment, the construct %reldir% is replaced with the directory of the fragment relative to the base Makefile.am. Similarly, %canon_reldir% is replaced with the canonicalized (see Other Automake variables) form of %reldir%. As a convenience, %D% is a synonym for %reldir%, and %C% is a synonym for %canon_reldir%.

A special feature is that if the fragment is in the same directory as the base Makefile.am (i.e., %reldir% is .), then %reldir% and %canon_reldir% will expand to the empty string as well as eat, if present, a following slash or underscore respectively.

Thus, a makefile fragment might look like this:

bin_PROGRAMS += %reldir%/mumble
%canon_reldir%_mumble_SOURCES = %reldir%/one.c