[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.2 Language support

Automake comes with built-in knowledge of the most common compiled languages: C, C++, Objective C, Yacc, Lex, assembly, and Fortran. However, programs are sometimes written in an unusual language, or in a custom language that is translated into something more common. Automake lets you handle these cases in a natural way.

Automake’s notion of a ‘language’ is tied to the suffix appended to each source file written in that language. You must inform Automake of each new suffix you introduce. This is done by listing them in the ‘SUFFIXES’ macro. For instance, suppose you are writing part of your program in the language ‘M’, which is compiled to object code by a program named mc. The typical suffix for an ‘M’ source file is ‘.m’. In your ‘Makefile.am’ you would write:


This differs from ordinary make usage, where you would use the special .SUFFIX target to list suffixes.

Now you need to tell Automake (and make) how to compile a ‘.m’ file to a ‘.o’ file. You do this by writing an ordinary make suffix rule:

MC = mc
        $(MC) $(MCFLAGS) $(AM_MCFLAGS) -c $<

Note that we introduced the ‘MC’, ‘MCFLAGS’, and ‘AM_MCFLAGS’ variables. While not required, this is good style in case you want to override any of these later (for instance from the command line).

Automake understands enough about suffix rules to recognize that ‘.m’ files can be treated just like any file it already understands, so now you can write:

bin_PROGRAMS = myprogram
myprogram_SOURCES = foo.c something.m

Note that Automake does not really understand chained suffix rules; however, frequently the right thing will happen anyway. For instance, if you have a .m.c rule, Automake will naively assume that ‘.m’ files should be turned into ‘.o’ files – and then it will proceed to rely on make to do the real work. In this example, if the translation takes three steps—from ‘.m’ to ‘.x’, then from ‘.x’ to ‘.c’, and finally to ‘.o’—then Automake’s simplistic approach will break. Fortunately, these cases are very rare.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Ben Elliston on May 30, 2015 using texi2html 1.82.