Handling build procedure differences
You can handle differences in the build procedure using the following methods.
Ideally, a single file (that is, a single version of a file element) drives all architecture-specific builds. One way to accomplish this is to revise makefiles as follows:
- Regularize build scripts
- Replace architecture-specific constructs (for example, /bin/cc) with make
macro invocations (for example,
$(CC)
) - Use the clearmake include directive to incorporate architecture-specific
settings of the
make
macros. For more information about theinclude
directive, see Setting up a parallel build.
For example, suppose that the source file main.c
is compiled differently for two
different architectures:
main.o:
/usr/ucb/cc -c -fsingle main.c
main.o:
/usr/bin/cc -c main.c
To merge these build scripts, use the compiler path name and options in make
macros CC
and CFLAGS
and place an architecture-specific include
line at the beginning of the makefile:
include /usr/project/make_macros/$(BLD_ARCH)_macros
..
main.o:
$(CC) -c $(CFLAGS) main.c
The files in the make_macros directory then have these contents:
CC = /usr/5bin/cc /usr/project/make_macros/sun5_macros
CFLAGS = -fsingle
CC = /usr/bin/cc /usr/project/make_macros/sles_macros
CFLAGS =
The make
macro BLD_ARCH acts as a selector between these
two files. The value of this macro can be placed in an environment variable by a shell startup
script:
setenv BLD_ARCH 'uname -s'.`uname -m`
Alternatively, developers can specify the value at build time. For example:
clearmake main BLD_ARCH="Linux.x86_64"