yann@2270
|
1 |
# This file contains the functions common to glibc and eglibc
|
yann@850
|
2 |
|
yann@2483
|
3 |
# Extract the C library tarball(s)
|
yann@2483
|
4 |
do_libc_extract() {
|
yann@2483
|
5 |
local addon
|
yann@2483
|
6 |
|
yann@2483
|
7 |
# Extract the main tarball
|
yann@2483
|
8 |
CT_Extract "${CT_LIBC}-${CT_LIBC_VERSION}"
|
yann@2483
|
9 |
CT_Pushd "${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
|
yann@2483
|
10 |
CT_Patch nochdir "${CT_LIBC}" "${CT_LIBC_VERSION}"
|
yann@2483
|
11 |
|
yann@2483
|
12 |
# Extract the add-opns
|
yann@2483
|
13 |
for addon in $(do_libc_add_ons_list " "); do
|
yann@2496
|
14 |
# If the addon was bundled with the main archive, we do not
|
yann@2496
|
15 |
# need to extract it. Worse, if we were to try to extract
|
yann@2496
|
16 |
# it, we'd get an error.
|
yann@2496
|
17 |
if [ -d "${addon}" ]; then
|
yann@2496
|
18 |
CT_DoLog DEBUG "Add-on already present, spkipping extraction"
|
yann@2496
|
19 |
continue
|
yann@2496
|
20 |
fi
|
yann@2483
|
21 |
|
yann@2483
|
22 |
CT_Extract nochdir "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
|
yann@2483
|
23 |
|
yann@2483
|
24 |
CT_TestAndAbort "Error in add-on '${addon}': both short and long names in tarball" \
|
yann@2483
|
25 |
-d "${addon}" -a -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
|
yann@2483
|
26 |
|
yann@2483
|
27 |
# Some addons have the 'long' name, while others have the
|
yann@2483
|
28 |
# 'short' name, but patches are non-uniformly built with
|
yann@2483
|
29 |
# either the 'long' or 'short' name, whatever the addons name
|
yann@2483
|
30 |
# but we prefer the 'short' name and avoid duplicates.
|
yann@2483
|
31 |
if [ -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ]; then
|
esben@2699
|
32 |
CT_DoExecLog FILE mv "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" "${addon}"
|
yann@2483
|
33 |
fi
|
yann@2483
|
34 |
|
esben@2699
|
35 |
CT_DoExecLog FILE ln -s "${addon}" "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
|
yann@2483
|
36 |
|
yann@2483
|
37 |
CT_Patch nochdir "${CT_LIBC}" "${addon}-${CT_LIBC_VERSION}"
|
yann@2483
|
38 |
|
yann@2483
|
39 |
# Remove the long name since it can confuse configure scripts to run
|
yann@2483
|
40 |
# the same source twice.
|
yann@2483
|
41 |
rm "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
|
yann@2483
|
42 |
done
|
yann@2483
|
43 |
|
yann@2483
|
44 |
# The configure files may be older than the configure.in files
|
yann@2483
|
45 |
# if using a snapshot (or even some tarballs). Fake them being
|
yann@2483
|
46 |
# up to date.
|
yann@2483
|
47 |
find . -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL
|
yann@2483
|
48 |
|
yann@2483
|
49 |
CT_Popd
|
benoit@2585
|
50 |
|
benoit@2585
|
51 |
if [ "${CT_LIBC_LOCALES}" = "y" ]; then
|
benoit@2585
|
52 |
do_libc_locales_extract
|
benoit@2585
|
53 |
fi
|
yann@2483
|
54 |
}
|
yann@2483
|
55 |
|
yann@2270
|
56 |
# Build and install headers and start files
|
yann@850
|
57 |
do_libc_start_files() {
|
bryanhundven@2515
|
58 |
# Start files and Headers should be configured the same way as the
|
bryanhundven@2515
|
59 |
# final libc, but built and installed differently.
|
bryanhundven@2515
|
60 |
do_libc_backend libc_mode=startfiles
|
yann@850
|
61 |
}
|
yann@850
|
62 |
|
yann@2270
|
63 |
# This function builds and install the full C library
|
yann@850
|
64 |
do_libc() {
|
bryanhundven@2515
|
65 |
do_libc_backend libc_mode=final
|
bryanhundven@2515
|
66 |
}
|
bryanhundven@2515
|
67 |
|
yann@2825
|
68 |
# This backend builds the C library once for each multilib
|
yann@2825
|
69 |
# variant the compiler gives us
|
yann@2806
|
70 |
# Usage: do_libc_backend param=value [...]
|
yann@2806
|
71 |
# Parameter : Definition : Type : Default
|
yann@2819
|
72 |
# libc_mode : 'startfiles' or 'final' : string : (none)
|
yann@2825
|
73 |
do_libc_backend() {
|
yann@2825
|
74 |
local libc_mode
|
yann@2825
|
75 |
local -a multilibs
|
yann@2825
|
76 |
local multilib
|
yann@2825
|
77 |
local multi_dir
|
yann@2825
|
78 |
local multi_flags
|
yann@2825
|
79 |
local extra_dir
|
yann@2826
|
80 |
local libc_headers libc_startfiles libc_full
|
yann@2826
|
81 |
local hdr
|
yann@2826
|
82 |
local arg
|
yann@2825
|
83 |
|
yann@2825
|
84 |
for arg in "$@"; do
|
yann@2825
|
85 |
eval "${arg// /\\ }"
|
yann@2825
|
86 |
done
|
yann@2825
|
87 |
|
yann@2825
|
88 |
case "${libc_mode}" in
|
yann@2826
|
89 |
startfiles)
|
yann@2826
|
90 |
CT_DoStep INFO "Installing C library headers & start files"
|
yann@2826
|
91 |
hdr=y
|
yann@2826
|
92 |
libc_startfiles=y
|
yann@2826
|
93 |
libc_full=
|
yann@2826
|
94 |
;;
|
yann@2826
|
95 |
final)
|
yann@2826
|
96 |
CT_DoStep INFO "Installing C library"
|
yann@2826
|
97 |
hdr=
|
yann@2826
|
98 |
libc_startfiles=
|
yann@2826
|
99 |
libc_full=y
|
yann@2826
|
100 |
;;
|
yann@2826
|
101 |
*) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";;
|
yann@2825
|
102 |
esac
|
yann@2825
|
103 |
|
yann@2825
|
104 |
# If gcc is not configured for multilib, it still prints
|
yann@2825
|
105 |
# a single line for the default settings
|
yann@2825
|
106 |
multilibs=( $("${CT_TARGET}-gcc" -print-multi-lib 2>/dev/null) )
|
yann@2825
|
107 |
for multilib in "${multilibs[@]}"; do
|
yann@2825
|
108 |
multi_dir="${multilib%%;*}"
|
yann@2825
|
109 |
if [ "${multi_dir}" != "." ]; then
|
yann@2825
|
110 |
CT_DoStep INFO "Building for multilib subdir='${multi_dir}'"
|
yann@2825
|
111 |
|
yann@2825
|
112 |
extra_flags="$( echo "${multilib#*;}" \
|
yann@2825
|
113 |
|${sed} -r -e 's/@/ -/g;' \
|
yann@2825
|
114 |
)"
|
yann@2825
|
115 |
extra_dir="/${multi_dir}"
|
yann@2825
|
116 |
|
yann@2825
|
117 |
# glibc install its files in ${extra_dir}/{usr/,}lib
|
yann@2825
|
118 |
# while gcc expects them in {,usr/}lib/${extra_dir}.
|
yann@2825
|
119 |
# Prepare some symlinks so glibc installs in fact in
|
yann@2825
|
120 |
# the proper place
|
yann@2825
|
121 |
# We do it in the start-files step, so it is not needed
|
yann@2825
|
122 |
# to do it in the final step, as the symlinks will
|
yann@2825
|
123 |
# already exist
|
yann@2825
|
124 |
if [ "${libc_mode}" = "startfiles" ]; then
|
yann@2825
|
125 |
CT_Pushd "${CT_SYSROOT_DIR}"
|
yann@2825
|
126 |
CT_DoExecLog ALL mkdir -p "lib/${multi_dir}" \
|
yann@2825
|
127 |
"usr/lib/${multi_dir}" \
|
yann@2825
|
128 |
"${multi_dir}" \
|
yann@2825
|
129 |
"${multi_dir}/usr"
|
yann@2825
|
130 |
CT_DoExecLog ALL ln -sf "../lib/${multi_dir}" "${multi_dir}/lib"
|
yann@2825
|
131 |
CT_DoExecLog ALL ln -sf "../../usr/lib/${multi_dir}" "${multi_dir}/usr/lib"
|
yann@2825
|
132 |
CT_Popd
|
yann@2825
|
133 |
fi
|
yann@2826
|
134 |
libc_headers=
|
yann@2825
|
135 |
else
|
yann@2825
|
136 |
extra_dir=
|
yann@2825
|
137 |
extra_flags=
|
yann@2826
|
138 |
libc_headers="${hdr}"
|
yann@2825
|
139 |
fi
|
yann@2825
|
140 |
|
yann@2899
|
141 |
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}${extra_dir//\//_}"
|
yann@2825
|
142 |
|
yann@2826
|
143 |
do_libc_backend_once extra_dir="${extra_dir}" \
|
yann@2826
|
144 |
extra_flags="${extra_flags}" \
|
yann@2826
|
145 |
libc_headers="${libc_headers}" \
|
yann@2826
|
146 |
libc_startfiles="${libc_startfiles}" \
|
yann@2826
|
147 |
libc_full="${libc_full}"
|
yann@2825
|
148 |
|
yann@2825
|
149 |
CT_Popd
|
yann@2825
|
150 |
|
yann@2825
|
151 |
if [ "${multi_dir}" != "." ]; then
|
yann@2825
|
152 |
if [ "${libc_mode}" = "final" ]; then
|
yann@2825
|
153 |
CT_DoLog EXTRA "Fixing up multilib location"
|
yann@2825
|
154 |
|
yann@2825
|
155 |
# rewrite the library multiplexers
|
yann@2825
|
156 |
for d in "lib/${multi_dir}" "usr/lib/${multi_dir}"; do
|
yann@2825
|
157 |
for l in libc libpthread libgcc_s; do
|
yann@2825
|
158 |
if [ -f "${CT_SYSROOT_DIR}/${d}/${l}.so" \
|
yann@2825
|
159 |
-a ! -L ${CT_SYSROOT_DIR}/${d}/${l}.so ]
|
yann@2825
|
160 |
then
|
yann@2825
|
161 |
CT_DoExecLog DEBUG ${sed} -r -i \
|
yann@2825
|
162 |
-e "s:/lib/:/lib/${multi_dir}/:g;" \
|
yann@2825
|
163 |
"${CT_SYSROOT_DIR}/${d}/${l}.so"
|
yann@2825
|
164 |
fi
|
yann@2825
|
165 |
done
|
yann@2825
|
166 |
done
|
yann@2827
|
167 |
# Remove the multi_dir now it is no longer useful
|
yann@2827
|
168 |
CT_DoExecLog DEBUG rm -rf "${CT_SYSROOT_DIR}/${multi_dir}"
|
yann@2825
|
169 |
fi # libc_mode == final
|
yann@2827
|
170 |
|
yann@2825
|
171 |
CT_EndStep
|
yann@2825
|
172 |
fi
|
yann@2825
|
173 |
done
|
yann@2825
|
174 |
|
yann@2825
|
175 |
CT_EndStep
|
yann@2825
|
176 |
}
|
yann@2825
|
177 |
|
yann@2825
|
178 |
# This backend builds the C library once
|
yann@2825
|
179 |
# Usage: do_libc_backend_once param=value [...]
|
yann@2825
|
180 |
# Parameter : Definition : Type : Default
|
yann@2826
|
181 |
# libc_headers : Build libc headers : bool : n
|
yann@2826
|
182 |
# libc_startfiles : Build libc start-files : bool : n
|
yann@2826
|
183 |
# libc_full : Build full libc : bool : n
|
yann@2820
|
184 |
# extra_flags : Extra CFLAGS to use (for multilib) : string : (empty)
|
yann@2823
|
185 |
# extra_dir : Extra subdir for multilib : string : (empty)
|
yann@2825
|
186 |
do_libc_backend_once() {
|
yann@2826
|
187 |
local libc_headers
|
yann@2826
|
188 |
local libc_startfiles
|
yann@2826
|
189 |
local libc_full
|
yann@2820
|
190 |
local extra_flags
|
yann@2823
|
191 |
local extra_dir
|
yann@2271
|
192 |
local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
|
yann@2276
|
193 |
local extra_cc_args
|
yann@1478
|
194 |
local -a extra_config
|
yann@2271
|
195 |
local -a extra_make_args
|
yann@2312
|
196 |
local glibc_cflags
|
yann@2821
|
197 |
local float_extra
|
yann@2822
|
198 |
local endian_extra
|
yann@2883
|
199 |
local arg
|
yann@1478
|
200 |
|
yann@2883
|
201 |
for arg in "$@"; do
|
yann@2883
|
202 |
eval "${arg// /\\ }"
|
bryanhundven@2515
|
203 |
done
|
yann@850
|
204 |
|
yann@850
|
205 |
CT_DoLog EXTRA "Configuring C library"
|
yann@850
|
206 |
|
yann@2271
|
207 |
case "${CT_LIBC}" in
|
yann@2271
|
208 |
eglibc)
|
yann@2271
|
209 |
if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
|
yann@2271
|
210 |
CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
|
yann@2271
|
211 |
fi
|
yann@2271
|
212 |
if [ "${CT_EGLIBC_OPT_SIZE}" = "y" ]; then
|
yann@2271
|
213 |
OPTIMIZE=-Os
|
yann@2271
|
214 |
else
|
yann@2271
|
215 |
OPTIMIZE=-O2
|
yann@2271
|
216 |
fi
|
yann@2271
|
217 |
;;
|
yann@2276
|
218 |
glibc)
|
yann@2276
|
219 |
# glibc can't be built without -O2 (reference needed!)
|
yann@2276
|
220 |
OPTIMIZE=-O2
|
yann@2276
|
221 |
# Also, if those two are missing, iconv build breaks
|
yann@2276
|
222 |
extra_config+=( --disable-debug --disable-sanity-checks )
|
yann@2276
|
223 |
;;
|
yann@2271
|
224 |
esac
|
richard@1796
|
225 |
|
yann@850
|
226 |
# Add some default glibc config options if not given by user.
|
yann@850
|
227 |
# We don't need to be conditional on wether the user did set different
|
yann@2467
|
228 |
# values, as they CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY is passed after
|
yann@2467
|
229 |
# extra_config
|
yann@850
|
230 |
|
yann@2273
|
231 |
extra_config+=("$(do_libc_min_kernel_config)")
|
yann@850
|
232 |
|
yann@850
|
233 |
case "${CT_THREADS}" in
|
yann@1478
|
234 |
nptl) extra_config+=("--with-__thread" "--with-tls");;
|
yann@1478
|
235 |
linuxthreads) extra_config+=("--with-__thread" "--without-tls" "--without-nptl");;
|
yann@1478
|
236 |
none) extra_config+=("--without-__thread" "--without-nptl")
|
yann@2467
|
237 |
case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
|
yann@850
|
238 |
*-tls*) ;;
|
yann@1478
|
239 |
*) extra_config+=("--without-tls");;
|
yann@850
|
240 |
esac
|
yann@850
|
241 |
;;
|
yann@850
|
242 |
esac
|
yann@850
|
243 |
|
yann@850
|
244 |
case "${CT_SHARED_LIBS}" in
|
yann@1478
|
245 |
y) extra_config+=("--enable-shared");;
|
yann@1478
|
246 |
*) extra_config+=("--disable-shared");;
|
yann@850
|
247 |
esac
|
yann@850
|
248 |
|
yann@2821
|
249 |
float_extra="$( echo "${extra_flags}" \
|
yann@2821
|
250 |
|${sed} -r -e '/^(.*[[:space:]])?-m(hard|soft)-float([[:space:]].*)?$/!d;' \
|
yann@2821
|
251 |
-e 's//\2/;' \
|
yann@2821
|
252 |
)"
|
yann@2821
|
253 |
case "${float_extra}" in
|
michael@2737
|
254 |
hard) extra_config+=("--with-fp");;
|
michael@2737
|
255 |
soft) extra_config+=("--without-fp");;
|
yann@2821
|
256 |
"")
|
yann@2821
|
257 |
case "${CT_ARCH_FLOAT}" in
|
yann@2821
|
258 |
hard|softfp) extra_config+=("--with-fp");;
|
yann@2821
|
259 |
soft) extra_config+=("--without-fp");;
|
yann@2821
|
260 |
esac
|
yann@2821
|
261 |
;;
|
yann@850
|
262 |
esac
|
yann@850
|
263 |
|
bryanhundven@2180
|
264 |
if [ "${CT_LIBC_DISABLE_VERSIONING}" = "y" ]; then
|
bryanhundven@2180
|
265 |
extra_config+=("--disable-versioning")
|
bryanhundven@2180
|
266 |
fi
|
bryanhundven@2180
|
267 |
|
bryanhundven@2181
|
268 |
if [ "${CT_LIBC_OLDEST_ABI}" != "" ]; then
|
bryanhundven@2181
|
269 |
extra_config+=("--enable-oldest-abi=${CT_LIBC_OLDEST_ABI}")
|
bryanhundven@2181
|
270 |
fi
|
bryanhundven@2181
|
271 |
|
yann@850
|
272 |
case "$(do_libc_add_ons_list ,)" in
|
benoit@2573
|
273 |
"") extra_config+=("--enable-add-ons=no");;
|
yann@1478
|
274 |
*) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");;
|
yann@850
|
275 |
esac
|
yann@850
|
276 |
|
benoit@2489
|
277 |
if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
|
benoit@2503
|
278 |
extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
|
benoit@2503
|
279 |
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
|
benoit@2489
|
280 |
fi
|
benoit@2489
|
281 |
|
yann@2822
|
282 |
# Extract the endianness options if any
|
yann@2822
|
283 |
# This should cover all possible endianness options
|
yann@2822
|
284 |
# in gcc, but it is prone to bit-rot... :-(
|
yann@2822
|
285 |
endian_extra="$( echo "${extra_flags}" \
|
yann@2822
|
286 |
|${sed} -r -e '/^(.*[[:space:]])?-(E[BL]|m((big|little)(-endian)?|e?[bl]))([[:space:]].*)?$/!d;' \
|
yann@2822
|
287 |
-e 's//\2/;' \
|
yann@2822
|
288 |
)"
|
yann@2822
|
289 |
case "${endian_extra}" in
|
yann@2822
|
290 |
EB|mbig-endian|mbig|meb|mb)
|
yann@2822
|
291 |
extra_cc_args="${extra_cc_args} ${endian_extra}"
|
yann@2822
|
292 |
;;
|
yann@2822
|
293 |
EL|mlittle-endian|mlittle|mel|ml)
|
yann@2822
|
294 |
extra_cc_args="${extra_cc_args} ${endian_extra}"
|
yann@2822
|
295 |
;;
|
yann@2822
|
296 |
"") extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
|
yann@2822
|
297 |
;;
|
yann@2822
|
298 |
esac
|
yann@850
|
299 |
|
yann@2289
|
300 |
touch config.cache
|
yann@2289
|
301 |
if [ "${CT_LIBC_GLIBC_FORCE_UNWIND}" = "y" ]; then
|
yann@2289
|
302 |
echo "libc_cv_forced_unwind=yes" >>config.cache
|
yann@2289
|
303 |
echo "libc_cv_c_cleanup=yes" >>config.cache
|
yann@2289
|
304 |
fi
|
yann@2289
|
305 |
|
yann@2276
|
306 |
# Pre-seed the configparms file with values from the config option
|
yann@2276
|
307 |
printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
|
yann@2276
|
308 |
|
benoit@2489
|
309 |
cross_cc=$(CT_Which "${CT_TARGET}-gcc")
|
yann@2820
|
310 |
extra_cc_args+=" ${extra_flags}"
|
yann@850
|
311 |
|
yann@2312
|
312 |
case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
|
yann@2312
|
313 |
y) ;;
|
yann@2312
|
314 |
*) glibc_cflags+=" -U_FORTIFY_SOURCE";;
|
yann@2312
|
315 |
esac
|
yann@2828
|
316 |
glibc_cflags+=" ${CT_TARGET_CFLAGS} ${OPTIMIZE} ${CT_LIBC_GLIBC_EXTRA_CFLAGS}"
|
yann@2312
|
317 |
|
bryanhundven@2229
|
318 |
# ./configure is mislead by our tools override wrapper for bash
|
bryanhundven@2229
|
319 |
# so just tell it where the real bash is _on_the_target_!
|
bryanhundven@2229
|
320 |
# Notes:
|
bryanhundven@2229
|
321 |
# - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
|
bryanhundven@2229
|
322 |
# - ${BASH_SHELL} is only used to set BASH
|
bryanhundven@2229
|
323 |
# - ${BASH} is only used to set the shebang
|
bryanhundven@2229
|
324 |
# in two scripts to run on the target
|
bryanhundven@2229
|
325 |
# So we can safely bypass bash detection at compile time.
|
bryanhundven@2229
|
326 |
# Should this change in a future eglibc release, we'd better
|
bryanhundven@2229
|
327 |
# directly mangle the generated scripts _after_ they get built,
|
bryanhundven@2229
|
328 |
# or even after they get installed... eglibc is such a sucker...
|
yann@2289
|
329 |
echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
|
bryanhundven@2229
|
330 |
|
yann@2276
|
331 |
# Configure with --prefix the way we want it on the target...
|
yann@2276
|
332 |
# There are a whole lot of settings here. You'll probably want
|
yann@2467
|
333 |
# to read up on what they all mean, and customize a bit, possibly by setting GLIBC_EXTRA_CONFIG_ARRAY
|
yann@2276
|
334 |
# Compare these options with the ones used when installing the glibc headers above - they're different.
|
yann@2276
|
335 |
# Adding "--without-gd" option to avoid error "memusagestat.c:36:16: gd.h: No such file or directory"
|
yann@2276
|
336 |
# See also http://sources.redhat.com/ml/libc-alpha/2000-07/msg00024.html.
|
yann@2276
|
337 |
# Set BUILD_CC, or we won't be able to build datafiles
|
yann@2706
|
338 |
# Run explicitly through CONFIG_SHELL, or the build breaks badly (loop-of-death)
|
yann@2706
|
339 |
# when the shell is not bash... Sigh... :-(
|
yann@2276
|
340 |
|
yann@2828
|
341 |
CT_DoLog DEBUG "Using gcc for target : '${cross_cc}'"
|
yann@2828
|
342 |
CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
|
yann@2828
|
343 |
CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
|
yann@2828
|
344 |
CT_DoLog DEBUG "Extra CC args passed : '${glibc_cflags}'"
|
yann@2828
|
345 |
CT_DoLog DEBUG "Extra flags (multilib) : '${extra_flags}'"
|
yann@2828
|
346 |
|
yann@2353
|
347 |
CT_DoExecLog CFG \
|
yann@1041
|
348 |
BUILD_CC="${CT_BUILD}-gcc" \
|
yann@2312
|
349 |
CFLAGS="${glibc_cflags}" \
|
yann@850
|
350 |
CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
|
yann@850
|
351 |
AR=${CT_TARGET}-ar \
|
yann@850
|
352 |
RANLIB=${CT_TARGET}-ranlib \
|
yann@2706
|
353 |
"${CONFIG_SHELL}" \
|
yann@2271
|
354 |
"${src_dir}/configure" \
|
yann@850
|
355 |
--prefix=/usr \
|
yann@1041
|
356 |
--build=${CT_BUILD} \
|
yann@850
|
357 |
--host=${CT_TARGET} \
|
yann@2289
|
358 |
--cache-file="$(pwd)/config.cache" \
|
yann@2276
|
359 |
--without-cvs \
|
yann@850
|
360 |
--disable-profile \
|
yann@850
|
361 |
--without-gd \
|
yann@2276
|
362 |
--with-headers="${CT_HEADERS_DIR}" \
|
yann@1478
|
363 |
"${extra_config[@]}" \
|
yann@2467
|
364 |
"${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[@]}"
|
benoit@2489
|
365 |
|
yann@2276
|
366 |
# build hacks
|
yann@2276
|
367 |
case "${CT_ARCH},${CT_ARCH_CPU}" in
|
yann@2276
|
368 |
powerpc,8??)
|
yann@2276
|
369 |
# http://sourceware.org/ml/crossgcc/2008-10/msg00068.html
|
yann@2276
|
370 |
CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)"
|
yann@2276
|
371 |
extra_make_args+=( ASFLAGS="-DBROKEN_PPC_8xx_CPU15" )
|
yann@2271
|
372 |
;;
|
yann@1328
|
373 |
esac
|
yann@1328
|
374 |
|
yann@2826
|
375 |
if [ "${libc_headers}" = "y" ]; then
|
bryanhundven@2515
|
376 |
CT_DoLog EXTRA "Installing C library headers"
|
yann@850
|
377 |
|
bryanhundven@2515
|
378 |
# use the 'install-headers' makefile target to install the
|
bryanhundven@2515
|
379 |
# headers
|
yann@2824
|
380 |
CT_DoExecLog ALL make ${JOBSFLAGS} \
|
yann@2823
|
381 |
install_root=${CT_SYSROOT_DIR}${extra_dir} \
|
yann@2824
|
382 |
install-bootstrap-headers=yes \
|
yann@2824
|
383 |
"${extra_make_args[@]}" \
|
bryanhundven@2515
|
384 |
install-headers
|
bryanhundven@2515
|
385 |
|
bryanhundven@2515
|
386 |
# For glibc, a few headers need to be manually installed
|
bryanhundven@2515
|
387 |
if [ "${CT_LIBC}" = "glibc" ]; then
|
bryanhundven@2515
|
388 |
# Two headers -- stubs.h and features.h -- aren't installed by install-headers,
|
bryanhundven@2515
|
389 |
# so do them by hand. We can tolerate an empty stubs.h for the moment.
|
bryanhundven@2515
|
390 |
# See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
|
bryanhundven@2515
|
391 |
mkdir -p "${CT_HEADERS_DIR}/gnu"
|
bryanhundven@2515
|
392 |
CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
|
bryanhundven@2515
|
393 |
CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \
|
bryanhundven@2515
|
394 |
"${CT_HEADERS_DIR}/features.h"
|
bryanhundven@2515
|
395 |
|
bryanhundven@2515
|
396 |
# Building the bootstrap gcc requires either setting inhibit_libc, or
|
bryanhundven@2515
|
397 |
# having a copy of stdio_lim.h... see
|
bryanhundven@2515
|
398 |
# http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
|
bryanhundven@2515
|
399 |
CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
|
bryanhundven@2515
|
400 |
|
bryanhundven@2515
|
401 |
# Following error building gcc-4.0.0's gcj:
|
bryanhundven@2515
|
402 |
# error: bits/syscall.h: No such file or directory
|
bryanhundven@2515
|
403 |
# solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
|
bryanhundven@2515
|
404 |
# but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
|
bryanhundven@2515
|
405 |
case "${CT_ARCH}" in
|
bryanhundven@2515
|
406 |
arm) ;;
|
bryanhundven@2515
|
407 |
*) CT_DoExecLog ALL cp -v "misc/syscall-list.h" \
|
bryanhundven@2515
|
408 |
"${CT_HEADERS_DIR}/bits/syscall.h"
|
bryanhundven@2515
|
409 |
;;
|
bryanhundven@2515
|
410 |
esac
|
bryanhundven@2515
|
411 |
fi
|
yann@2826
|
412 |
fi # libc_headers == y
|
bryanhundven@2515
|
413 |
|
yann@2826
|
414 |
if [ "${libc_startfiles}" = "y" ]; then
|
bryanhundven@2515
|
415 |
if [ "${CT_THREADS}" = "nptl" ]; then
|
bryanhundven@2515
|
416 |
CT_DoLog EXTRA "Installing C library start files"
|
bryanhundven@2515
|
417 |
|
bryanhundven@2515
|
418 |
# there are a few object files needed to link shared libraries,
|
bryanhundven@2515
|
419 |
# which we build and install by hand
|
yann@2823
|
420 |
CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}${extra_dir}/usr/lib"
|
bryanhundven@2515
|
421 |
CT_DoExecLog ALL make ${JOBSFLAGS} \
|
bryanhundven@2515
|
422 |
"${extra_make_args[@]}" \
|
bryanhundven@2515
|
423 |
csu/subdir_lib
|
yann@2824
|
424 |
CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
|
yann@2823
|
425 |
"${CT_SYSROOT_DIR}${extra_dir}/usr/lib"
|
bryanhundven@2515
|
426 |
|
bryanhundven@2515
|
427 |
# Finally, 'libgcc_s.so' requires a 'libc.so' to link against.
|
bryanhundven@2515
|
428 |
# However, since we will never actually execute its code,
|
bryanhundven@2515
|
429 |
# it doesn't matter what it contains. So, treating '/dev/null'
|
bryanhundven@2515
|
430 |
# as a C source file, we produce a dummy 'libc.so' in one step
|
bryanhundven@2515
|
431 |
CT_DoExecLog ALL "${cross_cc}" -nostdlib \
|
bryanhundven@2515
|
432 |
-nostartfiles \
|
bryanhundven@2515
|
433 |
-shared \
|
bryanhundven@2515
|
434 |
-x c /dev/null \
|
yann@2823
|
435 |
-o "${CT_SYSROOT_DIR}${extra_dir}/usr/lib/libc.so"
|
bryanhundven@2515
|
436 |
fi # threads == nptl
|
yann@2826
|
437 |
fi # libc_headers == y
|
yann@2826
|
438 |
|
yann@2826
|
439 |
if [ "${libc_full}" = "y" ]; then
|
bryanhundven@2515
|
440 |
CT_DoLog EXTRA "Building C library"
|
yann@2824
|
441 |
CT_DoExecLog ALL make ${JOBSFLAGS} \
|
yann@2824
|
442 |
"${extra_make_args[@]}" \
|
bryanhundven@2515
|
443 |
all
|
bryanhundven@2515
|
444 |
|
bryanhundven@2515
|
445 |
CT_DoLog EXTRA "Installing C library"
|
yann@2824
|
446 |
CT_DoExecLog ALL make ${JOBSFLAGS} \
|
yann@2824
|
447 |
"${extra_make_args[@]}" \
|
yann@2823
|
448 |
install_root="${CT_SYSROOT_DIR}${extra_dir}" \
|
bryanhundven@2515
|
449 |
install
|
benoit@2585
|
450 |
|
michael@2765
|
451 |
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
|
michael@2765
|
452 |
CT_DoLog EXTRA "Building and installing the C library manual"
|
michael@2765
|
453 |
# Omit JOBSFLAGS as GLIBC has problems building the
|
michael@2765
|
454 |
# manuals in parallel
|
michael@2765
|
455 |
CT_DoExecLog ALL make pdf html
|
michael@2765
|
456 |
# EGLIBC doesn't have a install-{pdf.html} and leaves the manuals
|
michael@2765
|
457 |
# in the source directory
|
michael@2765
|
458 |
CT_DoExecLog ALL mkdir -p ${CT_PREFIX_DIR}/share/doc
|
michael@2765
|
459 |
CT_DoExecLog ALL cp -av ${src_dir}/manual/*.pdf ${src_dir}/manual/libc \
|
michael@2765
|
460 |
${CT_PREFIX_DIR}/share/doc
|
michael@2765
|
461 |
fi
|
michael@2765
|
462 |
|
benoit@2585
|
463 |
if [ "${CT_LIBC_LOCALES}" = "y" ]; then
|
benoit@2585
|
464 |
do_libc_locales
|
benoit@2585
|
465 |
fi
|
yann@2826
|
466 |
fi # libc_full == y
|
yann@850
|
467 |
}
|
yann@850
|
468 |
|
yann@2270
|
469 |
# This function finishes the C library install
|
yann@2270
|
470 |
# This is a no-op
|
yann@850
|
471 |
do_libc_finish() {
|
yann@850
|
472 |
:
|
yann@850
|
473 |
}
|
yann@850
|
474 |
|
yann@850
|
475 |
# Build up the addons list, separated with $1
|
yann@850
|
476 |
do_libc_add_ons_list() {
|
yann@850
|
477 |
local sep="$1"
|
yann@2274
|
478 |
local addons_list="$( echo "${CT_LIBC_ADDONS_LIST}" \
|
yann@2274
|
479 |
|sed -r -e "s/[[:space:],]/${sep}/g;" \
|
yann@2274
|
480 |
)"
|
yann@850
|
481 |
case "${CT_THREADS}" in
|
yann@850
|
482 |
none) ;;
|
yann@850
|
483 |
*) addons_list="${addons_list}${sep}${CT_THREADS}";;
|
yann@850
|
484 |
esac
|
yann@850
|
485 |
[ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports"
|
yann@2274
|
486 |
# Remove duplicate, leading and trailing separators
|
yann@2274
|
487 |
echo "${addons_list}" |sed -r -e "s/${sep}+/${sep}/g; s/^${sep}//; s/${sep}\$//;"
|
yann@850
|
488 |
}
|
yann@2273
|
489 |
|
yann@2273
|
490 |
# Compute up the minimum supported Linux kernel version
|
yann@2273
|
491 |
do_libc_min_kernel_config() {
|
yann@2273
|
492 |
local min_kernel_config
|
yann@2273
|
493 |
|
yann@2467
|
494 |
case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
|
yann@2273
|
495 |
*--enable-kernel*) ;;
|
yann@2273
|
496 |
*) if [ "${CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then
|
yann@2273
|
497 |
# We can't rely on the kernel version from the configuration,
|
yann@2273
|
498 |
# because it might not be available if the user uses pre-installed
|
yann@2273
|
499 |
# headers. On the other hand, both method will have the kernel
|
yann@2279
|
500 |
# version installed in "usr/include/linux/version.h" in the sysroot.
|
yann@2273
|
501 |
# Parse that instead of having two code-paths.
|
yann@2273
|
502 |
version_code_file="${CT_SYSROOT_DIR}/usr/include/linux/version.h"
|
yann@2273
|
503 |
if [ ! -f "${version_code_file}" -o ! -r "${version_code_file}" ]; then
|
yann@2273
|
504 |
CT_Abort "Linux version is unavailable in installed headers files"
|
yann@2273
|
505 |
fi
|
yann@2273
|
506 |
version_code="$( grep -E LINUX_VERSION_CODE "${version_code_file}" \
|
yann@2273
|
507 |
|cut -d ' ' -f 3 \
|
yann@2273
|
508 |
)"
|
yann@2273
|
509 |
version=$(((version_code>>16)&0xFF))
|
yann@2273
|
510 |
patchlevel=$(((version_code>>8)&0xFF))
|
yann@2273
|
511 |
sublevel=$((version_code&0xFF))
|
yann@2273
|
512 |
min_kernel_config="${version}.${patchlevel}.${sublevel}"
|
yann@2273
|
513 |
elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then
|
yann@2273
|
514 |
# Trim the fourth part of the linux version, keeping only the first three numbers
|
yann@2276
|
515 |
min_kernel_config="$( echo "${CT_LIBC_GLIBC_MIN_KERNEL_VERSION}" \
|
yann@2276
|
516 |
|sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;' \
|
yann@2273
|
517 |
)"
|
yann@2273
|
518 |
fi
|
yann@2273
|
519 |
echo "--enable-kernel=${min_kernel_config}"
|
yann@2273
|
520 |
;;
|
yann@2273
|
521 |
esac
|
yann@2273
|
522 |
}
|