Admin/polyml/build
author wenzelm
Sat Nov 13 12:32:21 2010 +0100 (2010-11-13 ago)
changeset 40521 8896bd93488e
parent 39620 ff694044a55b
child 46875 162b0c46c559
permissions -rwxr-xr-x
back to quick_and_dirty, which is still practically important since the scheduler does not jump over subproofs;
     1 #!/usr/bin/env bash
     2 #
     3 # Multi-platform build script for Poly/ML
     4 
     5 THIS="$(cd "$(dirname "$0")"; pwd)"
     6 PRG="$(basename "$0")"
     7 
     8 
     9 # diagnostics
    10 
    11 function usage()
    12 {
    13   echo
    14   echo "Usage: $PRG SOURCE TARGET [OPTIONS]"
    15   echo
    16   echo "  Build Poly/ML in SOURCE directory for given platform in TARGET,"
    17   echo "  using the usual Isabelle platform identifiers."
    18   echo
    19   echo "  Additional options for ./configure may be given, e.g. --with-gmp"
    20   echo
    21   exit 1
    22 }
    23 
    24 function fail()
    25 {
    26   echo "$1" >&2
    27   exit 2
    28 }
    29 
    30 
    31 # command line args
    32 
    33 [ "$#" -eq 0 ] && usage
    34 SOURCE="$1"; shift
    35 
    36 [ "$#" -eq 0 ] && usage
    37 TARGET="$1"; shift
    38 
    39 USER_OPTIONS=("$@")
    40 
    41 
    42 # main
    43 
    44 [ -d "$SOURCE" ] || fail "Bad source directory: \"$SOURCE\""
    45 
    46 case "$TARGET" in
    47   x86-linux)
    48     OPTIONS=()
    49     ;;
    50   x86_64-linux)
    51     OPTIONS=()
    52     ;;
    53   x86-darwin)
    54     OPTIONS=(--build=i686-darwin CFLAGS='-arch i686 -O3'
    55       CXXFLAGS='-arch i686 -O3' CCASFLAGS='-arch i686 -O3'
    56       LDFLAGS='-segprot POLY rwx rwx')
    57     ;;
    58   x86_64-darwin)
    59     OPTIONS=(--build=x86_64-darwin CFLAGS='-arch x86_64 -O3'
    60       CXXFLAGS='-arch x86_64 -O3' CCASFLAGS='-arch x86_64'
    61       LDFLAGS='-segprot POLY rwx rwx')
    62     ;;
    63   x86-cygwin)
    64     OPTIONS=()
    65     ;;
    66   ppc-darwin | sparc-solaris | x86-solaris | x86-bsd)
    67     OPTIONS=()
    68     ;;
    69   *)
    70     fail "Bad platform identifier: \"$TARGET\""
    71     ;;
    72 esac
    73 
    74 (
    75   cd "$SOURCE"
    76   make distclean
    77 
    78   { ./configure --prefix="$PWD/$TARGET" "${OPTIONS[@]}" "${USER_OPTIONS[@]}" && \
    79     make compiler && \
    80     make compiler && \
    81     make install; } || fail "Build failed"
    82 )
    83 
    84 mkdir -p "$TARGET"
    85 mv "$SOURCE/$TARGET/bin/"* "$TARGET/"
    86 mv "$SOURCE/$TARGET/lib/"* "$TARGET/"
    87 rmdir "$SOURCE/$TARGET/bin" "$SOURCE/$TARGET/lib"
    88 rm -rf "$SOURCE/$TARGET/share"