lib/scripts/getsettings
author wenzelm
Tue Aug 04 13:35:33 2009 +0200 (2009-08-04)
changeset 32321 13920dbe4547
parent 32305 c5523ded51d9
child 32390 468eff174a77
permissions -rw-r--r--
more uniform handling of ISABELLE_HOME_USER component;
discontinued ISABELLE_IGNORE_USER_SETTINGS (ever used? cf. c567f9fd61a2);
     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 else
    55   function jvmpath() { echo "$@"; }
    56 fi
    57 HOME_JVM="$HOME"
    58 
    59 #CLASSPATH convenience
    60 function classpath () {
    61   for X in "$@"
    62   do
    63     if [ -z "$CLASSPATH" ]; then
    64       CLASSPATH="$X"
    65     else
    66       CLASSPATH="$CLASSPATH:$X"
    67     fi
    68   done
    69 }
    70 
    71 #nested components
    72 ISABELLE_COMPONENTS=""
    73 function init_component ()
    74 {
    75   local COMPONENT="$1"
    76 
    77   if [ ! -d "$COMPONENT" ]; then
    78     echo >&2 "Bad Isabelle component: $COMPONENT"
    79     exit 2
    80   elif [ -z "$ISABELLE_COMPONENTS" ]; then
    81     ISABELLE_COMPONENTS="$COMPONENT"
    82   else
    83     ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
    84   fi
    85   if [ -f "$COMPONENT/etc/settings" ]; then
    86     source "$COMPONENT/etc/settings" || exit 2
    87   fi
    88   if [ -f "$COMPONENT/etc/components" ]; then
    89     {
    90       while read; do
    91         case "$REPLY" in
    92           \#* | "") ;;
    93           /*) init_component "$REPLY" ;;
    94           *) init_component "$COMPONENT/$REPLY" ;;
    95         esac
    96       done
    97     } < "$COMPONENT/etc/components"
    98   fi
    99 }
   100 
   101 #main components
   102 init_component "$ISABELLE_HOME"
   103 
   104 [ "$ISABELLE_HOME" -ef "$ISABELLE_HOME_USER" ] && \
   105   { echo >&2 "### ISABELLE_HOME and ISABELLE_HOME_USER must not be the same directory!"; }
   106 [ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
   107 
   108 #ML system identifier
   109 if [ -z "$ML_PLATFORM" ]; then
   110   ML_IDENTIFIER="$ML_SYSTEM"
   111 else
   112   ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
   113 fi
   114 
   115 ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
   116 
   117 set +o allexport
   118 
   119 fi