Admin/makebin
author wenzelm
Wed Sep 21 21:00:57 2005 +0200 (2005-09-21)
changeset 17575 c45677c1aea0
parent 17573 4de614cc6509
child 17660 94bbe14c088e
permissions -rwxr-xr-x
tuned;
wenzelm@12721
     1
#!/usr/bin/env bash
wenzelm@10082
     2
#
wenzelm@10082
     3
# $Id$
wenzelm@10082
     4
#
wenzelm@10082
     5
# makebin -- make Isabelle logic images for current platform.
wenzelm@10082
     6
wenzelm@10082
     7
wenzelm@10082
     8
## global settings
wenzelm@10082
     9
wenzelm@10082
    10
DISTBASE=~/tmp/isadist
wenzelm@12427
    11
TMP="/var/tmp/isabelle-makebin$$"
wenzelm@10082
    12
wenzelm@10082
    13
TAR=tar
wenzelm@10082
    14
type -path gtar >/dev/null && TAR=gtar
wenzelm@10082
    15
wenzelm@10097
    16
export THIS_IS_ISABELLE_BUILD=true
wenzelm@10097
    17
wenzelm@10082
    18
wenzelm@10082
    19
## diagnostics
wenzelm@10082
    20
wenzelm@10082
    21
PRG=$(basename "$0")
wenzelm@10082
    22
wenzelm@10082
    23
function usage()
wenzelm@10082
    24
{
wenzelm@10082
    25
  echo
wenzelm@12827
    26
  echo "Usage: $PRG [OPTIONS] ARCHIVE"
wenzelm@10082
    27
  echo
wenzelm@12827
    28
  echo "  Options are:"
wenzelm@13001
    29
  echo "    -l           produce library"
wenzelm@13001
    30
  echo "    -n           dry run"
wenzelm@12827
    31
  echo
wenzelm@12827
    32
  echo "  Precompile Isabelle for the current platform."
wenzelm@10082
    33
  echo
wenzelm@10082
    34
  exit 1
wenzelm@10082
    35
}
wenzelm@10082
    36
wenzelm@10082
    37
function fail()
wenzelm@10082
    38
{
wenzelm@10082
    39
  echo "$1" >&2
wenzelm@10082
    40
  exit 2
wenzelm@10082
    41
}
wenzelm@10082
    42
wenzelm@10082
    43
wenzelm@10082
    44
## process command line
wenzelm@10082
    45
wenzelm@12827
    46
# options
wenzelm@12827
    47
wenzelm@12827
    48
DO_LIBRARY=""
wenzelm@13001
    49
DRY_RUN=""
wenzelm@12827
    50
wenzelm@13001
    51
while getopts "ln" OPT
wenzelm@12827
    52
do
wenzelm@12827
    53
  case "$OPT" in
wenzelm@12827
    54
    l)
wenzelm@12827
    55
      DO_LIBRARY=true
wenzelm@12827
    56
      ;;
wenzelm@13001
    57
    n)
wenzelm@13001
    58
      DRY_RUN=true
wenzelm@12827
    59
      ;;
wenzelm@12827
    60
    \?)
wenzelm@12827
    61
      usage
wenzelm@12827
    62
      ;;
wenzelm@12827
    63
  esac
wenzelm@12827
    64
done
wenzelm@12827
    65
wenzelm@12827
    66
shift $(($OPTIND - 1))
wenzelm@12827
    67
wenzelm@12827
    68
wenzelm@12827
    69
# args
wenzelm@12827
    70
wenzelm@10082
    71
[ "$#" -gt 1 ] && usage
wenzelm@10082
    72
wenzelm@10082
    73
ARCHIVE="$1"; shift
wenzelm@10082
    74
wenzelm@10082
    75
wenzelm@10082
    76
## main
wenzelm@10082
    77
wenzelm@10082
    78
[ ! -f "$ARCHIVE" ] && fail "Bad archive file $ARCHIVE"
wenzelm@10082
    79
ARCHIVE_BASE=$(basename "$ARCHIVE")
wenzelm@10082
    80
ARCHIVE_DIR=$(cd $(dirname "$ARCHIVE"); echo "$PWD")
wenzelm@10082
    81
ARCHIVE_FULL="$ARCHIVE_DIR/$ARCHIVE_BASE"
wenzelm@10082
    82
wenzelm@10082
    83
ISABELLE_NAME=$(basename "$ARCHIVE_BASE" .tar.gz)
wenzelm@10082
    84
ISABELLE_HOME="$TMP/$ISABELLE_NAME"
wenzelm@10082
    85
wenzelm@10082
    86
wenzelm@10082
    87
# build logics
wenzelm@10082
    88
wenzelm@10082
    89
mkdir "$TMP" || fail "Cannot create directory $TMP"
wenzelm@10082
    90
wenzelm@10082
    91
cd "$TMP"
wenzelm@10087
    92
"$TAR" xzf "$ARCHIVE_FULL"
wenzelm@10082
    93
cd "$ISABELLE_NAME"
wenzelm@10082
    94
kleing@14633
    95
# FIXME: ugly hack to get proper HOL4 image
kleing@14633
    96
