1 # This file adds functions to build the Newlib C library
2 # Copyright 2009 DoréDevelopment
3 # Licensed under the GPL v2. See COPYING in the root of this package
5 # Edited by Martin Lund <mgl@doredevelopment.dk>
8 LIBC_NEWLIB_AVR_HDRS_URI="http://www.atmel.com/Images"
9 LIBC_NEWLIB_AVR_HDRS_BASE="avr-headers-3.2.3.970"
10 LIBC_NEWLIB_AVR_HDRS_EXT=".zip"
13 local libc_src="ftp://sourceware.org/pub/newlib"
15 if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then
16 CT_GetCustom "newlib" "${CT_LIBC_VERSION}" \
17 "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
18 else # ! custom location
19 CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src} \
20 http://mirrors.kernel.org/sources.redhat.com/newlib
21 fi # ! custom location
23 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
24 CT_GetFile ${LIBC_NEWLIB_AVR_HDRS_BASE} \
25 ${LIBC_NEWLIB_AVR_HDRS_EXT} \
26 ${LIBC_NEWLIB_AVR_HDRS_URI}
31 # If using custom directory location, nothing to do
32 if [ "${CT_LIBC_NEWLIB_CUSTOM}" != "y" \
33 -a -d "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}" ]; then
37 CT_Extract "newlib-${CT_LIBC_VERSION}"
38 CT_Patch "newlib" "${CT_LIBC_VERSION}"
40 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
41 # The avr32header zip file extracts to avr32/*.h
42 # Put that in its directory, the same as normal tarballs
43 CT_Extract ${LIBC_NEWLIB_AVR_HDRS_BASE} \
44 -d ${CT_SRC_DIR}/${LIBC_NEWLIB_AVR_HDRS_BASE}
48 do_libc_check_config() {
52 do_libc_start_files() {
53 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
54 CT_DoStep INFO "Installing C library headers & start files"
56 CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
57 CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include"
58 CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/${LIBC_NEWLIB_AVR_HDRS_BASE}/avr32" \
59 "${CT_PREFIX_DIR}/${CT_TARGET}/include/"
68 CT_DoStep INFO "Installing C library"
70 mkdir -p "${CT_BUILD_DIR}/build-libc"
71 cd "${CT_BUILD_DIR}/build-libc"
73 CT_DoLog EXTRA "Configuring C library"
75 if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
76 newlib_opts+=( "--enable-newlib-io-c99-formats" )
78 newlib_opts+=( "--disable-newlib-io-c99-formats" )
80 if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
81 newlib_opts+=( "--enable-newlib-io-long-long" )
83 newlib_opts+=( "--disable-newlib-io-long-long" )
85 if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
86 newlib_opts+=( "--enable-newlib-io-float" )
87 if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
88 newlib_opts+=( "--enable-newlib-io-long-double" )
90 newlib_opts+=( "--disable-newlib-io-long-double" )
93 newlib_opts+=( "--disable-newlib-io-float" )
94 newlib_opts+=( "--disable-newlib-io-long-double" )
96 if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
97 newlib_opts+=( "--disable-newlib-supplied-syscalls" )
99 newlib_opts+=( "--enable-newlib-supplied-syscalls" )
102 [ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace")
104 # Note: newlib handles the build/host/target a little bit differently
105 # than one would expect:
107 # host : the machine building newlib
108 # target : the machine newlib runs on
110 CC_FOR_BUILD="${CT_BUILD}-gcc" \
111 CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
113 RANLIB=${CT_TARGET}-ranlib \
114 "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
116 --target=${CT_TARGET} \
117 --prefix=${CT_PREFIX_DIR} \
118 "${newlib_opts[@]}" \
119 "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
121 CT_DoLog EXTRA "Building C library"
122 CT_DoExecLog ALL make ${JOBSFLAGS}
124 CT_DoLog EXTRA "Installing C library"
125 CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
127 if [ "${CT_BUILD_MANUALS}" = "y" ]; then
128 local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}"
130 CT_DoLog EXTRA "Building and installing the C library manual"
131 CT_DoExecLog ALL make pdf html
133 # NEWLIB install-{pdf.html} fail for some versions
134 CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share/doc/newlib"
135 CT_DoExecLog ALL cp -av "${doc_dir}/newlib/libc/libc.pdf" \
136 "${doc_dir}/newlib/libm/libm.pdf" \
137 "${doc_dir}/newlib/libc/libc.html" \
138 "${doc_dir}/newlib/libm/libm.html" \
139 "${CT_PREFIX_DIR}/share/doc/newlib"