This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
spkg-install
132 lines (107 loc) · 4.17 KB
/
spkg-install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
if [ -z "$SAGE_LOCAL" ]; then
echo >&2 "SAGE_LOCAL undefined ... exiting"
echo >&2 "Maybe run 'sage --sh'?"
exit 1
fi
# Apply fixes to upstream source
cd src
# Exit on error
set -e
# Build in a separate directory, not in src/ (a.k.a. a VPATH build).
# This is the recommended way to build GCC.
cd ..
mkdir gcc-build
cd gcc-build
# The ld (linker) on old Darwin systems doesn't understand
# -compatibility_version, it needs -dylib_compatibility_version.
# Similarly for a few more options. We create an ld wrapper to fix
# these command line options.
if { uname -sr | grep 'Darwin [0-9]\.' ;} &>/dev/null; then
rm -f "$SAGE_LOCAL/bin/ld"
LD=`which "${LD:-ld}"`
echo '#!/bin/bash' >>"$SAGE_LOCAL/bin/ld"
echo '# ld wrapper generated by the GCC spkg' >>"$SAGE_LOCAL/bin/ld"
echo >>"$SAGE_LOCAL/bin/ld"
# Hardcode the path to the "real" ld.
echo "LD=$LD" >>"$SAGE_LOCAL/bin/ld"
cat >>"$SAGE_LOCAL/bin/ld" <<'EOF'
for arg in "$@"; do
arg=`echo "$arg" | sed \
-e 's/^-\(compatibility_version\)/-dylib_\1/' \
-e 's/^-\(current_version\)/-dylib_\1/' \
-e 's/^-\(install_name\)/-dylib_\1/' \
`
argv=("${argv[@]}" "$arg")
done
exec "$LD" "${argv[@]}"
EOF
chmod +x "$SAGE_LOCAL/bin/ld"
# Make GCC use this ld wrapper (found in the $PATH)
export LD=ld
fi
# On OS X 10.9, g++ and the cdefs.h header are currently incompatible
# Temporary workaround posted at http://trac.macports.org/ticket/41033
if { uname -sr | grep 'Darwin 13\.' ;} &>/dev/null; then
mkdir -p "$SAGE_LOCAL/include/sys"
sed 's+defined(__GNUC_STDC_INLINE__)+& \&\& !defined(__cplusplus)+' /usr/include/sys/cdefs.h > "$SAGE_LOCAL/include/sys/cdefs.h"
fi
# On OS X 10.10 there is random ObjC stuff in a C header
if { uname -sr | grep 'Darwin 14\.' ;} &>/dev/null; then
if [ -f /usr/include/dispatch/object.h ]; then
mkdir -p "$SAGE_LOCAL/include/dispatch"
sed 's+typedef void (\^dispatch_block_t)(void)+typedef void* dispatch_block_t+' \
/usr/include/dispatch/object.h > "$SAGE_LOCAL/include/dispatch/object.h"
else
echo "Warning: header /usr/include/dispatch/object.h not found, not applying fix."
fi
fi
# On OSX:
if [ "$UNAME" = "Darwin" ]; then
# isl/cloog libraries are almost certainly from Homebrew and won't work
GCC_CONFIGURE="--without-isl --without-cloog $GCC_CONFIGURE"
# Use 'bootstrap-debug' build configuration to force stripping of object
# files prior to comparison during bootstrap (broken by Xcode 6.3).
# See #18156
GCC_CONFIGURE="--with-build-config=bootstrap-debug $GCC_CONFIGURE"
fi
# Let GCC build on Raspberry Pi using hard floats.
if [ `uname -m` = "armv6l" ]; then
GCC_CONFIGURE="--with-arch=armv6 --with-fpu=vfp --with-float=hard $GCC_CONFIGURE"
fi
# Let GCC build on more recent ARM boards using hard floats.
if [ `uname -m` = "armv7l" ]; then
GCC_CONFIGURE="--with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard $GCC_CONFIGURE"
fi
if [ "$SAGE_CHECK" = yes ]; then
# Enable internal checks in GCC. These checks do not affect the
# binaries produced by GCC, but they do increase the compile time
# of everything compiled with GCC.
GCC_CONFIGURE="$GCC_CONFIGURE --enable-checking=yes"
fi
# Use the assembler/linker specified by $AS/$LD if they differ from the
# default.
if [ -n "$AS" -a "$AS" != "as" ]; then
CONFIGURE_AS="--with-as=$AS"
fi
if [ -n "$LD" -a "$LD" != "ld" ]; then
CONFIGURE_LD="--with-ld=$LD"
fi
../src/configure \
--prefix="$SAGE_LOCAL" \
--with-local-prefix="$SAGE_LOCAL" \
--with-gmp="$SAGE_LOCAL" --with-mpfr="$SAGE_LOCAL" --with-mpc="$SAGE_LOCAL" \
--with-system-zlib \
--disable-multilib \
--disable-nls \
--enable-languages=c,c++,fortran \
--disable-libitm \
$GCC_CONFIGURE "$CONFIGURE_AS" "$CONFIGURE_LD"
$MAKE BOOT_LDFLAGS="-Wl,-rpath,$SAGE_LOCAL/lib"
$MAKE install
# Force re-installation of gmp, mpir, mpfr and mpc with the GCC we just built.
# Also mark gfortran as not installed.
cd "$SAGE_SPKG_INST"
rm -f gmp-* mpir-* mpfr-* mpc-* gfortran-*
# Force re-configuration: the next time that "make" is run, we don't
# want GCC to be built again, see Trac #19324
touch "$SAGE_ROOT/configure"