author | nipkow |
Fri, 27 Sep 2013 16:48:47 +0200 | |
changeset 53955 | 436649a2ed62 |
parent 51042 | f024975be336 |
child 56958 | b2c2f74d1c93 |
permissions | -rwxr-xr-x |
38468 | 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 |
|
38472 | 16 |
echo " Build Poly/ML in SOURCE directory for given platform in TARGET," |
17 |
echo " using the usual Isabelle platform identifiers." |
|
38468 | 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) |
|
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 | 57 |
;; |
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 | 62 |
;; |
63 |
x86-cygwin) |
|
64 |
OPTIONS=() |
|
65 |
;; |
|
47763 | 66 |
x86-windows) |
67 |
OPTIONS=() |
|
68 |
;; |
|
69 |
x86_64-windows) |
|
47458 | 70 |
OPTIONS=() |
71 |
;; |
|
38472 | 72 |
ppc-darwin | sparc-solaris | x86-solaris | x86-bsd) |
73 |
OPTIONS=() |
|
74 |
;; |
|
38468 | 75 |
*) |
76 |
fail "Bad platform identifier: \"$TARGET\"" |
|
77 |
;; |
|
78 |
esac |
|
79 |
||
80 |
( |
|
81 |
cd "$SOURCE" |
|
82 |
make distclean |
|
83 |
||
84 |
{ ./configure --prefix="$PWD/$TARGET" "${OPTIONS[@]}" "${USER_OPTIONS[@]}" && \ |
|
85 |
make compiler && \ |
|
39620 | 86 |
make compiler && \ |
38468 | 87 |
make install; } || fail "Build failed" |
88 |
) |
|
89 |
||
90 |
mkdir -p "$TARGET" |
|
91 |
mv "$SOURCE/$TARGET/bin/"* "$TARGET/" |
|
92 |
mv "$SOURCE/$TARGET/lib/"* "$TARGET/" |
|
93 |
rmdir "$SOURCE/$TARGET/bin" "$SOURCE/$TARGET/lib" |
|
94 |
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
|
95 |
|
f024975be336
better apply peflags at build time, to avoid antivirus getting nervous about changing executables;
wenzelm
parents:
47763
diff
changeset
|
96 |
if [ "$TARGET" = x86-cygwin ]; then |
f024975be336
better apply peflags at build time, to avoid antivirus getting nervous about changing executables;
wenzelm
parents:
47763
diff
changeset
|
97 |
peflags -x8192000 -z500 "$TARGET/poly.exe" |
f024975be336
better apply peflags at build time, to avoid antivirus getting nervous about changing executables;
wenzelm
parents:
47763
diff
changeset
|
98 |
fi |