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);
wenzelm@25434
     1
# -*- shell-script -*- :mode=shellscript:
wenzelm@29145
     2
#
wenzelm@9789
     3
# Author: Markus Wenzel, TU Muenchen
wenzelm@2299
     4
#
wenzelm@2348
     5
# getsettings - bash source script to augment current env.
wenzelm@2299
     6
wenzelm@7770
     7
if [ -z "$ISABELLE_SETTINGS_PRESENT" ]
wenzelm@7770
     8
then
wenzelm@7770
     9
wenzelm@3185
    10
set -o allexport
wenzelm@3185
    11
wenzelm@7770
    12
ISABELLE_SETTINGS_PRESENT=true
wenzelm@7770
    13
wenzelm@15972
    14
export ISABELLE_HOME
wenzelm@12598
    15
if { echo -n "$ISABELLE_HOME" | fgrep " " >/dev/null; }
wenzelm@12598
    16
then
wenzelm@12598
    17
  echo 1>&2 "### White space in ISABELLE_HOME may cause strange problems later on!"
wenzelm@12598
    18
  echo 1>&2 "### ISABELLE_HOME=\"$ISABELLE_HOME\""
wenzelm@12598
    19
fi
wenzelm@2736
    20
wenzelm@11553
    21
#key executables
wenzelm@28499
    22
ISABELLE_PROCESS="$ISABELLE_HOME/bin/isabelle-process"
wenzelm@28504
    23
ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
wenzelm@28499
    24
#legacy settings
wenzelm@28499
    25
ISABELLE="$ISABELLE_PROCESS"
wenzelm@28499
    26
ISATOOL="$ISABELLE_TOOL"
wenzelm@2299
    27
wenzelm@25434
    28
#Isabelle distribution identifier -- filled in automatically!
wenzelm@25434
    29
ISABELLE_IDENTIFIER=""
wenzelm@21490
    30
wenzelm@2643
    31
#users tend to put strange things in here ...
wenzelm@2621
    32
unset ENV
wenzelm@2621
    33
unset BASH_ENV
wenzelm@2621
    34
wenzelm@9680
    35
#support easy settings
wenzelm@9680
    36
function choosefrom ()
wenzelm@9680
    37
{
wenzelm@9680
    38
  local RESULT=""
wenzelm@9680
    39
  local FILE=""
wenzelm@9680
    40
wenzelm@9680
    41
  for FILE in "$@"
wenzelm@9680
    42
  do
wenzelm@9680
    43
    [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
wenzelm@9680
    44
  done
wenzelm@9680
    45
wenzelm@9680
    46
  [ -z "$RESULT" ] && RESULT="$FILE"
wenzelm@9680
    47
  echo "$RESULT"
wenzelm@9680
    48
}
wenzelm@9680
    49
wenzelm@27914
    50
#JVM path wrapper
wenzelm@25650
    51
if [ "$OSTYPE" = cygwin ]; then
wenzelm@27908
    52
  CLASSPATH="$(cygpath -u -p "$CLASSPATH")"
wenzelm@27908
    53
  function jvmpath() { cygpath -w -p "$@"; }
wenzelm@25650
    54
else
wenzelm@27908
    55
  function jvmpath() { echo "$@"; }
wenzelm@25650
    56
fi
wenzelm@28055
    57
HOME_JVM="$HOME"
wenzelm@25650
    58
wenzelm@27908
    59
#CLASSPATH convenience
wenzelm@27908
    60
function classpath () {
wenzelm@27908
    61
  for X in "$@"
wenzelm@27908
    62
  do
wenzelm@27908
    63
    if [ -z "$CLASSPATH" ]; then
wenzelm@27908
    64
      CLASSPATH="$X"
wenzelm@27908
    65
    else
wenzelm@27908
    66
      CLASSPATH="$CLASSPATH:$X"
wenzelm@27908
    67
    fi
wenzelm@27908
    68
  done
wenzelm@27908
    69
}
wenzelm@27908
    70
wenzelm@32305
    71
#nested components
wenzelm@32305
    72
ISABELLE_COMPONENTS=""
wenzelm@32305
    73
function init_component ()
wenzelm@32305
    74
{
wenzelm@32305
    75
  local COMPONENT="$1"
wenzelm@32305
    76
wenzelm@32305
    77
  if [ ! -d "$COMPONENT" ]; then
wenzelm@32305
    78
    echo >&2 "Bad Isabelle component: $COMPONENT"
wenzelm@32305
    79
    exit 2
wenzelm@32305
    80
  elif [ -z "$ISABELLE_COMPONENTS" ]; then
wenzelm@32305
    81
    ISABELLE_COMPONENTS="$COMPONENT"
wenzelm@32305
    82
  else
wenzelm@32305
    83
    ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
wenzelm@32305
    84
  fi
wenzelm@32305
    85
  if [ -f "$COMPONENT/etc/settings" ]; then
wenzelm@32305
    86
    source "$COMPONENT/etc/settings" || exit 2
wenzelm@32305
    87
  fi
wenzelm@32305
    88
  if [ -f "$COMPONENT/etc/components" ]; then
wenzelm@32305
    89
    {
wenzelm@32305
    90
      while read; do
wenzelm@32305
    91
        case "$REPLY" in
wenzelm@32305
    92
          \#* | "") ;;
wenzelm@32305
    93
          /*) init_component "$REPLY" ;;
wenzelm@32305
    94
          *) init_component "$COMPONENT/$REPLY" ;;
wenzelm@32305
    95
        esac
wenzelm@32305
    96
      done
wenzelm@32305
    97
    } < "$COMPONENT/etc/components"
wenzelm@32305
    98
  fi
wenzelm@32305
    99
}
wenzelm@32305
   100
wenzelm@32305
   101
#main components
wenzelm@32305
   102
init_component "$ISABELLE_HOME"
wenzelm@9789
   103
wenzelm@9789
   104
[ "$ISABELLE_HOME" -ef "$ISABELLE_HOME_USER" ] && \
wenzelm@32321
   105
  { echo >&2 "### ISABELLE_HOME and ISABELLE_HOME_USER must not be the same directory!"; }
wenzelm@32321
   106
[ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
wenzelm@2299
   107
wenzelm@21490
   108
#ML system identifier
wenzelm@6413
   109
if [ -z "$ML_PLATFORM" ]; then
wenzelm@6413
   110
  ML_IDENTIFIER="$ML_SYSTEM"
wenzelm@6413
   111
else
wenzelm@6413
   112
  ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
wenzelm@6413
   113
fi
wenzelm@21468
   114
wenzelm@6413
   115
ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
wenzelm@3118
   116
wenzelm@2299
   117
set +o allexport
wenzelm@7770
   118
wenzelm@7770
   119
fi