#!/compat/linux/bin/sh # patched by R.U. 2005/12/13. # see http://www.otaru-uc.ac.jp/~yokota/comp/mathematica.freebsd.diff ##!/bin/sh # # Mathematica 5.2 Kernel command file # Copyright 1988-2005 Wolfram Research, Inc. # Make certain that ${PATH} includes /usr/bin and /bin PATH="/usr/bin:/bin:${PATH}" # Determine the SystemID by examining the output of `uname -s` and # `uname -m`. Failsafe to SystemID=Unknown. if [ -z "${SystemIDList}" ]; then case `uname -s` in AIX) SystemIDList="AIX-Power64";; HP-UX) SystemIDList="HPUX-PA64";; IRIX64) SystemIDList="IRIX-MIPS64";; FreeBSD) case `uname -m` in ia64) SystemIDList="Linux-IA64";; i?86) SystemIDList="Linux";; x86_64) SystemIDList="Linux-x86-64 Linux";; *) SystemIDList="Unknown";; esac;; Linux) case `uname -m` in ia64) SystemIDList="Linux-IA64";; i?86) SystemIDList="Linux";; x86_64) SystemIDList="Linux-x86-64 Linux";; *) SystemIDList="Unknown";; esac;; OSF1) SystemIDList="DEC-AXP";; SunOS) case `uname -m` in sun*) SystemIDList="UltraSPARC";; i86pc) SystemIDList="Solaris-x86-64";; *) SystemIDList="Unknown";; esac;; *) SystemIDList="Unknown";; esac fi # Find the full pathname and name of this script. Script="${0}" ProgramName=`basename "${0}"` # If ${SystemIDList} = Unknown, print an error message and exit if [ "${SystemIDList}" = "Unknown" ]; then echo "${ProgramName} cannot determine operating system." exit 1 fi # Test to see if the script is being called via a symlink, if so, examine # the output of ls -l on the symlink to find the link target. Reset # ${Script}. LinkDirectory=`pwd` while `exec test -L "${Script}"`; do ScriptDirectory=`dirname "${Script}"` Script=`ls -l "${Script}" | sed -e 's/.*-> //g'` cd "${ScriptDirectory}" done ScriptDirectory=`dirname "${Script}"` ScriptDirectory=`cd "${ScriptDirectory}"; pwd` cd "${LinkDirectory}" # Determine $TopDirectory by removing "Executables" from # "${ScriptDirectory}". ScriptLeafDirectory="Executables" TopDirectory=`cd "${ScriptDirectory}"; pwd | \ sed -e 's/\/'"${ScriptLeafDirectory}"'//g'` # Set a few necessary enviroment variables M_XFILESEARCHPATH="${TopDirectory}/SystemFiles/Graphics/TextResources/English/%N" if [ -z "${XFILESEARCHPATH}" ]; then XFILESEARCHPATH="${M_XFILESEARCHPATH}" else XFILESEARCHPATH="${M_XFILESEARCHPATH}:${XFILESEARCHPATH}" fi export XFILESEARCHPATH M_PSRESOURCEPATH="${TopDirectory}/SystemFiles/Graphics/SystemResources:${TopDirectory}/SystemFiles/Fonts/Type1" if [ -z "${PSRESOURCEPATH}" ]; then PSRESOURCEPATH="${M_PSRESOURCEPATH}" else PSRESOURCEPATH="${PSRESOURCEPATH}:${M_PSRESOURCEPATH}" fi export PSRESOURCEPATH for SystemID in $SystemIDList; do # Check for MathKernel, fail if the binary cannot be found. KernelPath="SystemFiles/Kernel/Binaries/${SystemID}" MathKernel="${TopDirectory}/${KernelPath}/MathKernel" if [ ! -x "${MathKernel}" ]; then fail=1 continue else fail=0 fi # Reset $PATH to include Mathematica directories PATH="${TopDirectory}/${ScriptLeafDirectory}:${TopDirectory}/SystemFiles/Graphics/Binaries/${SystemID}:${PATH}" export PATH # Set up library paths M_LIBRARY_PATH="${TopDirectory}/SystemFiles/Libraries/${SystemID}" if [ "${SystemID}" = "Linux" ]; then # cpuvendor=`cat /proc/cpuinfo | grep 'vendor_id' | awk '{print $3}' | uniq` # cpuid=`cat /proc/cpuinfo | grep 'cpu family' | awk '{print $4}' | uniq` cpuvendor=GenuineIntel cpuid=15 if [ "$cpuvendor" == "GenuineIntel" -a "$cpuid" == "15" ]; then M_LIBRARY_PATH="${TopDirectory}/SystemFiles/Libraries/${SystemID}/pentium4:${M_LIBRARY_PATH}" elif [ $cpuvendor == "AuthenticAMD" ]; then M_LIBRARY_PATH="${TopDirectory}/SystemFiles/Libraries/${SystemID}/athlon:${M_LIBRARY_PATH}" fi fi SED_LIBRARY_PATH=`echo "${M_LIBRARY_PATH}" | sed -e 's/\\//\\\\\//g'` if [ "${SystemID}" = "HPUX-PA64" ]; then SHLIB_PATH=`echo "${SHLIB_PATH}" | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'://g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"':/:/g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/::/:/g' | sed -e 's/:$//'` if [ -z "${SHLIB_PATH}" ]; then SHLIB_PATH="${M_LIBRARY_PATH}" else SHLIB_PATH="${M_LIBRARY_PATH}:${SHLIB_PATH}" fi export SHLIB_PATH elif [ "${SystemID}" = "AIX-Power64" ]; then LIBPATH=`echo "${LIBPATH}" | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'://g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"':/:/g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/::/:/g' | sed -e 's/:$//'` if [ -z "${LIBPATH}" ]; then LIBPATH="${M_LIBRARY_PATH}" else LIBPATH="${M_LIBRARY_PATH}:${LIBPATH}" fi export LIBPATH elif [ "${SystemID}" = "IRIX-MIPS64" ]; then LD_LIBRARY64_PATH=`echo "${LD_LIBRARY64_PATH}" | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'://g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"':/:/g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/::/:/g' | sed -e 's/:$//'` if [ -z "${LD_LIBRARY64_PATH}" ]; then LD_LIBRARY64_PATH="${M_LIBRARY_PATH}" else LD_LIBRARY64_PATH="${M_LIBRARY_PATH}:${LD_LIBRARY64_PATH}" fi export LD_LIBRARY64_PATH elif [ "${SystemID}" = "UltraSPARC" ]; then LD_LIBRARY_PATH_64=`echo "${LD_LIBRARY_PATH_64}" | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'://g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"':/:/g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/::/:/g' | sed -e 's/:$//'` if [ -z "${LD_LIBRARY_PATH_64}" ]; then LD_LIBRARY_PATH_64="${M_LIBRARY_PATH}" else LD_LIBRARY_PATH_64="${M_LIBRARY_PATH}:${LD_LIBRARY_PATH_64}" fi export LD_LIBRARY_PATH_64 fi LD_LIBRARY_PATH=`echo "${LD_LIBRARY_PATH}" | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'://g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"':/:/g' | \ sed -e 's/:'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/^'"${SED_LIBRARY_PATH}"'$//g' | \ sed -e 's/::/:/g' | sed -e 's/:$//'` if [ -z "${LD_LIBRARY_PATH}" ]; then LD_LIBRARY_PATH="${M_LIBRARY_PATH}" else LD_LIBRARY_PATH="${M_LIBRARY_PATH}:${LD_LIBRARY_PATH}" fi export LD_LIBRARY_PATH if [ "${SystemID}" = "Linux" -o "${SystemID}" = "Linux-x86-64" -o "${SystemID}" = "Linux-IA64" ]; then if [ -z "${OMP_NUM_THREADS}" ]; then # OMP_NUM_THREADS=`cat /proc/cpuinfo | grep processor | wc -l | tr -d ' '`; OMP_NUM_THREADS=`cat ${TopDirectory} | grep processor | wc -l | tr -d ' '`; export OMP_NUM_THREADS; fi fi if [ "${SystemID}" = "UltraSPARC" -o "${SystemID}" = "Solaris-x86-64" ]; then if [ -z "${OMP_NUM_THREADS}" ]; then OMP_NUM_THREADS=`/usr/sbin/psrinfo | wc -l | tr -d ' '`; export OMP_NUM_THREADS; fi fi if [ "${SystemID}" = "HPUX-PA64" -o "${SystemID}" = "HP-RISC" ]; then if [ -z "${MLIB_NUMBER_OF_THREADS}" ]; then MLIB_NUMBER_OF_THREADS=`/usr/sbin/ioscan -k -C processor | grep processor | wc -l`; export MLIB_NUMBER_OF_THREADS; fi fi if [ "${fail}" = "0" ]; then break fi done if [ ! "${fail}" = "0" ]; then for SystemID in $SystemIDList; do KernelPath="SystemFiles/Kernel/Binaries/${SystemID}" MathKernel="${TopDirectory}/${KernelPath}/MathKernel" echo "Mathematica kernel executable" echo "${MathKernel}" echo "not found. Your Mathematica installation may be incomplete" echo "or corrupted." done exit 1 fi exec "${MathKernel}" "$@"