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