Use https by default
[gentoo.git] / sys-libs / glibc / glibc-2.21-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="4"
6
7 inherit eutils versionator toolchain-funcs flag-o-matic gnuconfig multilib systemd unpacker multiprocessing
8
9 DESCRIPTION="GNU libc6 (also called glibc2) C library"
10 HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
11
12 LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
13 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
14 RESTRICT="strip" # strip ourself #46186
15 EMULTILIB_PKG="true"
16
17 # Configuration variables
18 RELEASE_VER=""
19 case ${PV} in
20 9999*)
21         EGIT_REPO_URIS="git://sourceware.org/git/glibc.git"
22         EGIT_SOURCEDIRS="${S}"
23         inherit git-2
24         ;;
25 *)
26         RELEASE_VER=${PV}
27         ;;
28 esac
29 GCC_BOOTSTRAP_VER="4.7.3-r1"
30 PATCH_VER="4"                                  # Gentoo patchset
31 : ${NPTL_KERN_VER:="2.6.32"}                   # min kernel version nptl requires
32
33 IUSE="debug gd hardened multilib nscd selinux systemtap profile suid vanilla crosscompile_opts_headers-only"
34
35 # Here's how the cross-compile logic breaks down ...
36 #  CTARGET - machine that will target the binaries
37 #  CHOST   - machine that will host the binaries
38 #  CBUILD  - machine that will build the binaries
39 # If CTARGET != CHOST, it means you want a libc for cross-compiling.
40 # If CHOST != CBUILD, it means you want to cross-compile the libc.
41 #  CBUILD = CHOST = CTARGET    - native build/install
42 #  CBUILD != (CHOST = CTARGET) - cross-compile a native build
43 #  (CBUILD = CHOST) != CTARGET - libc for cross-compiler
44 #  CBUILD != CHOST != CTARGET  - cross-compile a libc for a cross-compiler
45 # For install paths:
46 #  CHOST = CTARGET  - install into /
47 #  CHOST != CTARGET - install into /usr/CTARGET/
48
49 export CBUILD=${CBUILD:-${CHOST}}
50 export CTARGET=${CTARGET:-${CHOST}}
51 if [[ ${CTARGET} == ${CHOST} ]] ; then
52         if [[ ${CATEGORY} == cross-* ]] ; then
53                 export CTARGET=${CATEGORY#cross-}
54         fi
55 fi
56
57 is_crosscompile() {
58         [[ ${CHOST} != ${CTARGET} ]]
59 }
60
61 # Why SLOT 2.2 you ask yourself while sippin your tea ?
62 # Everyone knows 2.2 > 0, duh.
63 SLOT="2.2"
64
65 # General: We need a new-enough binutils/gcc to match upstream baseline.
66 # arch: we need to make sure our binutils/gcc supports TLS.
67 DEPEND=">=app-misc/pax-utils-0.1.10
68         !<sys-apps/sandbox-1.6
69         !<sys-apps/portage-2.1.2
70         selinux? ( sys-libs/libselinux )"
71 RDEPEND="!sys-kernel/ps3-sources
72         sys-apps/gentoo-functions
73         selinux? ( sys-libs/libselinux )
74         !sys-libs/nss-db"
75
76 if [[ ${CATEGORY} == cross-* ]] ; then
77         DEPEND+=" !crosscompile_opts_headers-only? (
78                 >=${CATEGORY}/binutils-2.24
79                 >=${CATEGORY}/gcc-4.6
80         )"
81         [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
82 else
83         DEPEND+="
84                 >=sys-devel/binutils-2.24
85                 >=sys-devel/gcc-4.6
86                 virtual/os-headers"
87         RDEPEND+=" vanilla? ( !sys-libs/timezone-data )"
88         PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
89 fi
90
91 upstream_uris() {
92         echo mirror://gnu/glibc/$1 ftp://sourceware.org/pub/glibc/{releases,snapshots}/$1 mirror://gentoo/$1
93 }
94 gentoo_uris() {
95         local devspace="HTTP~vapier/dist/URI HTTP~azarah/glibc/URI"
96         devspace=${devspace//HTTP/https://dev.gentoo.org/}
97         echo mirror://gentoo/$1 ${devspace//URI/$1}
98 }
99 SRC_URI=$(
100         [[ -z ${EGIT_REPO_URIS} ]] && upstream_uris ${P}.tar.xz
101         [[ -n ${PATCH_VER}      ]] && gentoo_uris ${P}-patches-${PATCH_VER}.tar.bz2
102 )
103 SRC_URI+=" ${GCC_BOOTSTRAP_VER:+multilib? ( $(gentoo_uris gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2) )}"
104
105 # eblit-include [--skip] <function> [version]
106 eblit-include() {
107         local skipable=false
108         [[ $1 == "--skip" ]] && skipable=true && shift
109         [[ $1 == pkg_* ]] && skipable=true
110
111         local e v func=$1 ver=$2
112         [[ -z ${func} ]] && die "Usage: eblit-include <function> [version]"
113         for v in ${ver:+-}${ver} -${PVR} -${PV} "" ; do
114                 e="${FILESDIR}/eblits/${func}${v}.eblit"
115                 if [[ -e ${e} ]] ; then
116                         source "${e}"
117                         return 0
118                 fi
119         done
120         ${skipable} && return 0
121         die "Could not locate requested eblit '${func}' in ${FILESDIR}/eblits/"
122 }
123
124 # eblit-run-maybe <function>
125 # run the specified function if it is defined
126 eblit-run-maybe() {
127         [[ $(type -t "$@") == "function" ]] && "$@"
128 }
129
130 # eblit-run <function> [version]
131 # aka: src_unpack() { eblit-run src_unpack ; }
132 eblit-run() {
133         eblit-include --skip common "${*:2}"
134         eblit-include "$@"
135         eblit-run-maybe eblit-$1-pre
136         eblit-${PN}-$1
137         eblit-run-maybe eblit-$1-post
138 }
139
140 src_unpack()    { eblit-run src_unpack    ; }
141 src_prepare()   { eblit-run src_prepare   ; }
142 src_configure() { eblit-run src_configure ; }
143 src_compile()   { eblit-run src_compile   ; }
144 src_test()      { eblit-run src_test      ; }
145 src_install()   { eblit-run src_install   ; }
146
147 # FILESDIR might not be available during binpkg install
148 for x in pretend setup {pre,post}inst ; do
149         e="${FILESDIR}/eblits/pkg_${x}.eblit"
150         if [[ -e ${e} ]] ; then
151                 . "${e}"
152                 eval "pkg_${x}() { eblit-run pkg_${x} ; }"
153         fi
154 done
155
156 eblit-src_unpack-pre() {
157         [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib && unpack gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2
158 }
159
160 eblit-src_prepare-post() {
161         cd "${S}"
162
163         if use hardened ; then
164                 einfo "Patching to get working PIE binaries on PIE (hardened) platforms"
165                 gcc-specs-pie && epatch "${FILESDIR}"/2.17/glibc-2.17-hardened-pie.patch
166                 epatch "${FILESDIR}"/2.20/glibc-2.20-hardened-inittls-nosysenter.patch
167
168                 # We don't enable these for non-hardened as the output is very terse --
169                 # it only states that a crash happened.  The default upstream behavior
170                 # includes backtraces and symbols.
171                 einfo "Installing Hardened Gentoo SSP and FORTIFY_SOURCE handler"
172                 cp "${FILESDIR}"/2.20/glibc-2.20-gentoo-stack_chk_fail.c debug/stack_chk_fail.c || die
173                 cp "${FILESDIR}"/2.20/glibc-2.20-gentoo-chk_fail.c debug/chk_fail.c || die
174
175                 if use debug ; then
176                         # Allow SIGABRT to dump core on non-hardened systems, or when debug is requested.
177                         sed -i \
178                                 -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
179                                 -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
180                                 debug/Makefile || die
181                 fi
182
183                 # Build various bits with ssp-all
184                 sed -i \
185                         -e 's:-fstack-protector$:-fstack-protector-all:' \
186                         */Makefile || die
187         fi
188
189         case $(gcc-fullversion) in
190         4.8.[0-3]|4.9.0)
191                 eerror "You need to switch to a newer compiler; gcc-4.8.[0-3] and gcc-4.9.0 miscompile"
192                 eerror "glibc.  See https://bugs.gentoo.org/547420 for details."
193                 die "need to switch compilers #547420"
194                 ;;
195         esac
196 }