lib/scripts/getsettings
author wenzelm
Thu Sep 12 14:32:02 2013 +0200 (2013-09-12)
changeset 53580 ffc926553ec5
parent 53576 793a429c63e7
child 53913 5ff12177a067
permissions -rwxr-xr-x
reverse orientation of ISABELLE_CLASSPATH;
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@48838
    14
#Cygwin vs. POSIX
wenzelm@47461
    15
if [ "$OSTYPE" = cygwin ]
wenzelm@47461
    16
then
wenzelm@47661
    17
  if [ -z "$USER_HOME" ]; then
wenzelm@47661
    18
    USER_HOME="$(cygpath -u "$HOMEDRIVE\\$HOMEPATH")"
wenzelm@47661
    19
  fi
wenzelm@47661
    20
wenzelm@47525
    21
  ISABELLE_HOME_WINDOWS="$(cygpath -w "$(dirname "$ISABELLE_HOME")")\\$(basename "$ISABELLE_HOME")"
wenzelm@47461
    22
  ISABELLE_HOME="$(cygpath -u "$ISABELLE_HOME_WINDOWS")"
wenzelm@47461
    23
wenzelm@47461
    24
  function jvmpath() { cygpath -i -C UTF8 -w -p "$@"; }
wenzelm@47996
    25
  CYGWIN_ROOT="$(jvmpath "/")"
wenzelm@53576
    26
wenzelm@53576
    27
  ISABELLE_CLASSPATH="$(cygpath -i -u -p "$CLASSPATH")"
wenzelm@53576
    28
  unset CLASSPATH
wenzelm@47461
    29
else
wenzelm@47661
    30
  if [ -z "$USER_HOME" ]; then
wenzelm@47661
    31
    USER_HOME="$HOME"
wenzelm@47661
    32
  fi
wenzelm@47661
    33
wenzelm@47461
    34
  function jvmpath() { echo "$@"; }
wenzelm@53576
    35
wenzelm@53576
    36
  ISABELLE_CLASSPATH="$CLASSPATH"
wenzelm@53576
    37
  unset CLASSPATH
wenzelm@47461
    38
fi
wenzelm@47461
    39
wenzelm@15972
    40
export ISABELLE_HOME
wenzelm@2736
    41
wenzelm@11553
    42
#key executables
wenzelm@28499
    43
ISABELLE_PROCESS="$ISABELLE_HOME/bin/isabelle-process"
wenzelm@28504
    44
ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
wenzelm@2299
    45
wenzelm@34254
    46
function isabelle ()
wenzelm@34254
    47
{
wenzelm@34254
    48
  "$ISABELLE_TOOL" "$@"
wenzelm@34254
    49
}
wenzelm@34254
    50
wenzelm@36196
    51
#platform
wenzelm@41758
    52
source "$ISABELLE_HOME/lib/scripts/isabelle-platform"
wenzelm@48455
    53
if [ -z "$ISABELLE_PLATFORM" ]; then
wenzelm@48455
    54
  echo 1>&2 "Failed to determine hardware and operating system type!"
wenzelm@48455
    55
  exit 2
wenzelm@48455
    56
fi
wenzelm@36196
    57
wenzelm@25434
    58
#Isabelle distribution identifier -- filled in automatically!
wenzelm@41511
    59
ISABELLE_ID=""
wenzelm@48837
    60
[ -z "$ISABELLE_IDENTIFIER" ] && ISABELLE_IDENTIFIER=""
wenzelm@21490
    61
wenzelm@41511
    62
#sometimes users put strange things in here ...
wenzelm@2621
    63
unset ENV
wenzelm@2621
    64
unset BASH_ENV
wenzelm@2621
    65
wenzelm@41614
    66
#shared library convenience
wenzelm@52443
    67
function librarypath ()
wenzelm@52443
    68
{
wenzelm@41614
    69
  for X in "$@"
wenzelm@41614
    70
  do
wenzelm@41614
    71
    case "$ISABELLE_PLATFORM" in
wenzelm@41614
    72
      *-darwin)
wenzelm@41614
    73
        if [ -z "$DYLD_LIBRARY_PATH" ]; then
wenzelm@41614
    74
          DYLD_LIBRARY_PATH="$X"
wenzelm@41614
    75
        else
wenzelm@41614
    76
          DYLD_LIBRARY_PATH="$X:$DYLD_LIBRARY_PATH"
wenzelm@41614
    77
        fi
wenzelm@41614
    78
        export DYLD_LIBRARY_PATH
wenzelm@41614
    79
        ;;
wenzelm@41614
    80
      *)
wenzelm@41614
    81
        if [ -z "$LD_LIBRARY_PATH" ]; then
wenzelm@41614
    82
          LD_LIBRARY_PATH="$X"
wenzelm@41614
    83
        else
