Handling build procedure differences
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 the include 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:
/bin/gcc -c -fsingle main.c
main.o:
/usr/bin/gcc -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/bin/gcc /usr/project/make_macros/rhel_macros
CFLAGS = -fsingle
CC = /usr/bin/gcc /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'
Alternatively, developers can specify the value at build time. For example:
clearmake main BLD_ARCH="Linux.x86_64"