A small layout enhancement in the Linux kernel build script.
/trunk/scripts/build/kernel/linux.sh | 3 2 1 0 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
1 # This file declares functions to install the uClibc C library
2 # Copyright 2007 Yann E. MORIN
3 # Licensed under the GPL v2. See COPYING in the root of this package
7 libc_src="http://www.uclibc.org/downloads
8 http://www.uclibc.org/downloads/snapshots
9 http://www.uclibc.org/downloads/old-releases"
10 # For uClibc, we have almost every thing: releases, and snapshots
11 # for the last month or so. We'll have to deal with svn revisions
13 CT_GetFile "${CT_LIBC_FILE}" ${libc_src}
15 [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] && CT_GetFile "uClibc-locale-030818" ${libc_src} || true
22 CT_ExtractAndPatch "${CT_LIBC_FILE}"
24 [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] && CT_ExtractAndPatch "uClibc-locale-030818" || true
29 # Check that uClibc has been previously configured
30 do_libc_check_config() {
31 CT_DoStep INFO "Checking C library configuration"
33 CT_TestOrAbort "You did not provide a uClibc config file!" -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" -a -f "${CT_LIBC_UCLIBC_CONFIG_FILE}"
35 if egrep '^KERNEL_SOURCE=' "${CT_LIBC_UCLIBC_CONFIG_FILE}" >/dev/null 2>&1; then
36 CT_DoLog WARN "Your uClibc version refers to the kernel _sources_, which is bad."
37 CT_DoLog WARN "I can't guarantee that our little hack will work. Please try to upgrade."
40 CT_DoLog EXTRA "Munging uClibc configuration"
41 mungeuClibcConfig "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_BUILD_DIR}/uClibc.config"
46 # This functions installs uClibc's headers
48 # Only need to install bootstrap uClibc headers for gcc-3.0 and above? Or maybe just gcc-3.3 and above?
49 # See also http://gcc.gnu.org/PR8180, which complains about the need for this step.
50 grep -q 'gcc-[34]' "${CT_SRC_DIR}/${CT_CC_FILE}/ChangeLog" 2>/dev/null || return 0
52 CT_DoStep INFO "Installing C library headers"
54 mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
55 cd "${CT_BUILD_DIR}/build-libc-headers"
57 # Simply copy files until uClibc has the ablity to build out-of-tree
58 CT_DoLog EXTRA "Copying sources to build dir"
59 { cd "${CT_SRC_DIR}/${CT_LIBC_FILE}"; tar cf - .; } |tar xf -
61 # Retrieve the config file
62 cp "${CT_BUILD_DIR}/uClibc.config" .config
64 # uClibc uses the CROSS environment variable as a prefix to the
65 # compiler tools to use. Setting it to the empty string forces
66 # use of the native build host tools, which we need at this
67 # stage, as we don't have target tools yet.
68 CT_DoLog EXTRA "Applying configuration"
69 CT_DoYes "" |CT_DoExecLog ALL make CROSS= PREFIX="${CT_SYSROOT_DIR}/" oldconfig
71 CT_DoLog EXTRA "Building headers"
72 CT_DoExecLog ALL make ${CT_LIBC_UCLIBC_VERBOSITY} CROSS= PREFIX="${CT_SYSROOT_DIR}/" headers
74 CT_DoLog EXTRA "Installing headers"
75 CT_DoExecLog ALL make ${CT_LIBC_UCLIBC_VERBOSITY} CROSS= PREFIX="${CT_SYSROOT_DIR}/" install_headers
80 # Build and install start files
81 do_libc_start_files() {
85 # This function build and install the full uClibc
87 CT_DoStep INFO "Installing C library"
89 mkdir -p "${CT_BUILD_DIR}/build-libc"
90 cd "${CT_BUILD_DIR}/build-libc"
92 # Simply copy files until uClibc has the ablity to build out-of-tree
93 CT_DoLog EXTRA "Copying sources to build dir"
94 { cd "${CT_SRC_DIR}/${CT_LIBC_FILE}"; tar cf - .; } |tar xf -
96 # Retrieve the config file
97 cp "${CT_BUILD_DIR}/uClibc.config" .config
99 # uClibc uses the CROSS environment variable as a prefix to the compiler
100 # tools to use. The newly built tools should be in our path, so we need
101 # only give the correct name for them.
102 # Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
103 # depending on the configuration of the library. That is, they are tailored
104 # to best fit the target. So it is useless and seems to be a bad thing to
105 # use LIBC_EXTRA_CFLAGS here.
106 CT_DoLog EXTRA "Applying configuration"
107 CT_DoYes "" |CT_DoExecLog ALL \
108 make CROSS=${CT_TARGET}- \
109 PREFIX="${CT_SYSROOT_DIR}/" \
112 # We do _not_ want to strip anything for now, in case we specifically
113 # asked for a debug toolchain, thus the STRIPTOOL= assignment
114 # /Old/ versions can not build in //
115 CT_DoLog EXTRA "Building C library"
117 make ${CT_LIBC_UCLIBC_PARALLEL:+${PARALLELMFLAGS}} \
118 CROSS=${CT_TARGET}- \
119 PREFIX="${CT_SYSROOT_DIR}/" \
121 ${CT_LIBC_UCLIBC_VERBOSITY} \
124 # YEM-FIXME: we want to install libraries in $SYSROOT/lib, but we don't want
125 # to install headers in $SYSROOT/include, thus making only install_runtime.
126 # Plus, the headers were previously installed earlier with install_headers,
127 # so all should be well. Unfortunately, the install_headers target does not
128 # install crti.o and consorts... :-( So reverting to target 'install'.
129 # Note: PARALLELMFLAGS is not usefull for installation.
130 # We do _not_ want to strip anything for now, in case we specifically
131 # asked for a debug toolchain, hence the STRIPTOOL= assignment
132 CT_DoLog EXTRA "Installing C library"
134 make CROSS=${CT_TARGET}- \
135 PREFIX="${CT_SYSROOT_DIR}/" \
137 ${CT_LIBC_UCLIBC_VERBOSITY} \
143 # This function is used to install those components needing the final C compiler
145 # Build and install host-side ldd
146 CT_DoStep INFO "Finishing C library"
148 mkdir -p "${CT_BUILD_DIR}/build-libc-finish"
149 cd "${CT_BUILD_DIR}/build-libc-finish"
151 # Simply copy files until uClibc has the ablity to build out-of-tree
152 CT_DoLog EXTRA "Copying sources to build dir"
153 { cd "${CT_SRC_DIR}/${CT_LIBC_FILE}"; tar cf - .; } |tar xf -
155 # Retrieve the config file
156 cp "${CT_BUILD_DIR}/uClibc.config" .config
158 CT_DoLog EXTRA "Applying configuration"
159 CT_DoYes "" |CT_DoExecLog ALL \
160 make CROSS=${CT_TARGET}- \
161 PREFIX="${CT_SYSROOT_DIR}/" \
164 CT_DoLog EXTRA "Installing C library host utils"
166 make PREFIX="${CT_SYSROOT_DIR}/" \
167 ${CT_LIBC_UCLIBC_VERBOSITY} \
169 CT_DoExecLog ALL install -m 0755 utils/ldd.host "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
174 # Initialises the .config file to sensible values
177 mungeuClibcConfig() {
180 munge_file="${CT_BUILD_DIR}/munge-uClibc-config.sed"
182 # Start with a fresh file
183 rm -f "${munge_file}"
184 touch "${munge_file}"
186 # Hack our target in the config file.
187 # Also remove stripping: its the responsibility of the
188 # firmware builder to strip or not.
189 cat >>"${munge_file}" <<-ENDSED
190 s/^(TARGET_.*)=y$/# \\1 is not set/
191 s/^# TARGET_${CT_KERNEL_ARCH} is not set/TARGET_${CT_KERNEL_ARCH}=y/
192 s/^TARGET_ARCH=".*"/TARGET_ARCH="${CT_KERNEL_ARCH}"/
193 s/.*(DOSTRIP).*/# \\1 is not set/
196 # Ah. We may one day need architecture-specific handler here...
197 # Hack the ARM {E,O}ABI into the config file
198 if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then
199 cat >>"${munge_file}" <<-ENDSED
200 s/.*(CONFIG_ARM_OABI).*/# \\1 is not set/
201 s/.*(CONFIG_ARM_EABI).*/\\1=y/
204 cat >>"${munge_file}" <<-ENDSED
205 s/.*(CONFIG_ARM_OABI).*/\\1=y/
206 s/.*(CONFIG_ARM_EABI).*/# \\1 is not set/
210 # Accomodate for old and new uClibc versions, where the
211 # way to select between big/little endian has changed
212 case "${CT_ARCH_BE},${CT_ARCH_LE}" in
213 y,) cat >>"${munge_file}" <<-ENDSED
214 s/.*(ARCH_LITTLE_ENDIAN).*/# \\1 is not set/
215 s/.*(ARCH_BIG_ENDIAN).*/\\1=y/
216 s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/# \\1 is not set/
217 s/.*(ARCH_WANTS_BIG_ENDIAN).*/\\1=y/
220 ,y) cat >>"${munge_file}" <<-ENDSED
221 s/.*(ARCH_LITTLE_ENDIAN).*/\\1=y/
222 s/.*(ARCH_BIG_ENDIAN).*/# \\1 is not set/
223 s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/\\1=y/
224 s/.*(ARCH_WANTS_BIG_ENDIAN).*/# \\1 is not set/
229 # Accomodate for old and new uClibc version, where the
230 # way to select between hard/soft float has changed
231 case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
232 y,) cat >>"${munge_file}" <<-ENDSED
233 s/^[^_]*(HAS_FPU).*/\\1=y/
234 s/.*(UCLIBC_HAS_FPU).*/\\1=y/
237 ,y) cat >>"${munge_file}" <<-ENDSED
238 s/^[^_]*(HAS_FPU).*/\\# \\1 is not set/
239 s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
244 # Change paths to work with crosstool-NG
245 # From http://www.uclibc.org/cgi-bin/viewcvs.cgi?rev=16846&view=rev
246 # " we just want the kernel headers, not the whole kernel source ...
247 # " so people may need to update their paths slightly
248 quoted_kernel_source=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/include/?$,,; s,/,\\/,g;')
249 quoted_headers_dir=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/,\\/,g;')
250 # CROSS_COMPILER_PREFIX is left as is, as the CROSS parameter is forced on the command line
251 # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, wich is the correct value of ${PREFIX}/${TARGET}
252 # Some (old) versions of uClibc use KERNEL_SOURCE (which is _wrong_), and
253 # newer versions use KERNEL_HEADERS (which is right). See:
254 cat >>"${munge_file}" <<-ENDSED
255 s/^DEVEL_PREFIX=".*"/DEVEL_PREFIX="\\/usr\\/"/
256 s/^RUNTIME_PREFIX=".*"/RUNTIME_PREFIX="\\/"/
257 s/^SHARED_LIB_LOADER_PREFIX=.*/SHARED_LIB_LOADER_PREFIX="\\/lib\\/"/
258 s/^KERNEL_SOURCE=".*"/KERNEL_SOURCE="${quoted_kernel_source}"/
259 s/^KERNEL_HEADERS=".*"/KERNEL_HEADERS="${quoted_headers_dir}"/
260 s/^UCLIBC_DOWNLOAD_PREGENERATED_LOCALE=y/\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE is not set/
263 if [ "${CT_USE_PIPES}" = "y" ]; then
264 if grep UCLIBC_EXTRA_CFLAGS extra/Configs/Config.in >/dev/null 2>&1; then
265 # Good, there is special provision for such things as -pipe!
266 cat >>"${munge_file}" <<-ENDSED
267 s/^(UCLIBC_EXTRA_CFLAGS=".*)"$/\\1 -pipe"/
270 # Hack our -pipe into WARNINGS, which will be internally incorporated to
271 # CFLAGS. This a dirty hack, but yet needed
272 cat >> "${munge_file}" <<-ENDSED
273 s/^(WARNINGS=".*)"$/\\1 -pipe"/
279 # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing
280 # entirely if LOCALE is not set. If LOCALE was already set, we'll
281 # assume the user has already made all the appropriate generation
282 # arrangements. Note that having the uClibc Makefile download the
283 # pregenerated locales is not compatible with crosstool; besides,
284 # crosstool downloads them as part of getandpatch.sh.
285 if [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] ; then
286 cat >>"${munge_file}" <<-ENDSED
287 s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\nUCLIBC_PREGENERATED_LOCALE_DATA=y\\n\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\n\\# UCLIBC_HAS_XLOCALE is not
291 # Force on options needed for C++ if we'll be making a C++ compiler.
292 # I'm not sure locales are a requirement for doing C++... Are they?
293 if [ "${CT_CC_LANG_CXX}" = "y" ]; then
294 cat >>"${munge_file}" <<-ENDSED
295 s/^# DO_C99_MATH is not set/DO_C99_MATH=y/
296 s/^# UCLIBC_CTOR_DTOR is not set/UCLIBC_CTOR_DTOR=y/
297 # Add these three lines when doing C++?
298 s/^# UCLIBC_HAS_WCHAR is not set/UCLIBC_HAS_WCHAR=y/
299 #s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\nUCLIBC_PREGENERATED_LOCALE_DATA=y\\n\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\n\\# UCLIBC_HAS_XLOCALE is not set/
300 s/^# UCLIBC_HAS_GNU_GETOPT is not set/UCLIBC_HAS_GNU_GETOPT=y/
304 # Always build the libpthread_db
305 cat >>"${munge_file}" <<-ENDSED
306 s/^# PTHREADS_DEBUG_SUPPORT is not set.*/PTHREADS_DEBUG_SUPPORT=y/
309 # Force on debug options if asked for
310 case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
312 cat >>"${munge_file}" <<-ENDSED
313 s/^DODEBUG=y/# DODEBUG is not set/
314 s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
315 s/^DOASSERTS=y/# DOASSERTS is not set/
316 s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
317 s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
318 s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
322 cat >>"${munge_file}" <<-ENDSED
323 s/^# DODEBUG is not set.*/DODEBUG=y/
324 s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
325 s/^DOASSERTS=y/# DOASSERTS is not set/
326 s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
327 s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
328 s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
332 cat >>"${munge_file}" <<-ENDSED
333 s/^# DODEBUG is not set.*/DODEBUG=y/
334 s/^# DODEBUG_PT is not set.*/DODEBUG_PT=y/
335 s/^# DOASSERTS is not set.*/DOASSERTS=y/
336 s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
337 s/^# SUPPORT_LD_DEBUG_EARLY is not set.*/SUPPORT_LD_DEBUG_EARLY=y/
338 s/^# UCLIBC_MALLOC_DEBUGGING is not set/UCLIBC_MALLOC_DEBUGGING=y/
342 sed -r -f "${munge_file}" "${src_config_file}" >"${dst_config_file}"