#!/bin/csh -f # # GETARCH -- Determine or set the current platform architecture parameters. # # Usage: getarch # getarch -set [] [opts] # # -mach print the architecture name [default] # -current print the currently configured arch # -nbits print number of bits in an int (32 or 64) # # -actual print actual architecture name regardless of VOCARCH # -set manually reset the environment architecture # # ---------------------------------------------------------------------------- unset noclobber onintr cleanup_ unalias cd cp cmp echo ln mv rm sed set grep ls chmod chown pwd touch sort which setenv path "(/sbin /usr/sbin /bin /usr/bin /usr/5bin /usr/ucb /etc /usr/etc $path /usr/local/bin /opt/local/bin /local/bin /home/local/bin /usr/openwin/bin /usr/X11R6/bin /usr/X11/bin)" # set echo ############################################################################## # START OF MACHDEP DEFINITIONS. ############################################################################## set VERSION = "V1.0" set nbits = 32 set debug = 0 #---------------------------------- # Determine platform architecture. #---------------------------------- if (-e /usr/bin/uname) then set uname_cmd = /usr/bin/uname else if (-e /bin/uname) then set uname_cmd = /bin/uname else WARNING "No 'uname' command found to determine architecture." exit 1 endif setenv UNAME `$uname_cmd | tr '[A-Z]' '[a-z]'` if ($UNAME == "sunos") then setenv UNAME_M `$uname_cmd -m | cut -c2- | tr '[A-Z]' '[a-z]'` else setenv UNAME_M `$uname_cmd -m | tr '[A-Z]' '[a-z]' | tr ' ' '_'` endif setenv OSVERSION `$uname_cmd -r | cut -c1` # Allow a VOCARCH definition in the environment to override. if ($#argv == 1 && "$1" == "-actual") then setenv MNAME $UNAME setenv MNAME_M $UNAME_M unsetenv VOCARCH else if ($#argv == 1 && "$1" == "-current") then setenv MNAME `/bin/ls -lad $iraf/bin | \ awk '{ printf ("%s\n", $11) }' | \ sed -e 's/bin.//g'` setenv MNAME_M $UNAME_M setenv VOCARCH $MNAME goto repeat_ else if ($?IRAFARCH) then # Let IRAFARCH set arch if (! $?VOCARCH) then setenv VOCARCH $IRAFARCH endif endif if ($#argv == 0) then if ($?VOCARCH) then repeat_: setenv MNAME $VOCARCH setenv MNAME_M $UNAME_M else setenv MNAME $UNAME setenv MNAME_M $UNAME_M endif else if ($#argv != 0 && "$1" == "-set") then setenv MNAME $2 setenv MNAME_M $2 else setenv MNAME $UNAME setenv MNAME_M $UNAME_M endif endif endif # Set some common defaults for most platforms set nbits = 32 # 32-bit architecture # Determine parameters for each architecture. switch ($MNAME) case darwin: # Mac OS X case ipad: case macosx: case macintel: if ($?VOCARCH) then set mach = "$VOCARCH" if ($mach == "macintel") then set nbits = 64 endif else if ($MNAME_M == "x86_64") then # 64-bit set mach = "macintel" set nbits = 64 else if ($MNAME_M == "x86" || $MNAME_M == "i386" || $MNAME_M == "ppc" || $MNAME_M == "power_macintosh") then set mach = "macosx" set nbits = 32 else set mach = "ipad" # iOS Device set nbits = 32 endif endif breaksw case redhat: case linux: case linux64: if ($?VOCARCH) then set mach = "$VOCARCH" if ($mach == "linux64") then set nbits = 64 endif else if ($MNAME_M == "x86_64") then # Linux x86_64 set mach = "linux64" set nbits = 64 else # Linux set mach = "linux" set nbits = 32 endif endif breaksw case ssun: case sparc: case sunos: if ($UNAME_M != "86pc") then if ($OSVERSION == 5) then # Sparc Solaris set mach = "ssun" else # Sparc SunOS 4.x set mach = "sparc" endif else set mach = "sunos" # Intel Solaris x86 endif breaksw case freebsd: # FreeBSD set mach = "freebsd" breaksw default: # We don't want to be limited by the CYGWIN version numbering so # look for a truncated match here before punting. set os_mach = `echo $UNAME | cut -c1-6` if ("$os_mach" == "cygwin") then set mach = "cygwin" breaksw else echo "Unable to determine platform architecture for ($MNAME)." exit 1 endif endsw ############################################################################## # END OF MACHDEP DEFINITIONS. ############################################################################## if ($#argv == 0) then echo $mach else if ("$1" == "-mach") then echo $mach else if ("$1" == "-actual") then echo $mach else if ("$1" == "-current") then echo $mach else if ("$1" == "-nbits") then echo $nbits else if ("$1" == "-set") then if ("$2" != "") then setenv VOCARCH $2 shift ; shift endif goto repeat_ else echo "Invalid option '"$1"'" endif endif