wenzelm@41614
    84
          LD_LIBRARY_PATH="$X:$LD_LIBRARY_PATH"
wenzelm@41614
    85
        fi
wenzelm@41614
    86
        export LD_LIBRARY_PATH
wenzelm@41614
    87
        ;;
wenzelm@41614
    88
    esac
wenzelm@41614
    89
  done
wenzelm@41614
    90
}
wenzelm@41614
    91
wenzelm@47115
    92
#robust invocation via ISABELLE_JDK_HOME
wenzelm@52443
    93
function isabelle_jdk ()
wenzelm@52443
    94
{
wenzelm@47465
    95
  if [ -z "$ISABELLE_JDK_HOME" ]; then
wenzelm@47465
    96
    echo "Unknown ISABELLE_JDK_HOME -- Java tools unavailable" >&2
wenzelm@47490
    97
    return 127
wenzelm@47465
    98
  else
wenzelm@47465
    99
    local PRG="$1"; shift
wenzelm@47465
   100
    "$ISABELLE_JDK_HOME/bin/$PRG" "$@"
wenzelm@47465
   101
  fi
wenzelm@47115
   102
}
wenzelm@47115
   103
wenzelm@47115
   104
#robust invocation via SCALA_HOME
wenzelm@52443
   105
function isabelle_scala ()
wenzelm@52443
   106
{
wenzelm@47465
   107
  if [ -z "$ISABELLE_JDK_HOME" ]; then
wenzelm@47465
   108
    echo "Unknown ISABELLE_JDK_HOME -- Java tools unavailable" >&2
wenzelm@47490
   109
    return 127
wenzelm@47465
   110
  elif [ -z "$SCALA_HOME" ]; then
wenzelm@47465
   111
    echo "Unknown SCALA_HOME -- Scala unavailable" >&2
wenzelm@47490
   112
    return 127
wenzelm@47465
   113
  else
wenzelm@47465
   114
    local PRG="$1"; shift
wenzelm@47465
   115
    "$SCALA_HOME/bin/$PRG" "$@"
wenzelm@47465
   116
  fi
wenzelm@47115
   117
}
wenzelm@47115
   118
wenzelm@52443
   119
#administrative build
wenzelm@52443
   120
if [ -e "$ISABELLE_HOME/Admin/build" ]; then
wenzelm@52443
   121
  function isabelle_admin_build ()
wenzelm@52443
   122
  {
wenzelm@52443
   123
    "$ISABELLE_HOME/Admin/build" "$@"
wenzelm@52443
   124
  }
wenzelm@52443
   125
else
wenzelm@52443
   126
  function isabelle_admin_build () { return 0; }
wenzelm@52443
   127
fi
wenzelm@52443
   128
wenzelm@53576
   129
#classpath
wenzelm@52443
   130
function classpath ()
wenzelm@52443
   131
{
wenzelm@27908
   132
  for X in "$@"
wenzelm@27908
   133
  do
wenzelm@53576
   134
    if [ -z "$ISABELLE_CLASSPATH" ]; then
wenzelm@53576
   135
      ISABELLE_CLASSPATH="$X"
wenzelm@27908
   136
    else
wenzelm@53580
   137
      ISABELLE_CLASSPATH="$ISABELLE_CLASSPATH:$X"
wenzelm@27908
   138
    fi
wenzelm@27908
   139
  done
wenzelm@53576
   140
  export ISABELLE_CLASSPATH
wenzelm@27908
   141
}
wenzelm@27908
   142
wenzelm@32390
   143
#arrays
wenzelm@32390
   144
function splitarray ()
wenzelm@32390
   145
{
wenzelm@32390
   146
  SPLITARRAY=()
wenzelm@32390
   147
  local IFS="$1"; shift
wenzelm@32390
   148
  for X in $*
wenzelm@32390
   149
  do
wenzelm@32390
   150
    SPLITARRAY["${#SPLITARRAY[@]}"]="$X"
wenzelm@32390
   151
  done
wenzelm@32390
   152
}
wenzelm@32390
   153
wenzelm@48838
   154
wenzelm@48838
   155
# components
wenzelm@48838
   156
wenzelm@32305
   157
ISABELLE_COMPONENTS=""
wenzelm@48838
   158
ISABELLE_COMPONENTS_MISSING=""
wenzelm@48838
   159
wenzelm@48838
   160
#init component tree
wenzelm@32305
   161
