Admin/makebin
author paulson
Tue, 10 Feb 2004 12:02:11 +0100
changeset 14378 69c4d5997669
parent 14024 213dcc39358f
child 14633 8553a957cffa
permissions -rwxr-xr-x
generic of_nat and of_int functions, and generalization of iszero and neg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12721
226fc0e2e7e3 #!/usr/bin/env bash;
wenzelm
parents: 12427
diff changeset
     1
#!/usr/bin/env bash
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     2
#
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     3
# $Id$
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     4
#
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     5
# makebin -- make Isabelle logic images for current platform.
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     6
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     7
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     8
## global settings
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
     9
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    10
DISTBASE=~/tmp/isadist
12427
37cfec8dfe8e use /var/tmp (which happens to be more spacious on atbroy37);
wenzelm
parents: 11576
diff changeset
    11
TMP="/var/tmp/isabelle-makebin$$"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    12
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    13
TAR=tar
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    14
type -path gtar >/dev/null && TAR=gtar
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    15
10097
1db5bd97f6a3 THIS_IS_ISABELLE_BUILD;
wenzelm
parents: 10090
diff changeset
    16
export THIS_IS_ISABELLE_BUILD=true
12985
9db054a40247 export THIS_IS_ISABELLE_ADMIN=true;
wenzelm
parents: 12830
diff changeset
    17
export THIS_IS_ISABELLE_ADMIN=true
10097
1db5bd97f6a3 THIS_IS_ISABELLE_BUILD;
wenzelm
parents: 10090
diff changeset
    18
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    19
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    20
## diagnostics
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    21
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    22
PRG=$(basename "$0")
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    23
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    24
function usage()
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    25
{
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    26
  echo
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    27
  echo "Usage: $PRG [OPTIONS] ARCHIVE"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    28
  echo
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    29
  echo "  Options are:"
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    30
  echo "    -l           produce library"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    31
  echo "    -n           dry run"
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    32
  echo
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    33
  echo "  Precompile Isabelle for the current platform."
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    34
  echo
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    35
  exit 1
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    36
}
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    37
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    38
function fail()
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    39
{
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    40
  echo "$1" >&2
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    41
  exit 2
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    42
}
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    43
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    44
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    45
## process command line
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    46
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    47
# options
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    48
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    49
DO_LIBRARY=""
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    50
DRY_RUN=""
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    51
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    52
while getopts "ln" OPT
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    53
do
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    54
  case "$OPT" in
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    55
    l)
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    56
      DO_LIBRARY=true
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    57
      ;;
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    58
    n)
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    59
      DRY_RUN=true
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    60
      ;;
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    61
    \?)
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    62
      usage
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    63
      ;;
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    64
  esac
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    65
done
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    66
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    67
shift $(($OPTIND - 1))
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    68
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    69
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    70
# args
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    71
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    72
[ "$#" -gt 1 ] && usage
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    73
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    74
ARCHIVE="$1"; shift
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    75
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    76
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    77
## main
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    78
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    79
[ ! -f "$ARCHIVE" ] && fail "Bad archive file $ARCHIVE"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    80
ARCHIVE_BASE=$(basename "$ARCHIVE")
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    81
ARCHIVE_DIR=$(cd $(dirname "$ARCHIVE"); echo "$PWD")
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    82
ARCHIVE_FULL="$ARCHIVE_DIR/$ARCHIVE_BASE"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    83
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    84
ISABELLE_NAME=$(basename "$ARCHIVE_BASE" .tar.gz)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    85
ISABELLE_HOME="$TMP/$ISABELLE_NAME"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    86
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    87
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    88
# build logics
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    89
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    90
mkdir "$TMP" || fail "Cannot create directory $TMP"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    91
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    92
cd "$TMP"
10087
wenzelm
parents: 10082
diff changeset
    93
"$TAR" xzf "$ARCHIVE_FULL"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    94
cd "$ISABELLE_NAME"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    95
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    96
if [ -n "$DO_LIBRARY" ]; then
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    97
  perl -pi -e 's/^ISABELLE_USEDIR_OPTIONS=.*$/ISABELLE_USEDIR_OPTIONS="-i true -d pdf"/' \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    98
    etc/settings
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    99
else
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   100
  perl -pi -e 's/^ISABELLE_USEDIR_OPTIONS=.*$/ISABELLE_USEDIR_OPTIONS="-p 2"/' \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   101
    etc/settings
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   102
fi
11576
c418146c4763 activate default ISABELLE_USEDIR_OPTIONS for precompiled distribution;
wenzelm
parents: 10307
diff changeset
   103
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   104
ISABELLE_HOME_USER=$(./bin/isatool getenv -b ISABELLE_HOME_USER)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   105
[ -f "$ISABELLE_HOME_USER/etc/settings" ] && \
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   106
  echo "### WARNING!  Personal Isabelle settings present. " >&2
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   107
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   108
COMPILER=$(./bin/isatool getenv -b ML_IDENTIFIER)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   109
PLATFORM=$(./bin/isatool getenv -b ML_PLATFORM)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   110
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   111
if [ -n "$DRY_RUN" ]; then
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   112
  mkdir -p "heaps/$COMPILER/log"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   113
  touch "heaps/$COMPILER/HOL"
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   114
  touch "heaps/$COMPILER/log/HOL.gz"
14024
213dcc39358f HOL-Real -> HOL-Complex
kleing
parents: 13001
diff changeset
   115
  touch "heaps/$COMPILER/HOL-Complex"
213dcc39358f HOL-Real -> HOL-Complex
kleing
parents: 13001
diff changeset
   116
  touch "heaps/$COMPILER/log/HOL-Complex.gz"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   117
  touch "heaps/$COMPILER/ZF"
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   118
  touch "heaps/$COMPILER/log/ZF.gz"
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   119
  mkdir browser_info
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   120
elif [ -n "$DO_LIBRARY" ]; then
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   121
  ./build -bait
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   122
else
14024
213dcc39358f HOL-Real -> HOL-Complex
kleing
parents: 13001
diff changeset
   123
  ./build -b -m HOL-Complex HOL
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   124
  ./build -b ZF
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   125
  rm -f "heaps/$COMPILER/Pure" "heaps/$COMPILER/FOL"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   126
fi
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   127
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   128
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   129
# prepare result
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   130
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   131
cd "$TMP"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   132
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   133
chmod -R g=o "$TMP"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   134
chgrp -R isabelle "$TMP"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   135
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   136
if [ -n "$DO_LIBRARY" ]; then
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   137
  "$TAR" cf "${ISABELLE_NAME}_library.tar" $ISABELLE_NAME/browser_info && \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   138
    gzip -f "${ISABELLE_NAME}_library.tar"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   139
    cp -f "${ISABELLE_NAME}_library.tar.gz" "$ARCHIVE_DIR"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   140
else
14024
213dcc39358f HOL-Real -> HOL-Complex
kleing
parents: 13001
diff changeset
   141
  for IMG in HOL HOL-Complex ZF
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   142
  do
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   143
    "$TAR" cf "${IMG}_$PLATFORM.tar" \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   144
      "$ISABELLE_NAME/heaps/$COMPILER/$IMG" \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   145
      "$ISABELLE_NAME/heaps/$COMPILER/log/$IMG.gz"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   146
    gzip -f "${IMG}_$PLATFORM.tar"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   147
    cp -f "${IMG}_$PLATFORM.tar.gz" "$ARCHIVE_DIR"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   148
  done
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   149
fi
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   150
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   151
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   152
# clean up
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   153
cd /tmp
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   154
rm -rf "$TMP"