lib/scripts/getsettings
author wenzelm
Wed Dec 09 16:28:49 2009 +0100 (2009-12-09)
changeset 34043 7129fab1fe4f
parent 33512 771ec7306438
child 34254 14f6df4f473d
permissions -rw-r--r--
more robust Cygwin.config: actually check Wow6432Node, prefer explicit CYGWIN_ROOT in any case;
     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 export ISABELLE_HOME
    15 if { echo -n "$ISABELLE_HOME" | fgrep " " >/dev/null; }
    16 then
    17   echo 1>&2 "### White space in ISABELLE_HOME may cause strange problems later on!"
    18   echo 1>&2 "### ISABELLE_HOME=\"$ISABELLE_HOME\""
    19 fi
    20 
    21 #key executables
    22 ISABELLE_PROCESS="$ISABELLE_HOME/bin/isabelle-process"
    23 ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
    24 #legacy settings
    25 ISABELLE="$ISABELLE_PROCESS"
    26 ISATOOL="$ISABELLE_TOOL"
    27 
    28 #Isabelle distribution identifier -- filled in automatically!
    29 ISABELLE_IDENTIFIER=""
    30 
    31 #users tend to put strange things in here ...
    32 unset ENV
    33 unset BASH_ENV
    34 
    35 #support easy settings
    36 function choosefrom ()
    37 {
    38   local RESULT=""
    39   local FILE=""
    40 
    41   for FILE in "$@"
    42   do
    43     [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
    44   done
    45 
    46   [ -z "$RESULT" ] && RESULT="$FILE"
    47   echo "$RESULT"
    48 }
    49 
    50 #JVM path wrapper
    51 if [ "$OSTYPE" = cygwin ]; then
    52   CLASSPATH="$(cygpath -u -p "$CLASSPATH")"
    53   function jvmpath() { cygpath -w -p "$@"; }
    54   CYGWIN_ROOT="$(jvmpath "/")"
    55 else
    56   function jvmpath() { echo "$@"; }
    57 fi
    58 HOME_JVM="$HOME"
    59 
    60 #CLASSPATH convenience
    61 function classpath () {
    62   for X in "$@"
    63   do
    64     if [ -z "$CLASSPATH" ]; then
    65       CLASSPATH="$X"
    66     else
    67       CLASSPATH="$CLASSPATH:$X"
    68     fi
    69   done
    70 }
    71 
    72 #arrays
    73 function splitarray ()
    74 {
    75   SPLITARRAY=()
    76   local IFS="$1"; shift
    77   for X in $*
    78   do
    79     SPLITARRAY["${#SPLITARRAY[@]}"]="$X"
    80   done
    81 }
    82 
    83 #nested components
    84 ISABELLE_COMPONENTS=""
    85 function init_component ()
    86 {
    87   local COMPONENT="$1"
    88 
    89   if [ ! -d "$COMPONENT" ]; then
    90     echo >&2 "Bad Isabelle component: \"$COMPONENT\""
    91     exit 2
    92   elif [ -z "$ISABELLE_COMPONENTS" ]; then
    93     ISABELLE_COMPONENTS="$COMPONENT"
    94   else
    95     ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
    96   fi
    97   if [ -f "$COMPONENT/etc/settings" ]; then
    98     source "$COMPONENT/etc/settings" || exit 2
    99   fi
   100   if [ -f "$COMPONENT/etc/components" ]; then
   101     {
   102       while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
   103       do
   104         case "$REPLY" in
   105           \#* | "") ;;
   106           /*) init_component "$REPLY" ;;
   107           *) init_component "$COMPONENT/$REPLY" ;;
   108         esac
   109       done
   110     } < "$COMPONENT/etc/components"
   111   fi
   112 }
   113 
   114 #main components
   115 init_component "$ISABELLE_HOME"
   116 
   117 [ "$ISABELLE_HOME" -ef "$ISABELLE_HOME_USER" ] && \
   118   { echo >&2 "### ISABELLE_HOME and ISABELLE_HOME_USER must not be the same directory!"; }
   119 [ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
   120 
   121 #ML system identifier
   122 if [ -z "$ML_PLATFORM" ]; then
   123   ML_IDENTIFIER="$ML_SYSTEM"
   124 else
   125   ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
   126 fi
   127 
   128 ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
   129 
   130 set +o allexport
   131 
   132 fi