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