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