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