daveb@rtech.ARPA (Dave Brower) (02/14/85)
[munch] If you need to know at compile time whether you're on a Berklix or a System V system, this might help. It seems to work on all of our systems, including the Pyramid split universe wonder: # include <fcntl.h> # ifdef FNDELAY # define BSD # else # define SYS5 # endif This assumes that FNDELAY is not defined in the System V fcntl.h, and is in the BSD. Can anyone think of a case where this is not true, or suggest a more convenient/valid alternative? -dB -- ---------------- {ucbvax, decvax}!mtxinu!rtech!daveb "The closer you look, the worse it gets."
guy@rlgvax.UUCP (Guy Harris) (02/16/85)
> If you need to know at compile time whether you're on a Berklix or > a System V system, this might help. It seems to work on all of our > systems, including the Pyramid split universe wonder: > > # include <fcntl.h> > # ifdef FNDELAY > # define BSD > # else > # define SYS5 > # endif > > This assumes that FNDELAY is not defined in the System V fcntl.h, and > is in the BSD. Can anyone think of a case where this is not true, Yes - 4.1BSD. It would produce an error complaining that <fcntl.h> couldn't be found. If you assume that the only UNIXes you're interested in are 4.2BSD and System III/System V, this will work (no V7, no 4.1BSD). It also won't work on the OS we're doing for the Power 6/32, if you're really interested in a strict 4.2/S5 distinction. It would think you were on a 4.2 system - we don't have two universes. However, most 4.2 stuff should work; our TTY driver, though S5 based, has all the Berkeley features in it (job control, correct "echoe" handling, "prterase", "crtkill", "ctlecho", etc., etc.) and has replaced the UNIX/TS 1.0 backward compatible "ioctl"s with V7/4.2BSD backward compatible "ioctl"s (I've successfully run the off-the-tape 4.2BSD binaries of "csh" and "vi"). I'm not sure what the result would be with Doug Gwyn's SysV emulation under 4.2BSD, either; if it doesn't provide a separate copy of <fcntl.h> your program would be built for 4.2BSD, but would be linked with SysV libraries. Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy
arnold@gatech.UUCP (Arnold Robbins) (02/19/85)
...!rtech!daveb suggests checking for BSD or System V by including <fcntl.h> and then seeing if FNDELAY is or isn't defined. This probably works just fine. I posted a more elaborate solution a couple months back to net.sources, and will duplicate here (it's short). Its main advantage is that it differentiates between 4.1, 4.2, and System V (we have all three around here...) It is used by saying CFLAGS=-O `where` in a makefile ------ #! /bin/sh # where --- shell file to determine what kind of environment we are in if test -r /bin/universe # on a pyramid then OPATH=$PATH PATH=/bin case `universe` in # universe is dumb, looking only at argv[0] att) echo "-DUSG -UBSD -UBSD4_2" ;; ucb) echo "-UUSG -DBSD -DBSD4_2" ;; *) echo unknown operating system! 1>&2 echo "-UUSG -UBSD -UBSD4_2" # undefine them all ;; esac PATH=$OPATH else # on something that is not a pyrmaid if grep SIGTSTP /usr/include/signal.h > /dev/null then # berkeley unix if test -r /usr/include/whoami.h # 4.1 then echo "-UUSG -DBSD -UBSD4_2" else # 4.2 echo "-UUSG -DBSD -DBSD4_2" fi else # ATT unix echo "-DUSG -UBSD -UBSD4_2" fi fi -- Arnold Robbins CSNET: arnold@gatech ARPA: arnold%gatech.csnet@csnet-relay.arpa UUCP: { akgua, allegra, hplabs, ihnp4, seismo, ut-sally }!gatech!arnold Help advance the state of Computer Science: Nuke a PR1ME today!
rogers@dadla.UUCP (Roger Southwick) (02/19/85)
[No matter where you go...there you are. Buckaroo Banzai] In his article "Which *nix? BSD : System V", Dave writes: > > If you need to know at compile time whether you're on a Berklix or > a System V system, this might help. It seems to work on all of our > systems, including the Pyramid split universe wonder: > > # include <fcntl.h> > # ifdef FNDELAY > # define BSD > # else > # define SYS5 > # endif > > This assumes that FNDELAY is not defined in the System V fcntl.h, and > is in the BSD. Can anyone think of a case where this is not true, or > suggest a more convenient/valid alternative? > Sure... How about 2.8 BSD. I have 3 PDP 11 systems running 2.8, and the include file is not even there. Also, what about the not so distant past of 4.1 BSD? How about V7? I don't remember if 4.1 had it (our system is now 4.2), and our V7 stuff is tucked away and long since forgotten. What I'd like to see is for all systems to have a <ostype.h> file containing the apropos define: #define BSD4_2 or #define SYSV_2 or #define BSD4_1 or #define VERS_7 ... Or some other such silly STANDARD thing. But I guess I'll keep on dreaming... -Roger UUCP: HOST!tektronix!dadla!rogers Where HOST is any one of: masscomp,decvax,allegra,uf-cgrl,mit-eddie,mit-ems, uoregon,psu-cs,orstcs,zehntel,ucbcad,ucbvax,purdue, uw-beaver,reed,ogcvax,ihnp4,tekred,minn-ua,cbosg CSnet: rogers%dadla@tektronix ARPAnet: rogers%dadla%tektronix@csnet-relay
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (02/20/85)
> # include <fcntl.h> > # ifdef FNDELAY > # define BSD > # else > # define SYS5 > # endif This should work on 4.2BSD and all UNIX System III and V releases. It would be a compile-time error on older UNIXes. I still prefer writing code for ONE environment rather than having to juggle two at the same time.
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (02/20/85)
> I'm not sure what the result would be with Doug Gwyn's SysV emulation > under 4.2BSD, either; if it doesn't provide a separate copy of <fcntl.h> > your program would be built for 4.2BSD, but would be linked with SysV > libraries. Not a problem; the emulation is complete unto itself and has its own ersatz System V include directory (the files in it have been tweaked a bit to fit 4.2BSD but the user is not supposed to notice this). I even went so far as to avoid #including ANY native 4.2BSD headers, but I would not recommend this as a general practice! (I plead extenuating circumstances.)