function init_component ()
wenzelm@32305
   162
{
wenzelm@32305
   163
  local COMPONENT="$1"
wenzelm@40570
   164
  case "$COMPONENT" in
wenzelm@40570
   165
    /*) ;;
wenzelm@40570
   166
    *)
wenzelm@40570
   167
      echo >&2 "Absolute component path required: \"$COMPONENT\""
wenzelm@40570
   168
      exit 2
wenzelm@40570
   169
      ;;
wenzelm@40570
   170
  esac
wenzelm@32305
   171
wenzelm@48838
   172
  if [ -d "$COMPONENT" ]; then
wenzelm@48838
   173
    if [ -z "$ISABELLE_COMPONENTS" ]; then
wenzelm@48838
   174
      ISABELLE_COMPONENTS="$COMPONENT"
wenzelm@48838
   175
    else
wenzelm@48838
   176
      ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
wenzelm@48838
   177
    fi
wenzelm@48838
   178
  else
wenzelm@48448
   179
    echo >&2 "### Missing Isabelle component: \"$COMPONENT\""
wenzelm@48838
   180
    if [ -z "$ISABELLE_COMPONENTS_MISSING" ]; then
wenzelm@48838
   181
      ISABELLE_COMPONENTS_MISSING="$COMPONENT"
wenzelm@48838
   182
    else
wenzelm@48838
   183
      ISABELLE_COMPONENTS_MISSING="$ISABELLE_COMPONENTS_MISSING:$COMPONENT"
wenzelm@48838
   184
    fi
wenzelm@32305
   185
  fi
wenzelm@48838
   186
wenzelm@32305
   187
  if [ -f "$COMPONENT/etc/settings" ]; then
wenzelm@41760
   188
    source "$COMPONENT/etc/settings"
wenzelm@41760
   189
    local RC="$?"
wenzelm@41760
   190
    if [ "$RC" -ne 0 ]; then
wenzelm@41760
   191
      echo >&2 "Return code $RC from bash script: \"$COMPONENT/etc/settings\""
wenzelm@41760
   192
      exit 2
wenzelm@41760
   193
    fi
wenzelm@32305
   194
  fi
wenzelm@32305
   195
  if [ -f "$COMPONENT/etc/components" ]; then
wenzelm@48838
   196
    init_components "$COMPONENT" "$COMPONENT/etc/components"
wenzelm@48838
   197
  fi
wenzelm@48838
   198
}
wenzelm@48838
   199
wenzelm@48838
   200
#init component forest
wenzelm@48838
   201
function init_components ()
wenzelm@48838
   202
{
wenzelm@48838
   203
  local BASE="$1"
wenzelm@48838
   204
  local CATALOG="$2"
wenzelm@48838
   205
wenzelm@48838
   206
  if [ ! -f "$CATALOG" ]; then
wenzelm@48838
   207
    echo >&2 "Bad component catalog file: \"$CATALOG\""
wenzelm@48838
   208
    exit 2
wenzelm@48838
   209
  fi
wenzelm@48838
   210
  {
wenzelm@48838
   211
    while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
wenzelm@48838
   212
    do
wenzelm@48838
   213
      case "$REPLY" in
wenzelm@48838
   214
        \#* | "") ;;
wenzelm@48838
   215
        /*) init_component "$REPLY" ;;
wenzelm@48838
   216
        *) init_component "$BASE/$REPLY" ;;
wenzelm@48838
   217
      esac
wenzelm@48838
   218
    done
wenzelm@48838
   219
  } < "$CATALOG"
wenzelm@32305
   220
}
wenzelm@32305
   221
wenzelm@32305
   222
#main components
wenzelm@32305
   223
init_component "$ISABELLE_HOME"
wenzelm@48725
   224
[ -d "$ISABELLE_HOME/Admin" ] && init_component "$ISABELLE_HOME/Admin"
wenzelm@32321
   225
[ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
wenzelm@2299
   226
wenzelm@48838
   227
wenzelm@21490
   228
#ML system identifier
wenzelm@6413
   229
if [ -z "$ML_PLATFORM" ]; then
wenzelm@6413
   230
  ML_IDENTIFIER="$ML_SYSTEM"
wenzelm@6413
   231
else
wenzelm@6413
   232
  ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
wenzelm@6413
   233
fi
wenzelm@21468
   234
wenzelm@48838
   235
ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
wenzelm@48838
   236
wenzelm@47748
   237
#enforce JAVA_HOME
wenzelm@47748
   238
export JAVA_HOME="$ISABELLE_JDK_HOME"
wenzelm@47748
   239
wenzelm@48495
   240
#build condition etc.
wenzelm@48495
   241
case "$ML_SYSTEM" in
wenzelm@48495
   242
  polyml*)
wenzelm@48495
   243
    ISABELLE_POLYML="true"
wenzelm@48495
   244
    ;;
wenzelm@48495
   245
  *)
wenzelm@48495
   246
    ISABELLE_POLYML=""
wenzelm@48495
   247
    ;;
wenzelm@48495
   248
esac
wenzelm@48495
   249
wenzelm@2299
   250
set +o allexport
wenzelm@7770
   251
wenzelm@7770
   252
fi