Back: Automake Conditionals
Forward: Automatic dependency tracking
 
FastBack: Automatic dependency tracking
Up: Advanced GNU Automake Usage
FastForward: A Complex GNU Autotools Project
Top: Autoconf, Automake, and Libtool
Contents: Table of Contents
Index: Index
About: About this document

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:

 
SUFFIXES = .m

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
.m.o:
        $(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.


This document was generated by Gary V. Vaughan on February, 8 2006 using texi2html