# HG changeset patch
# User J. H. Palmieri
# Date 1290300088 28800
# Node ID 038c726270285ec6de634bff941002ddeacde365
# Parent 891d88d2265a866223b4085f804808fd12ab523d
#10303: clean up use of SAGE64. Don't insist that it is only used on Solaris or OS X, only call sagecheck64 in sagebuild and sagespkg, and delete the file SAGE_LOCAL/lib/sage64.txt if SAGE64 is set to 'no'.
diff r 891d88d2265a r 038c72627028 sagebuild
 a/sagebuild
+++ b/sagebuild
@@ 88,9 +88,7 @@ if [ $DO_BUILD_ALL = 1 ]; then
cd "$CUR"
fi
# In case SAGE64 has been set to yes before reinject it into the environment
# This is only done on OSX and Solaris since those are the only real multi lib
# arches we support. Eventually Linux PPC on the PS3 might need to be added here
source $SAGE_LOCAL/bin/sagecheck64
+# Check whether this seems to a 64bit build:
+source "$SAGE_LOCAL"/bin/sagecheck64
build "sage"
diff r 891d88d2265a r 038c72627028 sagecheck64
 a/sagecheck64
+++ b/sagecheck64
@@ 1,42 +1,49 @@
#!/usr/bin/env bash
# If SAGE64 is set to yes check if $SAGE_LOCAL/lib exists on Solaris as well as
# OSX since those are currently the only two platforms which require SAGE64. If
# it does not exist create the directory and then create a file sage64.txt
# Eventually Linux PPC on the PS3 might need to be added here
+# If SAGE64 is set to "yes", make sure $SAGE_LOCAL/lib/sage64.txt
+# exists. If SAGE64 is set to "no", make sure that
+# $SAGE_LOCAL/lib/sage64.txt does not exist. If SAGE64 is not set,
+# then set it to "yes" if $SAGE_LOCAL/lib/sage64.txt exists.
if [ "$SAGE64" = "yes" ]; then
 CHECKFILE="no"
 if [ `uname` = "SunOS" ]; then
 echo "Building Sage on Solaris in 64bit mode"
 CHECKFILE="yes"
+ case `uname` in
+ "SunOS")
+ echo "Building Sage on Solaris in 64bit mode";;
+ "Darwin")
+ echo "Building Sage on OS X in 64bit mode";;
+ *)
+ echo "Building Sage in 64bit mode";;
+ esac
+ if ! [ d "$SAGE_LOCAL"/lib ]; then
+ echo "Creating SAGE_LOCAL/lib since it does not exist"
+ mkdir "$SAGE_LOCAL"/lib
fi
 if [ `uname` = "Darwin" ]; then
 echo "Building Sage on OS X in 64bit mode"
 CHECKFILE="yes"
+
+ if ! [ a "$SAGE_LOCAL"/lib/sage64.txt ]; then
+ echo "Creating SAGE_LOCAL/lib/sage64.txt since it does not exist"
+ touch "$SAGE_LOCAL"/lib/sage64.txt
fi
 if [ $CHECKFILE = "yes" ]; then
 if ! [ d "$SAGE_LOCAL"/lib ]; then
 echo "Creating SAGE_LOCAL/lib since it does not exist"
 mkdir "$SAGE_LOCAL"/lib
 fi
 echo "Creating SAGE_LOCAL/lib/sage64.txt since it does not exist"
 touch "$SAGE_LOCAL"/lib/sage64.txt
