Add an option to forbid downloads.
Idea and code-base from Don Elwell <don@manifoldlabs.com>, adapted by me.
/trunk/scripts/functions | 6 6 0 0 ++++++
/trunk/config/global/download.in | 18 18 0 0 ++++++++++++++++++
2 files changed, 24 insertions(+)
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 "uClibc-${CT_LIBC_VERSION}" ${libc_src}
15 if [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ]; then
16 CT_GetFile "uClibc-locale-030818" ${libc_src}
24 CT_Extract "uClibc-${CT_LIBC_VERSION}"
25 CT_Patch "uClibc-${CT_LIBC_VERSION}"
28 if [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ]; then
29 CT_Pushd "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}/extra/locale"
30 CT_Extract "uClibc-locale-030818" nochdir
31 CT_Patch "uClibc-locale-030818" nochdir
38 # Check that uClibc has been previously configured
39 do_libc_check_config() {
40 CT_DoStep INFO "Checking C library configuration"
42 CT_TestOrAbort "You did not provide a uClibc config file!" -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" -a -f "${CT_LIBC_UCLIBC_CONFIG_FILE}"
44 if egrep '^KERNEL_SOURCE=' "${CT_LIBC_UCLIBC_CONFIG_FILE}" >/dev/null 2>&1; then
45 CT_DoLog WARN "Your uClibc version refers to the kernel _sources_, which is bad."
46 CT_DoLog WARN "I can't guarantee that our little hack will work. Please try to upgrade."
49 CT_DoLog EXTRA "Munging uClibc configuration"
50 mungeuClibcConfig "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_BUILD_DIR}/uClibc.config"
55 # This functions installs uClibc's headers
57 CT_DoStep INFO "Installing C library headers"
59 mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
60 cd "${CT_BUILD_DIR}/build-libc-headers"
62 # Simply copy files until uClibc has the ablity to build out-of-tree
63 CT_DoLog EXTRA "Copying sources to build dir"
64 { cd "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}"; tar cf - .; } |tar xf -
66 # Retrieve the config file
67 cp "${CT_BUILD_DIR}/uClibc.config" .config
69 # uClibc uses the CROSS environment variable as a prefix to the
70 # compiler tools to use. Setting it to the empty string forces
71 # use of the native build host tools, which we need at this
72 # stage, as we don't have target tools yet.
73 CT_DoLog EXTRA "Applying configuration"
74 CT_DoYes "" |CT_DoExecLog ALL make CROSS= PREFIX="${CT_SYSROOT_DIR}/" oldconfig
76 CT_DoLog EXTRA "Building headers"
77 CT_DoExecLog ALL make ${CT_LIBC_UCLIBC_VERBOSITY} CROSS= PREFIX="${CT_SYSROOT_DIR}/" headers
79 CT_DoLog EXTRA "Installing headers"
80 CT_DoExecLog ALL make ${CT_LIBC_UCLIBC_VERBOSITY} CROSS= PREFIX="${CT_SYSROOT_DIR}/" install_headers
85 # Build and install start files
86 do_libc_start_files() {
90 # This function build and install the full uClibc
92 CT_DoStep INFO "Installing C library"
94 mkdir -p "${CT_BUILD_DIR}/build-libc"
95 cd "${CT_BUILD_DIR}/build-libc"
97 # Simply copy files until uClibc has the ablity to build out-of-tree
98 CT_DoLog EXTRA "Copying sources to build dir"
99 { cd "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}"; tar cf - .; } |tar xf -
101 # Retrieve the config file
102 cp "${CT_BUILD_DIR}/uClibc.config" .config
104 # uClibc uses the CROSS environment variable as a prefix to the compiler
105 # tools to use. The newly built tools should be in our path, so we need
106 # only give the correct name for them.
107 # Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
108 # depending on the configuration of the library. That is, they are tailored
109 # to best fit the target. So it is useless and seems to be a bad thing to
110 # use LIBC_EXTRA_CFLAGS here.
111 CT_DoLog EXTRA "Applying configuration"
112 CT_DoYes "" |CT_DoExecLog ALL \
113 make CROSS=${CT_TARGET}- \
114 PREFIX="${CT_SYSROOT_DIR}/" \
117 # We do _not_ want to strip anything for now, in case we specifically
118 # asked for a debug toolchain, thus the STRIPTOOL= assignment
119 # /Old/ versions can not build in //
120 CT_DoLog EXTRA "Building C library"
122 make ${CT_LIBC_UCLIBC_PARALLEL:+${PARALLELMFLAGS}} \
123 CROSS=${CT_TARGET}- \
124 PREFIX="${CT_SYSROOT_DIR}/" \
126 ${CT_LIBC_UCLIBC_VERBOSITY} \
129 # YEM-FIXME: we want to install libraries in $SYSROOT/lib, but we don't want
130 # to install headers in $SYSROOT/include, thus making only install_runtime.
131 # Plus, the headers were previously installed earlier with install_headers,
132 # so all should be well. Unfortunately, the install_headers target does not
133 # install crti.o and consorts... :-( So reverting to target 'install'.
134 # Note: PARALLELMFLAGS is not usefull for installation.
135 # We do _not_ want to strip anything for now, in case we specifically
136 # asked for a debug toolchain, hence the STRIPTOOL= assignment
137 CT_DoLog EXTRA "Installing C library"
139 make CROSS=${CT_TARGET}- \
140 PREFIX="${CT_SYSROOT_DIR}/" \
142 ${CT_LIBC_UCLIBC_VERBOSITY} \
148 # This function is used to install those components needing the final C compiler
150 # Build and install host-side ldd
151 CT_DoStep INFO "Finishing C library"
153 mkdir -p "${CT_BUILD_DIR}/build-libc-finish"
154 cd "${CT_BUILD_DIR}/build-libc-finish"
156 # Simply copy files until uClibc has the ablity to build out-of-tree
157 CT_DoLog EXTRA "Copying sources to build dir"
158 { cd "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}"; tar cf - .; } |tar xf -
160 # Retrieve the config file
161 cp "${CT_BUILD_DIR}/uClibc.config" .config
163 CT_DoLog EXTRA "Applying configuration"
164 CT_DoYes "" |CT_DoExecLog ALL \
165 make CROSS=${CT_TARGET}- \
166 PREFIX="${CT_SYSROOT_DIR}/" \
169 CT_DoLog EXTRA "Installing C library host utils"
171 make PREFIX="${CT_SYSROOT_DIR}/" \
172 ${CT_LIBC_UCLIBC_VERBOSITY} \
174 CT_DoExecLog ALL install -m 0755 utils/ldd.host "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
179 # Initialises the .config file to sensible values
182 mungeuClibcConfig() {
185 munge_file="${CT_BUILD_DIR}/munge-uClibc-config.sed"
187 # Start with a fresh file
188 rm -f "${munge_file}"
189 touch "${munge_file}"
191 # Hack our target in the config file.
192 # Also remove stripping: its the responsibility of the
193 # firmware builder to strip or not.
194 cat >>"${munge_file}" <<-ENDSED
195 s/^(TARGET_.*)=y$/# \\1 is not set/
196 s/^# TARGET_${CT_KERNEL_ARCH} is not set/TARGET_${CT_KERNEL_ARCH}=y/
197 s/^TARGET_ARCH=".*"/TARGET_ARCH="${CT_KERNEL_ARCH}"/
198 s/.*(DOSTRIP).*/# \\1 is not set/
201 # Ah. We may one day need architecture-specific handler here...
202 # Hack the ARM {E,O}ABI into the config file
203 if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then
204 cat >>"${munge_file}" <<-ENDSED
205 s/.*(CONFIG_ARM_OABI).*/# \\1 is not set/
206 s/.*(CONFIG_ARM_EABI).*/\\1=y/
209 cat >>"${munge_file}" <<-ENDSED
210 s/.*(CONFIG_ARM_OABI).*/\\1=y/
211 s/.*(CONFIG_ARM_EABI).*/# \\1 is not set/
215 # Accomodate for old and new uClibc versions, where the
216 # way to select between big/little endian has changed
217 case "${CT_ARCH_BE},${CT_ARCH_LE}" in
218 y,) cat >>"${munge_file}" <<-ENDSED
219 s/.*(ARCH_LITTLE_ENDIAN).*/# \\1 is not set/
220 s/.*(ARCH_BIG_ENDIAN).*/\\1=y/
221 s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/# \\1 is not set/
222 s/.*(ARCH_WANTS_BIG_ENDIAN).*/\\1=y/
225 ,y) cat >>"${munge_file}" <<-ENDSED
226 s/.*(ARCH_LITTLE_ENDIAN).*/\\1=y/
227 s/.*(ARCH_BIG_ENDIAN).*/# \\1 is not set/
228 s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/\\1=y/
229 s/.*(ARCH_WANTS_BIG_ENDIAN).*/# \\1 is not set/
234 # Accomodate for old and new uClibc version, where the
235 # way to select between hard/soft float has changed
236 case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
237 y,) cat >>"${munge_file}" <<-ENDSED
238 s/^[^_]*(HAS_FPU).*/\\1=y/
239 s/.*(UCLIBC_HAS_FPU).*/\\1=y/
242 ,y) cat >>"${munge_file}" <<-ENDSED
243 s/^[^_]*(HAS_FPU).*/\\# \\1 is not set/
244 s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
249 # Change paths to work with crosstool-NG
250 # From http://www.uclibc.org/cgi-bin/viewcvs.cgi?rev=16846&view=rev
251 # " we just want the kernel headers, not the whole kernel source ...
252 # " so people may need to update their paths slightly
253 quoted_kernel_source=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/include/?$,,; s,/,\\/,g;')
254 quoted_headers_dir=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/,\\/,g;')
255 # CROSS_COMPILER_PREFIX is left as is, as the CROSS parameter is forced on the command line
256 # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, wich is the correct value of ${PREFIX}/${TARGET}
257 # Some (old) versions of uClibc use KERNEL_SOURCE (which is _wrong_), and
258 # newer versions use KERNEL_HEADERS (which is right). See:
259 cat >>"${munge_file}" <<-ENDSED
260 s/^DEVEL_PREFIX=".*"/DEVEL_PREFIX="\\/usr\\/"/
261 s/^RUNTIME_PREFIX=".*"/RUNTIME_PREFIX="\\/"/
262 s/^SHARED_LIB_LOADER_PREFIX=.*/SHARED_LIB_LOADER_PREFIX="\\/lib\\/"/
263 s/^KERNEL_SOURCE=".*"/KERNEL_SOURCE="${quoted_kernel_source}"/
264 s/^KERNEL_HEADERS=".*"/KERNEL_HEADERS="${quoted_headers_dir}"/
265 s/^UCLIBC_DOWNLOAD_PREGENERATED_LOCALE=y/\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE is not set/
268 if [ "${CT_USE_PIPES}" = "y" ]; then
269 if grep UCLIBC_EXTRA_CFLAGS extra/Configs/Config.in >/dev/null 2>&1; then
270 # Good, there is special provision for such things as -pipe!
271 cat >>"${munge_file}" <<-ENDSED
272 s/^(UCLIBC_EXTRA_CFLAGS=".*)"$/\\1 -pipe"/
275 # Hack our -pipe into WARNINGS, which will be internally incorporated to
276 # CFLAGS. This a dirty hack, but yet needed
277 cat >> "${munge_file}" <<-ENDSED
278 s/^(WARNINGS=".*)"$/\\1 -pipe"/
284 # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing
285 # entirely if LOCALE is not set. If LOCALE was already set, we'll
286 # assume the user has already made all the appropriate generation
287 # arrangements. Note that having the uClibc Makefile download the
288 # pregenerated locales is not compatible with crosstool; besides,
289 # crosstool downloads them as part of getandpatch.sh.
290 if [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] ; then
291 cat >>"${munge_file}" <<-ENDSED
292 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
296 # Force on options needed for C++ if we'll be making a C++ compiler.
297 # I'm not sure locales are a requirement for doing C++... Are they?
298 if [ "${CT_CC_LANG_CXX}" = "y" ]; then
299 cat >>"${munge_file}" <<-ENDSED
300 s/^# DO_C99_MATH is not set/DO_C99_MATH=y/
301 s/^# UCLIBC_CTOR_DTOR is not set/UCLIBC_CTOR_DTOR=y/
302 # Add these three lines when doing C++?
303 s/^# UCLIBC_HAS_WCHAR is not set/UCLIBC_HAS_WCHAR=y/
304 #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/
305 s/^# UCLIBC_HAS_GNU_GETOPT is not set/UCLIBC_HAS_GNU_GETOPT=y/
309 # Always build the libpthread_db
310 cat >>"${munge_file}" <<-ENDSED
311 s/^# PTHREADS_DEBUG_SUPPORT is not set.*/PTHREADS_DEBUG_SUPPORT=y/
314 # Force on debug options if asked for
315 case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
317 cat >>"${munge_file}" <<-ENDSED
318 s/^DODEBUG=y/# DODEBUG is not set/
319 s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
320 s/^DOASSERTS=y/# DOASSERTS is not set/
321 s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
322 s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
323 s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
327 cat >>"${munge_file}" <<-ENDSED
328 s/^# DODEBUG is not set.*/DODEBUG=y/
329 s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
330 s/^DOASSERTS=y/# DOASSERTS is not set/
331 s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
332 s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
333 s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
337 cat >>"${munge_file}" <<-ENDSED
338 s/^# DODEBUG is not set.*/DODEBUG=y/
339 s/^# DODEBUG_PT is not set.*/DODEBUG_PT=y/
340 s/^# DOASSERTS is not set.*/DOASSERTS=y/
341 s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
342 s/^# SUPPORT_LD_DEBUG_EARLY is not set.*/SUPPORT_LD_DEBUG_EARLY=y/
343 s/^# UCLIBC_MALLOC_DEBUGGING is not set/UCLIBC_MALLOC_DEBUGGING=y/
347 sed -r -f "${munge_file}" "${src_config_file}" >"${dst_config_file}"