Admin/polyml/build
author desharna
Mon, 06 Oct 2014 13:34:24 +0200
changeset 58569 3f61adcc1fc9
parent 56958 b2c2f74d1c93
child 60960 1fd5db0e2b34
permissions -rwxr-xr-x
add 'ctr_transfers' to 'fp_sugar'

#!/usr/bin/env bash
#
# Multi-platform build script for Poly/ML

THIS="$(cd "$(dirname "$0")"; pwd)"
PRG="$(basename "$0")"


# diagnostics

function usage()
{
  echo
  echo "Usage: $PRG SOURCE TARGET [OPTIONS]"
  echo
  echo "  Build Poly/ML in SOURCE directory for given platform in TARGET,"
  echo "  using the usual Isabelle platform identifiers."
  echo
  echo "  Additional options for ./configure may be given, e.g. --with-gmp"
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


# command line args

[ "$#" -eq 0 ] && usage
SOURCE="$1"; shift

[ "$#" -eq 0 ] && usage
TARGET="$1"; shift

USER_OPTIONS=("$@")


# main

[ -d "$SOURCE" ] || fail "Bad source directory: \"$SOURCE\""

case "$TARGET" in
  x86-linux)
    OPTIONS=()
    ;;
  x86_64-linux)
    OPTIONS=()
    ;;
  x86-darwin)
    OPTIONS=(--build=i686-darwin CFLAGS='-arch i686 -O3 -I../libffi/include'
      CXXFLAGS='-arch i686 -O3 -I../libffi/include' CCASFLAGS='-arch i686 -O3'
      LDFLAGS='-segprot POLY rwx rwx')
    ;;
  x86_64-darwin)
   OPTIONS=(--build=x86_64-darwin CFLAGS='-arch x86_64 -O3 -I../libffi/include'
     CXXFLAGS='-arch x86_64 -O3 -I../libffi/include' CCASFLAGS='-arch x86_64'
     LDFLAGS='-segprot POLY rwx rwx')
    ;;
  x86-cygwin)
    OPTIONS=()
    ;;
  x86-windows)
    OPTIONS=()
    ;;
  x86_64-windows)
    OPTIONS=()
    ;;
  *)
    fail "Bad platform identifier: \"$TARGET\""
    ;;
esac

(
  cd "$SOURCE"
  make distclean

  { ./configure --prefix="$PWD/$TARGET" "${OPTIONS[@]}" "${USER_OPTIONS[@]}" && \
    make compiler && \
    make compiler && \
    make install; } || fail "Build failed"
)

mkdir -p "$TARGET"
mv "$SOURCE/$TARGET/bin/"* "$TARGET/"
mv "$SOURCE/$TARGET/lib/"* "$TARGET/"
rmdir "$SOURCE/$TARGET/bin" "$SOURCE/$TARGET/lib"
rm -rf "$SOURCE/$TARGET/share"

if [ "$TARGET" = x86-cygwin ]; then
  peflags -x8192000 -z500 "$TARGET/poly.exe"
fi