Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: guy@netapp.com (Guy Harris)
Subject: Re: Portable startup files question..
Date: 1995/05/25	[thread overview]
Message-ID: <3q2ikp$ju@nova.netapp.com> (raw)
In-Reply-To: D93vAG.H9x@Cadence.COM

Dale DePriest <daled@cds9172.Cadence.COM> wrote:
>case `uname | awk '{print $1}'` in
>SunOS)  if [ -f /bin/arch ]
>        then  ARCH=`arch`
>        else ARCH=sun4v
>        fi

Or, even better (tested on SunOS 4.1.3, SunOS 5.4, IRIX 5.3, and
DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX 3.0, Ultrix code taken from the
previous example):

	#
	# Don't waste time screwing around with "awk" just to get the
	# name of the OS; use the standard "uname -s" flag.  (The "awk"
	# in the example was probably unnecessary in any case, as
	# "uname" generally doesn't print *all* the various bits of
	# information it can by default, you have to use "uname -a" to
	# get that.)
	#
	# NOTE: on some older flavors of UNIX, "uname -s" interprets
	# "system name" as "name of the machine" rather than "name of
	# the OS" (for reasons that date back to the really dim dark
	# ages of UNIX history); I think some SVR3.x systems do so,
	# as well as older systems.
	#
	# To determine the flavor of the OS on *those* systems, you're on
	# your own; piping the output of "uname" to "awk" probably won't
	# help, because it'll print the machine name in any case.
	#
	# This example only sets ARCH to an indication of the instruction-set
	# architecture of the machine; other UNIX-flavor-dependent stuff
	# could be done as well.  This means it does *not* set it to
	# the output of the "arch" command in SunOS 4.1[.x], as that
	# prints Sun's old "application architecture" name - i.e., "sun4"
	# rather than "sparc" for SPARC machines.
	#
	# This is a Bourne-compatible-shell example.  A C-shell-compatible
	# version is left as an exercise to the reader.
	#
	# This only deals with the OSes I have on hand, plus Ultrix with
	# code lifted from the posting to which I'm following up.
	# Versions for other OSes are left as an exercise to the reader.
	#
	# The coding style is the one I use; changes to match your preferred
	# Bourne-shell coding style are left as an exercise to the reader.
	#
	case `uname -s` in

	SunOS)
		case `uname -r` in

		4.1*)
			#
			# SunOS 4.1[.x] should have an "arch" command.
			# It prints the "application architecture"
			# of the machine, e.g. "sun4" for SPARC and,
			# as I remember, "sun3" for 68K.
			#
			# If, for some reason, you give a damn about
			# the "kernel architecture", use "arch -k", but
			# you probably *don't* give a damn about it.
			#
			# For now, we map "sun4" to "sparc", and
			# "sun3" to "m68k"; SunOS 5.x uses "sparc"
			# rather than "sun4", as not all SPARC machines
			# running 5.x - or 4.1[.x], for that matter! -
			# are Sun machines, and I'm assuming "ARCH" here
			# is supposed to mean "instruction-set architecture"
			# in any case.
			#
			case `arch` in

			sun4)
				ARCH=sparc
				;;

			sun3)
				ARCH=m68k
				;;

			*)
				#
				# There aren't any others - the 386i
				# never ran 4.1[.x] - but default just
				# in case.
				#
				ARCH=`arch`
				;;
			esac
			;;

		5.*)
			#
			# In SunOS 5.x, at least on SPARC, the
			# "application architecture" is printed by
			# "uname -p".
			#
			# WARNING: the significance of "-m" and "-p" in
			# various SVR4-flavored systems is not, as far
			# as I know, consistent among all systems.  In
			# particular, on x86-based systems, "uname -p"
			# may say what kind of x86 processor (386, 486,
			# Pentium, etc.) the machine has, and "uname -m"
			# may give the "application architecture" of "i386"
			# (given that I suspect 99 44/100% of the x86-based
			# machines running UNIX have a kernel architecture
			# of "IBM-compatible PC", I don't know of any way
			# to get the "kernel architecture"; anybody who
			# has a Sequent Symmetry is welcome to indicate how
			# one distinguishes them from PeeCees, in case
			# anybody gives a damn - but, as per the section
			# on SunOS 4.1[.x], I suspect nobody does).
			#
			# If anybody does happen to give a damn, on SPARC
			# 5.x machines "uname -m" gives the kernel
			# architecture.
			#
			ARCH=`uname -p`
			;;
		esac
		;;

	ULTRIX)
		case `uname -m` in

		RISC)
			ARCH=decds
			;;

		VAX)
			ARCH=vax
			;;

		*)
			ARCH=deca
			;;
		esac
		;;

	OSF1)
		#
		# "OSF1" is here assumed to really mean "Digital UNIX";
		# we use "uname -m".  I don't know whether DEC finally
		# ended up porting OSF/1 or Digital UNIX of any flavor
		# to any of their MIPS-based machines or not, nor do I
		# know what any *other* flavors of OSF/1 do.
		#
		# On Alpha machines, "uname -m" returns "alpha".
		#
		ARCH=`uname -m`
		;;

	IRIX)
		#
		# We deal only with IRIX 5.x here; if you have an earlier
		# version, put the appropriate code here, after switching
		# on "uname -r" if necessary.
		#
		# The man page claims that "uname -p" prints "the (informal)
		# of the current system's instruction set architecture",
		# so that's what we use for ARCH; it prints "mips".
		#
		# "-m" prints the CPU board type in 5.x.
		#
		ARCH=`uname -p`
		;;

	#
	# Insert stuff for your OS here.
	#
	esac



  reply	other threads:[~1995-05-25  4:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-05-21  4:00 Portable startup files question Ricardo Marek
1995-05-21  4:00 ` tim werner
1995-05-22  4:00   ` Guy Harris
1995-05-21  4:00 ` Uwe Leinberger
1995-05-22  4:00   ` Ido Sarig
1995-05-22  4:00     ` Guy Harris
1995-05-24  4:00     ` Dale DePriest
1995-05-25  4:00       ` Guy Harris [this message]
1995-05-26  4:00         ` Thanh Ma
1995-05-26  4:00           ` Guy Harris
1995-06-02  4:00     ` Christopher Samuel
1995-05-23  4:00 ` Larry Gale
1995-05-26  4:00 ` Syed Zaeem Hosain
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox