Admin/makebin
author wenzelm
Tue, 10 Jul 2007 16:45:05 +0200
changeset 23702 58ca991e0702
parent 23137 ae4110f7f88f
child 25183 261d6791952c
permissions -rwxr-xr-x
removed no_state markup -- produce empty state; Markup.add_mode;
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
12427
37cfec8dfe8e use /var/tmp (which happens to be more spacious on atbroy37);
wenzelm
parents: 11576
diff changeset
    10
TMP="/var/tmp/isabelle-makebin$$"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    11
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    12
TAR=tar
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    13
type -path gtar >/dev/null && TAR=gtar
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    14
10097
1db5bd97f6a3 THIS_IS_ISABELLE_BUILD;
wenzelm
parents: 10090
diff changeset
    15
export THIS_IS_ISABELLE_BUILD=true
1db5bd97f6a3 THIS_IS_ISABELLE_BUILD;
wenzelm
parents: 10090
diff changeset
    16
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    17
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    18
## diagnostics
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
PRG=$(basename "$0")
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
function usage()
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
  echo
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    25
  echo "Usage: $PRG [OPTIONS] ARCHIVE"
10082
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 "  Options are:"
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    28
  echo "    -l           produce library"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    29
  echo "    -n           dry run"
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    30
  echo
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    31
  echo "  Precompile Isabelle for the current platform."
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    32
  echo
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    33
  exit 1
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    34
}
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    35
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    36
function fail()
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
  echo "$1" >&2
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    39
  exit 2
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    40
}
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    41
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
## process command line
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    44
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    45
# options
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    46
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    47
DO_LIBRARY=""
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    48
DRY_RUN=""
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    49
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    50
while getopts "ln" OPT
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    51
do
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    52
  case "$OPT" in
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    53
    l)
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    54
      DO_LIBRARY=true
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    55
      ;;
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    56
    n)
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    57
      DRY_RUN=true
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    58
      ;;
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    59
    \?)
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    60
      usage
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    61
      ;;
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    62
  esac
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    63
done
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    64
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    65
shift $(($OPTIND - 1))
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    66
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    67
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    68
# args
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
    69
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    70
[ "$#" -gt 1 ] && usage
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    71
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    72
ARCHIVE="$1"; shift
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
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    75
## main
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
[ ! -f "$ARCHIVE" ] && fail "Bad archive file $ARCHIVE"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    78
ARCHIVE_BASE=$(basename "$ARCHIVE")
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    79
ARCHIVE_DIR=$(cd $(dirname "$ARCHIVE"); echo "$PWD")
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    80
ARCHIVE_FULL="$ARCHIVE_DIR/$ARCHIVE_BASE"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    81
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    82
ISABELLE_NAME=$(basename "$ARCHIVE_BASE" .tar.gz)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    83
ISABELLE_HOME="$TMP/$ISABELLE_NAME"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    84
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    85
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    86
# build logics
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
mkdir "$TMP" || fail "Cannot create directory $TMP"
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
cd "$TMP"
10087
wenzelm
parents: 10082
diff changeset
    91
"$TAR" xzf "$ARCHIVE_FULL"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    92
cd "$ISABELLE_NAME"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
    93
17575
wenzelm
parents: 17573
diff changeset
    94
perl -pi \
wenzelm
parents: 17573
diff changeset
    95
  -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1":;' \
wenzelm
parents: 17573
diff changeset
    96
  -e 's:^HOL_USEDIR_OPTIONS=.*$:HOL_USEDIR_OPTIONS="-p 2":;' \
wenzelm
parents: 17573
diff changeset
    97
  etc/settings
wenzelm
parents: 17573
diff changeset
    98
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
    99
if [ -n "$DO_LIBRARY" ]; then
17575
wenzelm
parents: 17573
diff changeset
   100
  perl -pi -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1 -i true -d pdf -V outline=/proof,/ML":;' \
13001
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
23137
ae4110f7f88f removed HOL4 image, which seldom works;
wenzelm
parents: 17660
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"