/usr/local vs. /usr/local/bin
M.T.Russell
mtr at ukc.ac.uk
Tue Nov 1 05:09:06 AEST 1988
In article <88Oct19.153216edt.45 at neat.ai.toronto.edu> lamy at ai.utoronto.ca (Jean-Francois Lamy) writes:
>A good rule of thumb is to keep in mind that even if you don't have a
>mixed-architecture environment *now*, you may have one soon. So write your
>Makefiles and #defines with an explicit directory for architecture independent
>configuration data and aux. files.
We have a scheme for building binaries for multiple architectures in a
single NFS mounted source tree which I haven't seen described elsewhere.
We have a make variable (M) set to a name for the architecture/OS
combination, which is then used in the makefile to name the architecture
specific .o files and binaries. Makefiles look roughly like:
.SUFFIXES: .$Mo
.c.$Mo:
$(CC) -c $(CFLAGS) $*.c
mv -f $*.o $*.$Mo
OBJS = bar.$Mo baz.$Mo
foo: $Mfoo
$Mfoo: $(OBJS)
$(CC) -o $@ $(OBJS)
So if M is set to "sun3_", then bar.sun3_o and baz.sun3_o are linked to
build sun3_foo. M can obviously be made more specific (e.g. "sun3_sunos4_").
This scheme has several advantages over the shadow tree of symlinks
method:
- you always get the right binary for the right architecture.
- binaries for multiple architectures can exist simultaneously in the
same source directory
- all you have to do to add a new architecture is define a new
name for it in $M
- no shadow tree of symlinks to maintain
Of course with an existing source tree it has the disadvantage that
you'd have to hack all the makefiles - we only use it for our own
projects.
One problem is that you can't have two makes running simultaneously
on two different architectures as the intermediate .o files can clash.
What I'd like to write for the compilation rule is
.c.$Mo:
$(CC) -c $(CFLAGS) -o $*.$Mo $*.c
but unfortunately the C compilers don't allow -o with -c.
M is set in the environment, usually via .login. Locally we have
a machinetype command, and a line
setenv M `machinetype`
in .login.
If your version of make doesn't import environment variables, you have to
install a wrapper, e.g.
#! /bin/sh
exec /bin/make "M=$M" "$@"
Mark Russell
mtr at ukc.ac.uk
More information about the Comp.unix.questions
mailing list