Admin/makebin
author wenzelm
Wed, 15 Feb 2006 21:34:55 +0100
changeset 19046 bc5c6c9b114e
parent 17660 94bbe14c088e
child 23137 ae4110f7f88f
permissions -rwxr-xr-x
removed distinct, renamed gen_distinct to distinct;
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
14633
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
    94
# FIXME: ugly hack to get proper HOL4 image
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
    95
# needs HOL4 proof terms installed in ~/isabelle/proofs
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
    96
# desperately needs fix for next release!
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
    97
cat > src/HOL/Import/HOL/ROOT.ML <<EOF
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
    98
with_path ".." use_thy "HOL4Compat";
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
    99
with_path ".." use_thy "HOL4Syntax";
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
   100
use_thy "HOL4Prob";
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
   101
use_thy "HOL4";
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
   102
EOF
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
   103
17575
wenzelm
parents: 17573
diff changeset
   104
perl -pi \
wenzelm
parents: 17573
diff changeset
   105
  -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1":;' \
wenzelm
parents: 17573
diff changeset
   106
  -e 's:^HOL_USEDIR_OPTIONS=.*$:HOL_USEDIR_OPTIONS="-p 2":;' \
wenzelm
parents: 17573
diff changeset
   107
  etc/settings
wenzelm
parents: 17573
diff changeset
   108
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   109
if [ -n "$DO_LIBRARY" ]; then
17575
wenzelm
parents: 17573
diff changeset
   110
  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
   111
    etc/settings
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   112
fi
11576
c418146c4763 activate default ISABELLE_USEDIR_OPTIONS for precompiled distribution;
wenzelm
parents: 10307
diff changeset
   113
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   114
ISABELLE_HOME_USER=$(./bin/isatool getenv -b ISABELLE_HOME_USER)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   115
[ -f "$ISABELLE_HOME_USER/etc/settings" ] && \
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   116
  echo "### WARNING!  Personal Isabelle settings present. " >&2
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   117
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   118
COMPILER=$(./bin/isatool getenv -b ML_IDENTIFIER)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   119
PLATFORM=$(./bin/isatool getenv -b ML_PLATFORM)
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   120
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   121
if [ -n "$DRY_RUN" ]; then
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   122
  mkdir -p "heaps/$COMPILER/log"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   123
  touch "heaps/$COMPILER/HOL"
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   124
  touch "heaps/$COMPILER/log/HOL.gz"
14024
213dcc39358f HOL-Real -> HOL-Complex
kleing
parents: 13001
diff changeset
   125
  touch "heaps/$COMPILER/HOL-Complex"
213dcc39358f HOL-Real -> HOL-Complex
kleing
parents: 13001
diff changeset
   126
  touch "heaps/$COMPILER/log/HOL-Complex.gz"
14633
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
   127
  touch "heaps/$COMPILER/HOL4"
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
   128
  touch "heaps/$COMPILER/log/HOL4.gz"
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   129
  touch "heaps/$COMPILER/ZF"
12827
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   130
  touch "heaps/$COMPILER/log/ZF.gz"
05c13f5a515d options -l and -t;
wenzelm
parents: 12721
diff changeset
   131
  mkdir browser_info
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   132
elif [ -n "$DO_LIBRARY" ]; then
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   133
  ./build -bait
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   134
else
14024
213dcc39358f HOL-Real -> HOL-Complex
kleing
parents: 13001
diff changeset
   135
  ./build -b -m HOL-Complex HOL
17575
wenzelm
parents: 17573
diff changeset
   136
  ./build -b -m HOL4 HOL
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   137
  ./build -b ZF
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   138
  rm -f "heaps/$COMPILER/Pure" "heaps/$COMPILER/FOL"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   139
fi
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   140
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   141
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   142
# prepare result
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   143
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   144
cd "$TMP"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   145
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   146
chmod -R g=o "$TMP"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   147
chgrp -R isabelle "$TMP"
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   148
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   149
if [ -n "$DO_LIBRARY" ]; then
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   150
  "$TAR" cf "${ISABELLE_NAME}_library.tar" $ISABELLE_NAME/browser_info && \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   151
    gzip -f "${ISABELLE_NAME}_library.tar"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   152
    cp -f "${ISABELLE_NAME}_library.tar.gz" "$ARCHIVE_DIR"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   153
else
14633
8553a957cffa add HOL4 image, needs fixing
kleing
parents: 14024
diff changeset
   154
  for IMG in HOL HOL-Complex HOL4 ZF
13001
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   155
  do
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   156
    "$TAR" cf "${IMG}_$PLATFORM.tar" \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   157
      "$ISABELLE_NAME/heaps/$COMPILER/$IMG" \
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   158
      "$ISABELLE_NAME/heaps/$COMPILER/log/$IMG.gz"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   159
    gzip -f "${IMG}_$PLATFORM.tar"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   160
    cp -f "${IMG}_$PLATFORM.tar.gz" "$ARCHIVE_DIR"
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   161
  done
40ba2eee948e clarified -l option;
wenzelm
parents: 12985
diff changeset
   162
fi
10082
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   163
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   164
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   165
# clean up
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   166
cd /tmp
7c2021b7c664 make Isabelle logic images for current platform;
wenzelm
parents:
diff changeset
   167
rm -rf "$TMP"