generating code to run multiple targets/configurations from single

John F Carr jfc at athena.mit.edu
Tue Apr 11 21:49:02 AEST 1989


There is a program at Athena called "machtype" which tells you what kind
of machine you are on (and other trivia, like CPU type and display hardware,
if you care).  This is also a shell variable, "hosttype", in our version of
tcsh.  I put in my .login "setenv HOSTTYPE $hosttype", and make other
programs depend on this (those that I can't modify the source for with
#ifdef <machine type>).

Such a program is extremely useful when using NFS, since there is otherwise
no convenient way of determining what hardware you are running on.  In
particular, $PATH must be set to point to the correct bin directories on
NFS filesystems exported to multiple machine types.  Our naming convention
is to add the machine type as a prefix to "bin", so we have "vaxbin" and
"rtbin" subdirectories of most exported filesystems (as well as "vaxlib" and
"rtlib" if appropriate).  The Andrew File System has built in support for
machine type, being able to substitute it automatically in a filename (but
as a suffix -- we managed to choose opposite conventions).

Solutions I have heard to the multiple target machines types include:

  1. Create lots of symlinks.  Run make in the correct directory and it
     will do the right thing.

  2. Have disctinct make targets per machine type.  So, to compile for
     the RT one runs "make rt"; for a vax "make vax".

  3. Use an environment variable, modify make to define a variable,
     or otherwise get it to notice the machine type.  Like (2) except
     make makes the distinction between target machine types, instead
     of the programmer.

Now if only we can get X to distinguish between a 16" and a 19" display...

--
   John Carr             "When they turn the pages of history,
   jfc at Athena.mit.edu     When these days have passed long ago,
   bloom-beacon!          Will they read of us with sadness
   athena.mit.edu!jfc     For the seeds that we let grow?"  --Neil Peart



More information about the Comp.unix.wizards mailing list