# needs HOL4 proof terms installed in ~/isabelle/proofs
kleing@14633
    97
# desperately needs fix for next release!
kleing@14633
    98
cat > src/HOL/Import/HOL/ROOT.ML <<EOF
kleing@14633
    99
with_path ".." use_thy "HOL4Compat";
kleing@14633
   100
with_path ".." use_thy "HOL4Syntax";
kleing@14633
   101
use_thy "HOL4Prob";
kleing@14633
   102
use_thy "HOL4";
kleing@14633
   103
EOF
kleing@14633
   104
wenzelm@17575
   105
perl -pi \
wenzelm@17575
   106
  -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1":;' \
wenzelm@17575
   107
  -e 's:^HOL_USEDIR_OPTIONS=.*$:HOL_USEDIR_OPTIONS="-p 2":;' \
wenzelm@17575
   108
  etc/settings
wenzelm@17575
   109
wenzelm@13001
   110
if [ -n "$DO_LIBRARY" ]; then
wenzelm@17575
   111
  perl -pi -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1 -i true -d pdf -V outline=/proof,/ML":;' \
wenzelm@13001
   112
    etc/settings
wenzelm@13001
   113
fi
wenzelm@11576
   114
wenzelm@10082
   115
ISABELLE_HOME_USER=$(./bin/isatool getenv -b ISABELLE_HOME_USER)
wenzelm@10082
   116
[ -f "$ISABELLE_HOME_USER/etc/settings" ] && \
wenzelm@10082
   117
  echo "### WARNING!  Personal Isabelle settings present. " >&2
wenzelm@10082
   118
wenzelm@10082
   119
COMPILER=$(./bin/isatool getenv -b ML_IDENTIFIER)
wenzelm@10082
   120
PLATFORM=$(./bin/isatool getenv -b ML_PLATFORM)
wenzelm@10082
   121
wenzelm@13001
   122
if [ -n "$DRY_RUN" ]; then
wenzelm@12827
   123
  mkdir -p "heaps/$COMPILER/log"
wenzelm@10082
   124
  touch "heaps/$COMPILER/HOL"
wenzelm@12827
   125
  touch "heaps/$COMPILER/log/HOL.gz"
kleing@14024
   126
  touch "heaps/$COMPILER/HOL-Complex"
kleing@14024
   127
  touch "heaps/$COMPILER/log/HOL-Complex.gz"
kleing@14633
   128
  touch "heaps/$COMPILER/HOL4"
kleing@14633
   129
  touch "heaps/$COMPILER/log/HOL4.gz"
wenzelm@10082
   130
  touch "heaps/$COMPILER/ZF"
wenzelm@12827
   131
  touch "heaps/$COMPILER/log/ZF.gz"
wenzelm@12827
   132
  mkdir browser_info
wenzelm@13001
   133
elif [ -n "$DO_LIBRARY" ]; then
wenzelm@13001
   134
  ./build -bait
wenzelm@10082
   135
else
kleing@14024
   136
  ./build -b -m HOL-Complex HOL
wenzelm@17575
   137
  ./build -b -m HOL4 HOL
wenzelm@10082
   138
  ./build -b ZF
wenzelm@10082
   139
  rm -f "heaps/$COMPILER/Pure" "heaps/$COMPILER/FOL"
wenzelm@10082
   140
fi
wenzelm@10082
   141
wenzelm@10082
   142
wenzelm@10082
   143
# prepare result
wenzelm@10082
   144
wenzelm@10082
   145
cd "$TMP"
wenzelm@10082
   146
wenzelm@10082
   147
chmod -R g=o "$TMP"
wenzelm@10082
   148
chgrp -R isabelle "$TMP"
wenzelm@10082
   149
wenzelm@13001
   150
if [ -n "$DO_LIBRARY" ]; then
wenzelm@13001
   151
  "$TAR" cf "${ISABELLE_NAME}_library.tar" $ISABELLE_NAME/browser_info && \
wenzelm@13001
   152
    gzip -f "${ISABELLE_NAME}_library.tar"
wenzelm@13001
   153
    cp -f "${ISABELLE_NAME}_library.tar.gz" "$ARCHIVE_DIR"
wenzelm@13001
   154
else
kleing@14633
   155
  for IMG in HOL HOL-Complex HOL4 ZF
wenzelm@13001
   156
  do
wenzelm@13001
   157
    "$TAR" cf "${IMG}_$PLATFORM.tar" \
wenzelm@13001
   158
      "$ISABELLE_NAME/heaps/$COMPILER/$IMG" \
wenzelm@13001
   159
      "$ISABELLE_NAME/heaps/$COMPILER/log/$IMG.gz"
wenzelm@13001
   160
    gzip -f "${IMG}_$PLATFORM.tar"
wenzelm@13001
   161
    cp -f "${IMG}_$PLATFORM.tar.gz" "$ARCHIVE_DIR"
wenzelm@13001
   162
  done
wenzelm@13001
   163
fi
wenzelm@10082
   164
wenzelm@10082
   165
wenzelm@10082
   166
# clean up
wenzelm@10082
   167
cd /tmp
wenzelm@10082
   168
rm -rf "$TMP"