+elif [ "$SAGE64" = "no" ]; then
+ # User has declared this build to *not* be 64bit, so delete
+ # sage64.txt.
+ if [ a "$SAGE_LOCAL"/lib/sage64.txt ]; then
+ echo "SAGE64 set to no. Deleting SAGE_LOCAL/lib/sage64.txt."
+ fi
+ rm f "$SAGE_LOCAL"/lib/sage64.txt
+else
+ # SAGE64 is not set, so check if SAGE_LOCAL/lib/sage64.txt
+ # exists. If it does, set SAGE64 to "yes".
+ if [ a "$SAGE_LOCAL"/lib/sage64.txt ]; then
+ echo "File SAGE_LOCAL/lib/sage64.txt detected."
+ case `uname` in
+ "Darwin")
+ echo "Building Sage on Solaris in 64bit mode.";;
+ "SunOS")
+ echo "Building Sage on OS X in 64bit mode.";;
+ *)
+ echo "Building Sage in 64bit mode.";;
+ esac
+ SAGE64="yes"
+ export SAGE64
fi
fi

# Check if SAGE_LOCAL/lib/sage64.txt exists. If it does on Solaris and OSX
# force the setting of SAGE64

if [ a "$SAGE_LOCAL"/lib/sage64.txt ]; then
 echo "Detected SAGE64 flag"
 if [ `uname` = "SunOS" ]; then
 echo "Building Sage on Solaris in 64bit mode"
 SAGE64="yes"; export SAGE64
 fi
 if [ `uname` = "Darwin" ]; then
 echo "Building Sage on OS X in 64bit mode"
 SAGE64="yes"; export SAGE64
 fi
fi

diff r 891d88d2265a r 038c72627028 sageenv
 a/sageenv
+++ b/sageenv
@@ 101,7 +101,7 @@ if [ 1 = 2 ]; then
echo "MAKE The make program (e.g. make, /usr/bin/make or /usr/local/bin/gmake)"
echo "MAKEFLAGS Flag(s) to make (e.g. j4)."
echo "RANLIB Archiver ranlib (e.g. ranlib, /usr/ccs/bin/ranlib etc)"
 echo "SAGE64 Set to \"yes\" to build a 64bit binary (Solaris SPARC or Solaris x86 only)"
+ echo "SAGE64 Set to \"yes\" to build a 64bit binary"
echo "SHAREDFLAGS Flag(s) necessary for building a shared library (e.g. fPIC or xcode=pic32)"
echo "We attempt to set this to sensible values, but check below to"
echo "ensure they are OK. If you wish to override any then please use:"
@@ 275,6 +275,9 @@ if [ "$LDFLAGS" = "" ]; then
LDFLAGS="" && export LDFLAGS
fi
+# SAGE64 is used in the script sagecheck64, which is called by
+# sagespkg before executing each spkg's spkginstall file. It is
+# also called by sagebuild.
if [ "$SAGE64" = "" ]; then
SAGE64="no"
fi
@@ 284,10 +287,6 @@ if [ "$SAGE64" != "yes" a "$SAGE64" !=
exit 1
fi
# In case SAGE64 has been set to yes before reinject it into the environment
# This is only done on OSX and Solaris since those are the only real multi lib
# arches we support. Eventually Linux PPC on the PS3 might need to be added here
source $SAGE_LOCAL/bin/sagecheck64 2> /dev/null
export SAGE64
if [ "$CXXFLAGS" = "" ]; then
diff r 891d88d2265a r 038c72627028 sagesdist
 a/sagesdist
+++ b/sagesdist
@@ 39,6 +39,7 @@ cd "$CUR"
cp $SAGE_ROOT/local/bin/sagespkg $PKGDIR/base/
cp $SAGE_ROOT/local/bin/sageenv $PKGDIR/base/
cp $SAGE_ROOT/local/bin/sagemake_relative $PKGDIR/base/
+cp $SAGE_ROOT/local/bin/sagecheck64 $PKGDIR/base/
TMP="/tmp/$TARGET"
diff r 891d88d2265a r 038c72627028 sagespkg
 a/sagespkg
+++ b/sagespkg
@@ 311,6 +311,8 @@ uname a
if [ $? ne 0 ]; then
echo "Unable to determine host system information."
fi
+# Check whether this seems to a 64bit build:
+source "$SAGE_LOCAL"/bin/sagecheck64
echo "****************************************************"
echo "****************************************************"