Next: , Previous: , Up: Building Programs and Libraries   [Contents][Index]


7.8 Automatic de-ANSI-fication

Although the GNU standards allow the use of ANSI C, this can have the effect of limiting portability of a package to some older compilers (notably SunOS).

Automake allows you to work around this problem on such machines by “de-ANSI-fying” each source file before the actual compilation takes place.

If the Makefile.am variable AUTOMAKE_OPTIONS (Changing Automake’s Behavior) contains the option ansi2knr then code to handle de-ANSI-fication is inserted into the generated Makefile.in.

This causes each C source file in the directory to be treated as ANSI C. If an ANSI C compiler is available, it is used. If no ANSI C compiler is available, the ansi2knr program is used to convert the source files into K&R C, which is then compiled.

The ansi2knr program is simple-minded. It assumes the source code will be formatted in a particular way; see the ansi2knr man page for details.

De-ANSI-fication support requires the source files ansi2knr.c and ansi2knr.1 to be in the same package as the ANSI C source; these files are distributed with Automake. Also, the package configure.in must call the macro AM_C_PROTOTYPES.

Automake also handles finding the ansi2knr support files in some other directory in the current package. This is done by prepending the relative path to the appropriate directory to the ansi2knr option. For instance, suppose the package has ANSI C code in the src and lib subdirs. The files ansi2knr.c and ansi2knr.1 appear in lib. Then this could appear in src/Makefile.am:

AUTOMAKE_OPTIONS = ../lib/ansi2knr

If no directory prefix is given, the files are assumed to be in the current directory.


Next: Automatic dependency tracking, Previous: C++ and other languages, Up: Building Programs and Libraries   [Contents][Index]