--- makefile.orig	2003-12-16 03:01:22.000000000 -0700
+++ makefile	2004-01-25 18:43:28.191767000 -0700
@@ -345,13 +345,12 @@
 					`uname` ; \
 			fi ;; \
 		'SunOS') \
-			if [ `which $(CC) | grep -c ucb` = '1' ] && \
-			   [ `which ucbcc | grep -c ucb` = '0' ] ; then \
-				make CC=gcc CFLAGS="$(CFLAGS) `./endian` \
+			if [ -f /usr/ccs/bin/ucbcc ] ; then \
+				make CFLAGS="$(CFLAGS) `./endian` \
 					-DOSVERSION=`uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'`" \
 					`uname` ; \
 			else \
-				make CFLAGS="$(CFLAGS) `./endian` \
+				make CC=gcc CFLAGS="$(CFLAGS) `./endian` \
 					-DOSVERSION=`uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'`" \
 					`uname` ; \
 			fi ;; \
@@ -383,15 +382,14 @@
 				-DOSVERSION=`uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'`" \
 				`uname` ;; \
 		'SunOS') \
-			if [ `which $(CC) | grep -c ucb` = '1' ] && \
-			   [ `which ucbcc | grep -c ucb` = '0' ] ; then \
+			if [ -f /usr/ccs/bin/ucbcc ] ; then \
 				make TARGET=$(SLIBNAME) OBJPATH=$(SHARED_OBJ_PATH) \
-					CC=gcc CFLAGS="$(SCFLAGS) `./endian` \
+					CFLAGS="$(SCFLAGS) `./endian` \
 					-DOSVERSION=`uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'`" \
 					`uname` ; \
 			else \
 				make TARGET=$(SLIBNAME) OBJPATH=$(SHARED_OBJ_PATH) \
-					CFLAGS="$(SCFLAGS) `./endian` \
+					CC=gcc CFLAGS="$(SCFLAGS) `./endian` \
 					-DOSVERSION=`uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'`" \
 					`uname` ; \
 			fi ;; \
@@ -1100,7 +1098,7 @@
 						else \
 							if [ `uname -a | grep -c sun4m` = '1' ] ; then \
 								gcc -mcpu=supersparc -c bn/sparcv8.S -o $(OBJPATH)bn_asm.o ; \
-							else
+							else \
 								gcc -mcpu=ultrasparc -c bn/sparcv8plus.S -o $(OBJPATH)bn_asm.o ; \
 							fi ; \
 						fi
@@ -1338,21 +1336,19 @@
 							make link LIB=$(LIB) OUT=$(OUT) \
 								OS_LDFLAGS="$(LDFLAGS_SUNOS)" ;; \
 						5) \
-							if [ `which $(LD) | grep -c ucb/cc` = '1' ] && \
-							   [ `which ucbcc | grep -c ucbcc` = '0' ] ; then \
-								make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
+							if [ -f /usr/ccs/bin/ucbcc ] ; then \
+								make link LIB=$(LIB) OUT=$(OUT) \
 									OS_LDFLAGS="$(LDFLAGS_SOLARIS5)" ; \
 							else \
-								make link LIB=$(LIB) OUT=$(OUT) \
+								make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
 									OS_LDFLAGS="$(LDFLAGS_SOLARIS5)" ; \
 							fi ;; \
 						6|7|8|9) \
-							if [ `which $(LD) | grep -c ucb/cc` = '1' ] && \
-							   [ `which ucbcc | grep -c ucbcc` = '0' ] ; then \
-								make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
+							if [ -f /usr/ccs/bin/ucbcc ] ; then \
+								make link LIB=$(LIB) OUT=$(OUT) \
 									OS_LDFLAGS="$(LDFLAGS_SOLARIS7)" ; \
 							else \
-								make link LIB=$(LIB) OUT=$(OUT) \
+								make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
 									OS_LDFLAGS="$(LDFLAGS_SOLARIS7)" ; \
 							fi ;; \
 					esac ;; \
@@ -1690,13 +1686,12 @@
 	@- if [ `uname -r | tr -d '[A-Z].' | cut -c 1` = '4' ] ; then \
 		make $(DEFINES) CC=gcc CFLAGS="$(CFLAGS) -fomit-frame-pointer -O3" ; \
 	else \
-		if [ `which $(CC) | grep -c ucb/cc` = '1' ] && \
-		   [ `which ucbcc | grep -c ucbcc` = '0' ] ; then \
-			make $(DEFINES) CC=$(CC) CFLAGS="$(CFLAGS) -fomit-frame-pointer \
-				-O3 -D_REENTRANT" ; \
-		else \
+		if [ -f /usr/ccs/bin/ucbcc ] ; then \
 			make $(DEFINES) CFLAGS="$(CFLAGS) -erroff=E_ARG_INCOMPATIBLE_WITH_ARG \
 				-xO3 -D_REENTRANT" ; \
+		else \
+			make $(DEFINES) CC=$(CC) CFLAGS="$(CFLAGS) -fomit-frame-pointer \
+				-O3 -D_REENTRANT" ; \
 		fi ; \
 	fi
 
