summaryrefslogtreecommitdiff
path: root/binutils/build.sh
blob: 635fdcb4cf5ffd4df6b86c57878e2473a21f0c17 (plain) (blame)
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
#!/bin/bash
disable_base=1
name=binutils
version=2.34
revision=0
sources=(
    "https://ftp.gnu.org/gnu/${name}/${name}-${version}.tar.gz"
)
build_depends=(
    "bison"
    "texinfo"
    "m4"
    "zlib"
)
depends=(
    "zlib"
)

src=${name}-${version}
blddir=${src}_build


function prepare() {
    set -x
    tar xf ${name}-${version}.tar.gz
    mkdir -p ${blddir}
    cd "${blddir}"

    if [[ $(uname -s) == Darwin ]]; then
        LDFLAGS="-L${_runtime}/lib"
    fi
}

function build() {
    opts=(
        --enable-shared
        --enable-lto
        --enable-ld=default
        --enable-plugins
        --enable-threads
        --disable-static
        --disable-multilib
        --with-system-zlib
        --with-sysroot=/
        --with-tune=generic
    )

    if [[ $(uname -s) == Linux ]]; then
        opts+=(--target=x86_64-pc-linux-gnu)
        export LD_LIBRARY_PATH="${_runtime}/lib:${_prefix}/lib64"
        export LDFLAGS="$LDFLAGS -L${_runtime}/lib64"
        export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${_runtime}/lib64/pkgconfig"
    fi

    ../${src}/configure \
        --prefix=${_prefix} \
        --libdir=${_prefix}/lib \
        --with-lib-path=${_prefix}/lib:${_runtime}/lib:${_prefix}/lib64:${_runtime}/lib64:/lib64:/usr/lib64:/usr/local/lib:/usr/local/lib64 \
        ${opts[@]}

    make -j${_maxjobs}
}

function package() {
    make install-strip DESTDIR="${_pkgdir}"
}