aboutsummaryrefslogtreecommitdiff
path: root/arm-linux-gnueabi-glibc/PKGBUILD
blob: 10f4f071e03f73b44e7562b20c1b16b47250fc36 (about) (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Contributor: Wojtek Kosior <kwojtus@protonmail.com>

# TODO tools from ${_target}-binutils package could be used instead
# of building temporary binutils. I couldn't get them to work easily,
# however. If You can (and have time), fix it.

# TODO There should be some switch to disable building of docs.
# It'd speed up the build + enable us to remove doxygen from depends

_target=arm-linux-gnueabi
pkgname=${_target}-glibc
pkgver=2.25
pkgrel=1
pkgdesc="The GNU C Library ARM GNU/Linux EABI target"
arch=(any)
license=('GPL-3' 'LGPL-3')
url="https://gcc.gnu.org"
groups=('cross-devel')
depends=("glibc-source=$pkgver" 'gcc-source' 'binutils-source')
makedepends=('gcc-ada' 'doxygen')
# The following are checkdepends of gcc. They should only get
# uncommented if we decide to check the temporary compiler.
# checkdepends=('dejagnu' 'inetutils')
options=('!strip' 'staticlibs')

prepare() {
    cd "${srcdir}"
    prepare-gcc-source .
    prepare-glibc-source .
    prepare-binutils-source .
    
    # hack! - some configure tests for header files using "$CPP $CPPFLAGS"
    sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/"                      \
	gcc-*/{libiberty,gcc}/configure binutils-*/libiberty/configure
    
    mkdir -p {gcc,glibc,binutils}_build cross_tools
}

build() {
    # Build primitive binutils and gcc for building glibc
    cd "${srcdir}/binutils_build"
    
    ../binutils-*/configure                            \
    	--prefix="${srcdir}/cross_tools"               \
        --with-sysroot="${srcdir}/cross_tools"         \
        --with-lib-path="${srcdir}/cross_tools/lib"    \
        --target=${_target}                            \
	--disable-gdb                                  \
	--disable-nls                                  \
        --disable-werror                               \
    	--disable-multilib                             \
    	--disable-threads                              \
	--disable-gold # or could we enable it and use gold for glibc later?
    
    make configure-host
    make
    make install
    
    cd "${srcdir}/gcc_build"
    
    # using -pipe causes spurious test-suite failures
    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48565
    # But for now we're not testing this temporary compiler,
    # so the next 2 lines stay commented-out :)
    #    CFLAGS=${CFLAGS/-pipe/}
    #    CXXFLAGS=${CXXFLAGS/-pipe/}
    
    ../gcc-*/configure                                 \
    	--target=${_target}                            \
    	--prefix="${srcdir}/cross_tools"               \
    	--with-newlib                                  \
    	--without-headers                              \
    	--disable-nls                                  \
    	--disable-shared                               \
    	--disable-multilib                             \
    	--disable-decimal-float                        \
    	--disable-threads                              \
    	--disable-libatomic                            \
    	--disable-libgomp                              \
    	--disable-libquadmath                          \
    	--disable-libssp                               \
    	--disable-libvtv                               \
    	--disable-libstdcxx                            \
    	--enable-languages=c,c++                       \
    	--with-bugurl=https://issues.hyperbola.info/   \
    	--with-system-zlib                             \
    	--with-glibc-version=2.11

    # Perhaps `make all-gcc target-libgcc` would be the right thing?
    make
    make install

    cd "${srcdir}/glibc_build"

    # If (for example) we're building glibc for arm and CFLAGS contains
    # -march=x86_64, it shall break configure. That's why we remove -march= flag.
    # -mtune=generic is also not supported on some arches.
    # Warning: extglob option in bash must be enabled for this
    # pattern matching to work (can be done using shopt builtin).
    CFLAGS=${CFLAGS/-march=+([^[:space:]])/}
    CFLAGS=${CFLAGS/-mtune=+([^[:space:]])/}

    # remove fortify for building libraries
    CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=[[:digit:]]/}
    
    echo "slibdir=/lib" > configparms
    echo "rtlddir=/lib" >> configparms
    echo "sbindir=/usr/sbin" >> configparms
    echo "rootsbindir=/sbin" >> configparms
    echo "vardbdir=/var/lib/misc" >> configparms
    
    ../glibc-*/configure                                   \
	--prefix=/usr                                      \
	--includedir=/include                              \
	--libdir=/lib                                      \
	--libexecdir=/libexec                              \
	--with-bugurl=https://issues.hyperbola.info/       \
	--enable-add-ons                                   \
	--enable-obsolete-rpc                              \
	--enable-kernel=2.6.32                             \
	--enable-bind-now                                  \
	--disable-profile                                  \
	--enable-stackguard-randomization                  \
	--enable-stack-protector=strong                    \
	--enable-lock-elision                              \
	--enable-multi-arch                                \
	--disable-werror                                   \
	--host=${_target}                                  \
	--with-headers=/usr/${_target}/include             \
	--with-binutils="${srcdir}/cross_tools/bin/"       \
	CC="${srcdir}/cross_tools/bin/${_target}-gcc"
    
    echo "build-programs=no" >> configparms
    make
}

package() {
    cd "${srcdir}/glibc_build"

    make install_root="${pkgdir}/usr/${_target}" install

    rm -r "${pkgdir}/usr/${_target}/"{etc,var,usr}

    STRIP="${srcdir}/cross_tools/bin/${_target}-strip"

    # Aside from using different strip tool, we do all the stripping the same, as it
    # is done for native glibc. Perhaps it is wrong. If You know better, change it.
    
    if check_option 'debug' n; then
	find "${pkgdir}/usr/${_target}/bin" -type f -executable -exec \
	     "$STRIP" $STRIP_BINARIES {} + 2> /dev/null || true
	find "${pkgdir}/usr/${_target}/lib" -name '*.a' -type f -exec \
	     "$STRIP" $STRIP_STATIC {} + 2> /dev/null || true

	# Do not strip these for gdb and valgrind functionality, but strip the rest.
	find "$pkgdir"/usr/${_target}/lib \
	     -not -name 'ld-*.so' \
	     -not -name 'libc-*.so' \
	     -not -name 'libpthread-*.so' \
	     -not -name 'libthread_db-*.so' \
	     -name '*-*.so' -type f -exec "$STRIP" $STRIP_SHARED {} + 2> /dev/null || true
    fi
}