-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild_gcc.sh
executable file
·78 lines (60 loc) · 1.49 KB
/
build_gcc.sh
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
#!/bin/bash
#
# This script downloads and builds GCC 4.7.0 for Mac OS X.
# Depends on: brew, wget
#
# This file is modifyed version of script by Konrad Rudolph, found here:
# http://apple.stackexchange.com/questions/38222/how-do-i-install-gcc-via-homebrew
#
VERSION=4.7.0
VER_SHORT=4.7
PREFIX=/usr/local/gcc-${VER_SHORT}
TEMP_DIR=temp-gcc
LANGUAGES=c,c++,objc,obj-c++
MAKE='make -j 4'
echo "Preparing to install GCC ${VERSION}..."
echo " Installation path: ${PREFIX}"
echo " Temporary dir: ${TEMP_DIR}"
echo " Programming languages: ${LANGUAGES}"
brew-path() { brew info $1 | head -n3 | tail -n1 | cut -d' ' -f1; }
# Prerequisites
echo
echo "Installing gmp, mpfr and libmpc using brew..."
brew install gmp
brew install mpfr
brew install libmpc
# Download & install the latest GCC
echo
echo "Downloading GCC sources..."
mkdir -p $PREFIX
mkdir ${TEMP_DIR}
cd ${TEMP_DIR}
wget ftp://ftp.gnu.org/gnu/gcc/gcc-${VERSION}/gcc-${VERSION}.tar.gz
tar xfz gcc-$VERSION.tar.gz
rm gcc-${VERSION}.tar.gz
cd gcc-${VERSION}
mkdir build
cd build
echo
echo "Configuring GCC..."
../configure \
--prefix=$PREFIX \
--with-gmp=$(brew-path gmp) \
--with-mpfr=$(brew-path mpfr) \
--with-mpc=$(brew-path libmpc) \
--program-suffix=-${VER_SHORT} \
--enable-languages=${LANGUAGES} \
--with-system-zlib \
--enable-stage1-checking \
--enable-plugin \
--enable-lto \
--disable-multilib
echo
echo "Building GCC..."
$MAKE bootstrap
echo
echo "Installing GCC..."
make install
# Uncomment for cleanup
# cd ../../..
# rm -r temp-gcc