Admin/polyml/build
author wenzelm
Wed, 16 Mar 2016 22:19:08 +0100
changeset 62645 a2351f82bc48
parent 62387 ad3eb2889f9a
child 63229 f951c624c1a1
permissions -rwxr-xr-x
eliminated spurious Unicode, which is in conflict with Isabelle symbol interpretation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38468
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     2
#
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     3
# Multi-platform build script for Poly/ML
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     4
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     5
THIS="$(cd "$(dirname "$0")"; pwd)"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     6
PRG="$(basename "$0")"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     7
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     8
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
     9
# diagnostics
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    10
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    11
function usage()
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    12
{
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    13
  echo
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    14
  echo "Usage: $PRG SOURCE TARGET [OPTIONS]"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    15
  echo
38472
3c5716b2e7b6 pro-forma support for further platforms;
wenzelm
parents: 38468
diff changeset
    16
  echo "  Build Poly/ML in SOURCE directory for given platform in TARGET,"
3c5716b2e7b6 pro-forma support for further platforms;
wenzelm
parents: 38468
diff changeset
    17
  echo "  using the usual Isabelle platform identifiers."
38468
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    18
  echo
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    19
  echo "  Additional options for ./configure may be given, e.g. --with-gmp"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    20
  echo
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    21
  exit 1
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    22
}
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    23
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    24
function fail()
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    25
{
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    26
  echo "$1" >&2
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    27
  exit 2
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    28
}
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    29
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    30
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    31
# command line args
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    32
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    33
[ "$#" -eq 0 ] && usage
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    34
SOURCE="$1"; shift
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    35
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    36
[ "$#" -eq 0 ] && usage
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    37
TARGET="$1"; shift
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    38
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    39
USER_OPTIONS=("$@")
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    40
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    41
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    42
# main
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    43
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    44
[ -d "$SOURCE" ] || fail "Bad source directory: \"$SOURCE\""
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    45
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    46
case "$TARGET" in
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    47
  x86-linux)
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    48
    OPTIONS=()
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    49
    ;;
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    50
  x86_64-linux)
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    51
    OPTIONS=()
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    52
    ;;
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    53
  x86-darwin)
46875
162b0c46c559 updated polyml/build option to prefer included libffi;
wenzelm
parents: 39620
diff changeset
    54
    OPTIONS=(--build=i686-darwin CFLAGS='-arch i686 -O3 -I../libffi/include'
162b0c46c559 updated polyml/build option to prefer included libffi;
wenzelm
parents: 39620
diff changeset
    55
      CXXFLAGS='-arch i686 -O3 -I../libffi/include' CCASFLAGS='-arch i686 -O3'
38585
62b414d8051c reactivated -segprot options, just to make double-sure;
wenzelm
parents: 38472
diff changeset
    56
      LDFLAGS='-segprot POLY rwx rwx')
38468
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    57
    ;;
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    58
  x86_64-darwin)
46875
162b0c46c559 updated polyml/build option to prefer included libffi;
wenzelm
parents: 39620
diff changeset
    59
   OPTIONS=(--build=x86_64-darwin CFLAGS='-arch x86_64 -O3 -I../libffi/include'
162b0c46c559 updated polyml/build option to prefer included libffi;
wenzelm
parents: 39620
diff changeset
    60
     CXXFLAGS='-arch x86_64 -O3 -I../libffi/include' CCASFLAGS='-arch x86_64'
162b0c46c559 updated polyml/build option to prefer included libffi;
wenzelm
parents: 39620
diff changeset
    61
     LDFLAGS='-segprot POLY rwx rwx')
38468
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    62
    ;;
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    63
  x86-cygwin)
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    64
    OPTIONS=()
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    65
    ;;
47763
15936c7b2fa3 mingw is windows (still inactive);
wenzelm
parents: 47458
diff changeset
    66
  x86-windows)
61181
b6b5e41d261b updated to polyml-5.5.3-20150916 (polyml git version cb1b36caa242);
wenzelm
parents: 61155
diff changeset
    67
    OPTIONS=(--host=i686-w32-mingw32 CPPFLAGS='-I/mingw32/include' --disable-windows-gui)
60961
49d1ea25f1a4 more complete build;
wenzelm
parents: 60960
diff changeset
    68
    PATH="/mingw32/bin:$PATH"
47763
15936c7b2fa3 mingw is windows (still inactive);
wenzelm
parents: 47458
diff changeset
    69
    ;;
15936c7b2fa3 mingw is windows (still inactive);
wenzelm
parents: 47458
diff changeset
    70
  x86_64-windows)
