author | wenzelm |
Mon, 18 Jan 2016 16:03:58 +0100 | |
changeset 62199 | fc55a4e3f439 |
parent 61181 | b6b5e41d261b |
child 62387 | ad3eb2889f9a |
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) |
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 | 68 |
PATH="/mingw32/bin:$PATH" |
47763 | 69 |
;; |
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 | 72 |
PATH="/mingw64/bin:$PATH" |
47458 | 73 |
;; |
38468 | 74 |
*) |
75 |
fail "Bad platform identifier: \"$TARGET\"" |
|
76 |
;; |
|
77 |
esac |
|
78 |
||
79 |
( |
|
80 |
cd "$SOURCE" |
|
81 |
make distclean |
|
82 |
||
83 |
{ ./configure --prefix="$PWD/$TARGET" "${OPTIONS[@]}" "${USER_OPTIONS[@]}" && \ |
|
84 |
make compiler && \ |
|
39620 | 85 |
make compiler && \ |
38468 | 86 |
make install; } || fail "Build failed" |
87 |
) |
|
88 |
||
89 |
mkdir -p "$TARGET" |
|
90 |
mv "$SOURCE/$TARGET/bin/"* "$TARGET/" |
|
91 |
mv "$SOURCE/$TARGET/lib/"* "$TARGET/" |
|
92 |
rmdir "$SOURCE/$TARGET/bin" "$SOURCE/$TARGET/lib" |
|
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 | 95 |
case "$TARGET" in |
96 |
x86-cygwin) |
|
97 |
peflags -x8192000 -z500 "$TARGET/poly.exe" |
|
98 |
;; |
|
99 |
x86-windows) |
|
60979 | 100 |
for X in libgcc_s_dw2-1.dll libgmp-10.dll libstdc++-6.dll |
60968 | 101 |
do |
102 |
cp "/mingw32/bin/$X" "$TARGET/." |
|
103 |
done |
|
60960 | 104 |
;; |
61071 | 105 |
x86_64-windows) |
106 |
for X in libgcc_s_seh-1.dll libgmp-10.dll libstdc++-6.dll |
|
107 |
do |
|
108 |
cp "/mingw64/bin/$X" "$TARGET/." |
|
109 |
done |
|
110 |
;; |
|
60960 | 111 |
esac |