Bug 1637211 [wpt PR 23529] - [testdriver] fix typos in addPointer documentation,...
[gecko.git] / build / unix / build-gcc / build-gcc.sh
bloba7760fa0988b5589003c84782d3d4c0c30dcfa01
1 #!/bin/bash
3 set -e
4 set -x
6 make_flags="-j$(nproc)"
8 prepare_mingw() {
9 export prefix=/tools/mingw32
10 export install_dir=$root_dir$prefix
11 mkdir -p $install_dir
12 export PATH=$PATH:$install_dir/bin/
14 cd $root_dir
16 git clone -n git://git.code.sf.net/p/mingw-w64/mingw-w64
17 pushd mingw-w64
18 git checkout $mingw_version # Asserts the integrity of the checkout (Right?)
19 popd
22 apply_patch() {
23 if [ $# -ge 2 ]; then
24 pushd $root_dir/$1
25 shift
26 else
27 pushd $root_dir/gcc-source
29 patch -p1 < $1
30 popd
33 build_binutils() {
34 # if binutils_configure_flags is not set at all, give it the default value
35 if [ -z "${binutils_configure_flags+xxx}" ];
36 then
37 # gold is disabled because we don't use it on automation, and also we ran into
38 # some issues with it using this script in build-clang.py.
40 # --enable-targets builds extra target support in ld.
41 # Enabling aarch64 support brings in arm support, so we don't need to specify that too.
43 # It is important to have the binutils --target and the gcc --target match,
44 # so binutils will install binaries in a place that gcc will look for them.
45 binutils_configure_flags="--enable-targets=aarch64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu --disable-gold --enable-plugins --disable-nls --with-sysroot=/"
48 mkdir $root_dir/binutils-objdir
49 pushd $root_dir/binutils-objdir
50 ../binutils-source/configure --prefix=${prefix-/tools/gcc}/ $binutils_configure_flags
51 make $make_flags
52 make install $make_flags DESTDIR=$root_dir
53 export PATH=$root_dir/${prefix-/tools/gcc}/bin:$PATH
54 popd
57 build_gcc() {
58 # Be explicit about --build and --target so header and library install
59 # directories are consistent.
60 local target="${1:-x86_64-unknown-linux-gnu}"
62 mkdir $root_dir/gcc-objdir
63 pushd $root_dir/gcc-objdir
64 ../gcc-source/configure --prefix=${prefix-/tools/gcc} --build=x86_64-unknown-linux-gnu --target="${target}" --enable-languages=c,c++ --disable-nls --disable-gnu-unique-object --enable-__cxa_atexit --with-arch-32=pentiumpro --with-sysroot=/
65 make $make_flags
66 make $make_flags install DESTDIR=$root_dir
68 cd $root_dir/tools
69 ln -s gcc gcc/bin/cc
71 tar caf $root_dir/gcc.tar.xz gcc/
72 popd
75 build_gcc_and_mingw() {
76 mkdir gcc-objdir
77 pushd gcc-objdir
78 ../gcc-source/configure --prefix=$install_dir --target=i686-w64-mingw32 --with-gnu-ld --with-gnu-as --disable-multilib --enable-threads=posix
79 make $make_flags all-gcc
80 make $make_flags install-gcc
81 popd
83 mkdir mingw-w64-headers32
84 pushd mingw-w64-headers32
85 ../mingw-w64/mingw-w64-headers/configure --host=i686-w64-mingw32 --prefix=$install_dir/i686-w64-mingw32/ --enable-sdk=all --enable-secure-api --enable-idl
86 make $make_flags install
87 popd
89 mkdir mingw-w64-crt32
90 pushd mingw-w64-crt32
91 ../mingw-w64/mingw-w64-crt/configure --host=i686-w64-mingw32 --prefix=$install_dir/i686-w64-mingw32/
92 make
93 make install
94 popd
96 mkdir mingw-w64-pthread
97 pushd mingw-w64-pthread
98 ../mingw-w64/mingw-w64-libraries/winpthreads/configure --host=i686-w64-mingw32 --prefix=$install_dir/i686-w64-mingw32/
99 make
100 make install
101 popd
103 pushd gcc-objdir
104 make
105 make install
106 popd
108 mkdir widl32
109 pushd widl32
110 ../mingw-w64/mingw-w64-tools/widl/configure --prefix=$install_dir --target=i686-w64-mingw32
111 make
112 make install
113 popd
115 pushd $(dirname $install_dir)
116 tar caf $root_dir/mingw32.tar.xz $(basename $install_dir)/
117 popd