#!/bin/csh -f

#
# make sure the path is sufficient to find needed cmds
#
set path=($PATH /bin /usr/bin /usr/sbin)

set os=`uname`
set arch=unknown

if ( $?SHARC_ARCH ) then
	set arch=$SHARC_ARCH
else if ( $os == 'IRIX64' ) then
	set osmajor=`uname -r | cut -d. -f1 | cut -c1`
	set osminor=`uname -r | cut -d. -f2 | cut -c1`
	if ( $osmajor >= 6 && $osminor >= 5 ) then
		set arch=sgi_6.5_n64
	else if ( $osmajor >= 6 && $osminor >= 2 ) then
		set arch=sgi_6.2_o32
	endif
else if ( $os == 'Linux' ) then
	set proc=`uname -m`
	if ( $proc == 'alpha' ) then
		set osmajor=`uname -r | cut -d. -f1`
		set osminor=`uname -r | cut -d. -f2`
		if ( $osmajor >= 2 && $osminor >= 2 ) then
			set arch=linux_alpha_2.2
		endif
        else if ( $proc == 'ia64' ) then
                set osmajor=`uname -r | cut -d. -f1`
                set osminor=`uname -r | cut -d. -f2`
                if ( $osmajor > 2 || ($osmajor == 2 && $osminor >= 4 )) then
                        set arch=linux_ia64_2.4
                endif

        else if ( $proc == 'x86_64' ) then
                set osmajor=`uname -r | cut -d. -f1`
                set osminor=`uname -r | cut -d. -f2`
                if ( $osmajor >= 2 && $osminor >= 6 ) then
                        set arch=linux_2.6_64
                else if ( $osmajor >= 2 && $osminor >= 2 ) then
                        set arch=linux_2.4_64
                endif

	else
		set osmajor=`uname -r | cut -d. -f1`
		set osminor=`uname -r | cut -d. -f2`
if ( $osmajor >= 2 && $osminor >= 6 ) then
set arch=linux_2.4
endif
		if ( $osmajor >= 2 && $osminor == 4 ) then
			set arch=linux_2.4
                else 
			set arch=linux_2.4
		endif
	endif
else if ( $os == 'HP-UX' ) then
        uname -a | grep -q -i ia64
        if ($status == 0) then
		set bits=`getconf HW_CPU_SUPP_BITS`
		if ( $bits >= 64 ) then
		    set arch=hpia_11.2_64
		else
		    set arch=hpia_11.2_32
		endif
        else
	    set osmajor=`uname -r | cut -d. -f2`
	    set osminor=`uname -r | cut -d. -f3`
	    if ( $osmajor >= 11 ) then
		set bits=`getconf HW_CPU_SUPP_BITS`
		if ( $bits >= 64 ) then
			set arch=hp_11.0_64
		else
			set arch=hp_11.0_32
		endif
	    else if ( $osmajor >= 10 && $osminor >= 20 ) then
		set arch=hp_10.2
	    endif
	endif
else if ( $os == 'SunOS' ) then
	set osmajor=`uname -r | cut -d. -f1`
	set osminor=`uname -r | cut -d. -f2`
	if ( $osmajor > 5 ) then
		set arch=sun_8_64
	else if ( $osmajor >= 5 && $osminor >= 8 ) then
		set arch=sun_8_64
	else if ( $osmajor >= 5 && $osminor >= 6 ) then
		set arch=sun_8_64
	endif
else if ( $os == 'OSF1' ) then
	set arch=cpq_5.1
else if ( $os == 'AIX' ) then
	set arch=ibm_5.3_64
else if ( $os == 'SUPER-UX' ) then
	set arch=nec
else if ( $os == 'Darwin' ) then
        set arch=apple_10.3_32
endif



echo $arch