61181
b6b5e41d261b updated to polyml-5.5.3-20150916 (polyml git version cb1b36caa242);
wenzelm
parents: 61155
diff changeset
    71
    OPTIONS=(--host=x86_64-w64-mingw32 CPPFLAGS='-I/mingw64/include' --disable-windows-gui)
61071
c6ac3c3fbb85 support x86_64-windows;
wenzelm
parents: 60979
diff changeset
    72
    PATH="/mingw64/bin:$PATH"
47458
29b3f9cba73d minimal support for x86-mingw;
wenzelm
parents: 46875
diff changeset
    73
    ;;
38468
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    74
  *)
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    75
    fail "Bad platform identifier: \"$TARGET\""
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    76
    ;;
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    77
esac
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    78
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    79
(
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    80
  cd "$SOURCE"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    81
  make distclean
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    82
62387
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 61181
diff changeset
    83
  { ./configure --prefix="$PWD/$TARGET" "${OPTIONS[@]}" --enable-intinf-as-int "${USER_OPTIONS[@]}" && \
38468
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    84
    make compiler && \
39620
ff694044a55b make compiler doubly sure;
wenzelm
parents: 38585
diff changeset
    85
    make compiler && \
38468
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    86
    make install; } || fail "Build failed"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    87
)
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    88
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    89
mkdir -p "$TARGET"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    90
mv "$SOURCE/$TARGET/bin/"* "$TARGET/"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    91
mv "$SOURCE/$TARGET/lib/"* "$TARGET/"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    92
rmdir "$SOURCE/$TARGET/bin" "$SOURCE/$TARGET/lib"
01d70ada9284 multi-platform build script for Poly/ML;
wenzelm
parents:
diff changeset
    93
rm -rf "$SOURCE/$TARGET/share"
51042
f024975be336 better apply peflags at build time, to avoid antivirus getting nervous about changing executables;
wenzelm
parents: 47763
diff changeset
    94
60960
1fd5db0e2b34 support for native x86-windows via MinGW32;
wenzelm
parents: 56958
diff changeset
    95
case "$TARGET" in
1fd5db0e2b34 support for native x86-windows via MinGW32;
wenzelm
parents: 56958
diff changeset
    96
  x86-cygwin)
1fd5db0e2b34 support for native x86-windows via MinGW32;
wenzelm
parents: 56958
diff changeset
    97
    peflags -x8192000 -z500 "$TARGET/poly.exe"
1fd5db0e2b34 support for native x86-windows via MinGW32;
wenzelm
parents: 56958
diff changeset
    98
    ;;
1fd5db0e2b34 support for native x86-windows via MinGW32;
wenzelm
parents: 56958
diff changeset
    99
  x86-windows)
60979
fb3a641bc914 clarified x86-windows setup;
wenzelm
parents: 60972
diff changeset
   100
    for X in libgcc_s_dw2-1.dll libgmp-10.dll libstdc++-6.dll
60968
24c53d220431 include libgmp;
wenzelm
parents: 60961
diff changeset
   101
    do
24c53d220431 include libgmp;
wenzelm
parents: 60961
diff changeset
   102
      cp "/mingw32/bin/$X" "$TARGET/."
24c53d220431 include libgmp;
wenzelm
parents: 60961
diff changeset
   103
    done
60960
1fd5db0e2b34 support for native x86-windows via MinGW32;
wenzelm
parents: 56958
diff changeset
   104
    ;;
61071
c6ac3c3fbb85 support x86_64-windows;
wenzelm
parents: 60979
diff changeset
   105
  x86_64-windows)
c6ac3c3fbb85 support x86_64-windows;
wenzelm
parents: 60979
diff changeset
   106
    for X in libgcc_s_seh-1.dll libgmp-10.dll libstdc++-6.dll
c6ac3c3fbb85 support x86_64-windows;
wenzelm
parents: 60979
diff changeset
   107
    do
c6ac3c3fbb85 support x86_64-windows;
wenzelm
parents: 60979
diff changeset
   108
      cp "/mingw64/bin/$X" "$TARGET/."
c6ac3c3fbb85 support x86_64-windows;
wenzelm
parents: 60979
diff changeset
   109
    done
c6ac3c3fbb85 support x86_64-windows;
wenzelm
parents: 60979
diff changeset
   110
    ;;
60960
1fd5db0e2b34 support for native x86-windows via MinGW32;
wenzelm
parents: 56958
diff changeset
   111
esac