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