lib/scripts/getsettings
author wenzelm
Wed Aug 29 20:16:22 2012 +0200 (2012-08-29)
changeset 49000 0cebcbeac4c7
parent 48838 623ba165d059
child 49347 d4768cb77a69
permissions -rwxr-xr-x
provide polyml-5.4.1 as regular component;
discontinued old-style choosefrom settings with hardwired defaults;
     1 # -*- shell-script -*- :mode=shellscript:
     2 #
     3 # Author: Markus Wenzel, TU Muenchen
     4 #
     5 # getsettings - bash source script to augment current env.
     6 
     7 if [ -z "$ISABELLE_SETTINGS_PRESENT" ]
     8 then
     9 
    10 set -o allexport
    11 
    12 ISABELLE_SETTINGS_PRESENT=true
    13 
    14 #Cygwin vs. POSIX
    15 if [ "$OSTYPE" = cygwin ]
    16 then
    17   if [ -z "$USER_HOME" ]; then
    18     USER_HOME="$(cygpath -u "$HOMEDRIVE\\$HOMEPATH")"
    19   fi
    20 
    21   ISABELLE_HOME_WINDOWS="$(cygpath -w "$(dirname "$ISABELLE_HOME")")\\$(basename "$ISABELLE_HOME")"
    22   ISABELLE_HOME="$(cygpath -u "$ISABELLE_HOME_WINDOWS")"
    23 
    24   CLASSPATH="$(cygpath -i -u -p "$CLASSPATH")"
    25   function jvmpath() { cygpath -i -C UTF8 -w -p "$@"; }
    26   CYGWIN_ROOT="$(jvmpath "/")"
    27 else
    28   if [ -z "$USER_HOME" ]; then
    29     USER_HOME="$HOME"
    30   fi
    31 
    32   function jvmpath() { echo "$@"; }
    33   CLASSPATH="$CLASSPATH"
    34 fi
    35 
    36 export ISABELLE_HOME
    37 
    38 #key executables
    39 ISABELLE_PROCESS="$ISABELLE_HOME/bin/isabelle-process"
    40 ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
    41 
    42 function isabelle ()
    43 {
    44   "$ISABELLE_TOOL" "$@"
    45 }
    46 
    47 #platform
    48 source "$ISABELLE_HOME/lib/scripts/isabelle-platform"
    49 if [ -z "$ISABELLE_PLATFORM" ]; then
    50   echo 1>&2 "Failed to determine hardware and operating system type!"
    51   exit 2
    52 fi
    53 
    54 #Isabelle distribution identifier -- filled in automatically!
    55 ISABELLE_ID=""
    56 [ -z "$ISABELLE_IDENTIFIER" ] && ISABELLE_IDENTIFIER=""
    57 
    58 #sometimes users put strange things in here ...
    59 unset ENV
    60 unset BASH_ENV
    61 
    62 #shared library convenience
    63 function librarypath () {
    64   for X in "$@"
    65   do
    66     case "$ISABELLE_PLATFORM" in
    67       *-darwin)
    68         if [ -z "$DYLD_LIBRARY_PATH" ]; then
    69           DYLD_LIBRARY_PATH="$X"
    70         else
    71           DYLD_LIBRARY_PATH="$X:$DYLD_LIBRARY_PATH"
    72         fi
    73         export DYLD_LIBRARY_PATH
    74         ;;
    75       *)
    76         if [ -z "$LD_LIBRARY_PATH" ]; then
    77           LD_LIBRARY_PATH="$X"
    78         else
    79           LD_LIBRARY_PATH="$X:$LD_LIBRARY_PATH"
    80         fi
    81         export LD_LIBRARY_PATH
    82         ;;
    83     esac
    84   done
    85 }
    86 
    87 #robust invocation via ISABELLE_JDK_HOME
    88 function isabelle_jdk () {
    89   if [ -z "$ISABELLE_JDK_HOME" ]; then
    90     echo "Unknown ISABELLE_JDK_HOME -- Java tools unavailable" >&2
    91     return 127
    92   else
    93     local PRG="$1"; shift
    94     "$ISABELLE_JDK_HOME/bin/$PRG" "$@"
    95   fi
    96 }
    97 
    98 #robust invocation via SCALA_HOME
    99 function isabelle_scala () {
   100   if [ -z "$ISABELLE_JDK_HOME" ]; then
   101     echo "Unknown ISABELLE_JDK_HOME -- Java tools unavailable" >&2
   102     return 127
   103   elif [ -z "$SCALA_HOME" ]; then
   104     echo "Unknown SCALA_HOME -- Scala unavailable" >&2
   105     return 127
   106   else
   107     local PRG="$1"; shift
   108     "$SCALA_HOME/bin/$PRG" "$@"
   109   fi
   110 }
   111 
   112 #CLASSPATH convenience
   113 function classpath () {
   114   for X in "$@"
   115   do
   116     if [ -z "$CLASSPATH" ]; then
   117       CLASSPATH="$X"
   118     else
   119       CLASSPATH="$X:$CLASSPATH"
   120     fi
   121   done
   122   export CLASSPATH
   123 }
   124 
   125 #arrays
   126 function splitarray ()
   127 {
   128   SPLITARRAY=()
   129   local IFS="$1"; shift
   130   for X in $*
   131   do
   132     SPLITARRAY["${#SPLITARRAY[@]}"]="$X"
   133   done
   134 }
   135 
   136 
   137 # components
   138 
   139 ISABELLE_COMPONENTS=""
   140 ISABELLE_COMPONENTS_MISSING=""
   141 
   142 #init component tree
   143 function init_component ()
   144 {
   145   local COMPONENT="$1"
   146   case "$COMPONENT" in
   147     /*) ;;
   148     *)
   149       echo >&2 "Absolute component path required: \"$COMPONENT\""
   150       exit 2
   151       ;;
   152   esac
   153 
   154   if [ -d "$COMPONENT" ]; then
   155     if [ -z "$ISABELLE_COMPONENTS" ]; then
   156       ISABELLE_COMPONENTS="$COMPONENT"
   157     else
   158       ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
   159     fi
   160   else
   161     echo >&2 "### Missing Isabelle component: \"$COMPONENT\""
   162     if [ -z "$ISABELLE_COMPONENTS_MISSING" ]; then
   163       ISABELLE_COMPONENTS_MISSING="$COMPONENT"
   164     else
   165       ISABELLE_COMPONENTS_MISSING="$ISABELLE_COMPONENTS_MISSING:$COMPONENT"
   166     fi
   167   fi
   168 
   169   if [ -f "$COMPONENT/etc/settings" ]; then
   170     source "$COMPONENT/etc/settings"
   171     local RC="$?"
   172     if [ "$RC" -ne 0 ]; then
   173       echo >&2 "Return code $RC from bash script: \"$COMPONENT/etc/settings\""
   174       exit 2
   175     fi
   176   fi
   177   if [ -f "$COMPONENT/etc/components" ]; then
   178     init_components "$COMPONENT" "$COMPONENT/etc/components"
   179   fi
   180 }
   181 
   182 #init component forest
   183 function init_components ()
   184 {
   185   local BASE="$1"
   186   local CATALOG="$2"
   187 
   188   if [ ! -d "$BASE" ]; then
   189     echo >&2 "Bad component base directory: \"$BASE\""
   190     exit 2
   191   fi
   192   if [ ! -f "$CATALOG" ]; then
   193     echo >&2 "Bad component catalog file: \"$CATALOG\""
   194     exit 2
   195   fi
   196   {
   197     while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
   198     do
   199       case "$REPLY" in
   200         \#* | "") ;;
   201         /*) init_component "$REPLY" ;;
   202         *) init_component "$BASE/$REPLY" ;;
   203       esac
   204     done
   205   } < "$CATALOG"
   206 }
   207 
   208 #main components
   209 init_component "$ISABELLE_HOME"
   210 [ -d "$ISABELLE_HOME/Admin" ] && init_component "$ISABELLE_HOME/Admin"
   211 [ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
   212 
   213 
   214 #ML system identifier
   215 if [ -z "$ML_PLATFORM" ]; then
   216   ML_IDENTIFIER="$ML_SYSTEM"
   217 else
   218   ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
   219 fi
   220 
   221 ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
   222 
   223 #enforce JAVA_HOME
   224 export JAVA_HOME="$ISABELLE_JDK_HOME"
   225 
   226 #build condition etc.
   227 case "$ML_SYSTEM" in
   228   polyml*)
   229     ISABELLE_POLYML="true"
   230     ;;
   231   *)
   232     ISABELLE_POLYML=""
   233     ;;
   234 esac
   235 
   236 set +o allexport
   237 
   238 fi