Alternative approach using imake
The imake
utility is distributed with many UNIX and Linux variants and
is available for free from the MIT Consortium.
The imake utility provides an alternative to the method of using
make macros as described in Handling build procedure differences. The
imake methodology also involves architecture-specific
make
macros, but in a different way. imake generates an
architecture-specific makefile by running cpp on an
architecture-independent template file, typically named imakefile.
A typical imakefile contains a series of cpp macros, each of which expands to a build target line and its corresponding multiline build script. Typically, the expansion itself is architecture independent:
- MakeObjectFromSrc(main)
- (macro in imakefile)
- main.o: $(SRC)/main.c
- (expansion in actual makefile)
- $(CC) -c $(CFLAGS)$(SRC)/main.c
imake places architecture-specific make macro settings at the beginning of the generated makefile. For example:
SRC = ..
CC = /usr/5bin/cc
CFLAGS = -fsingle
RM = rm -f
An idiosyncrasy of imake is that makefiles are derived objects, not source files. The architecture-independent template file (imakefile) is the source file and must be maintained as a VersionVault element.