Distinguishing "true" MIPS box from DECstation at compile time

Ray Loyzaga yar at cs.su.oz
Thu Dec 21 08:36:10 AEST 1989


In article <2103 at odin.SGI.COM> msc at sgi.com writes:
> In article <89Dec15.145750est.2273 at neat.cs.toronto.edu>,
> moraes at cs.toronto.edu (Mark Moraes) writes:
> > It is probably much better to ifdef on specific features that one
> > needs (eg.  BSD_SIGNALS, JOB_CONTROL, DIRENT, SHMEM, etc) than on a
> > specific vendor type, considering the way the zillion and one
> > [Deleted]
> > Then one can create configuration headers per machine -- s-machine.h,
> > sysdep.h, whatever, defining specific features on a per release basis,
> > as is sometimes necessary :-( The joys of maintaining a single source
> > tree for multiple architectures and OS deviants!
> > 
> > *Soapbox off*
> 
> Yes, Yes,a thousand times yes.
> 
> Even though the system vendors don't define "feature ifdefs" you can write
> your code as if you had them.  You simply have to create a header that does
> all the ugly stuff (like that in the rest of the referenced article) and
> sets the appropriate "featuredefs".

> We tried to persuade the X consortium to change the ifdef's in X to a scheme
> like this.  Their response was lukewarm.

The only problem with this approach is that all the sources that you develop
will have #includes of files that are not available on any other system,
you could #ifdef the includes but on the basis of what? The bottom line
is that you need to have an "include" file that defines the way the system
is set up, and this file is sourced by cpp with every invocation.
This file should contain the "standard defines" such as mips or sysV etc,
these are currently compiled into cpp or a caller program and mean that
the user must rely on the result of the output of "strings" on cpp or cc,
and some guesswork, or hope that any changes are reflected in the
manuals on each release. I'd be much more comfortable in reading a file
such as /etc/local-system which contains
-Dmips
-DBSD4

etc, and having cpp doing something like
#!/bin/sh
/lib/cpp.real `cat /etc/local-system` "$@"

The inbuilt defines couldn't be clearer and there would be no need to
include any files that are unlikely to exist on other machines.
We currently use such a system to communicate some kernel changes
that affect the sizes of system structures to all the system
sources without having to edit them.



More information about the Comp.unix.ultrix mailing list