2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
zephyr_library()
|
|
|
|
zephyr_library_sources(libc-hooks.c)
|
|
|
|
|
2019-08-14 06:24:45 +08:00
|
|
|
# Zephyr normally uses -ffreestanding, which with current GNU toolchains
|
|
|
|
# means that the flag macros used by newlib 3.x <inttypes.h> to signal
|
|
|
|
# support for PRI.64 macros are not present. To make them available we
|
|
|
|
# need to hook into the include path before the system files and
|
|
|
|
# explicitly include the newlib header that provides those macros.
|
|
|
|
zephyr_include_directories(include)
|
|
|
|
|
2018-01-09 00:06:42 +08:00
|
|
|
# LIBC_*_DIR may or may not have been set by the toolchain. E.g. when
|
2018-02-12 04:36:21 +08:00
|
|
|
# using ZEPHYR_TOOLCHAIN_VARIANT=cross-compile it will be either up to the
|
2018-01-09 00:06:42 +08:00
|
|
|
# toolchain to know where it's libc implementation is, or if it is
|
|
|
|
# unable to, it will be up to the user to specify LIBC_*_DIR vars to
|
2019-08-14 06:24:45 +08:00
|
|
|
# point to a newlib implementation. Note that this does not change the
|
|
|
|
# directory order if LIBC_INCLUDE_DIR is already a system header
|
|
|
|
# directory.
|
2018-01-09 00:06:42 +08:00
|
|
|
|
|
|
|
if(LIBC_INCLUDE_DIR)
|
2019-08-14 06:24:45 +08:00
|
|
|
zephyr_include_directories(${LIBC_INCLUDE_DIR})
|
2018-01-09 00:06:42 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(LIBC_LIBRARY_DIR)
|
|
|
|
set(LIBC_LIBRARY_DIR_FLAG -L${LIBC_LIBRARY_DIR})
|
|
|
|
endif()
|
|
|
|
|
2018-07-12 04:57:03 +08:00
|
|
|
# define __LINUX_ERRNO_EXTENSIONS__ so we get errno defines like -ESHUTDOWN
|
|
|
|
# used by the network stack
|
|
|
|
zephyr_compile_definitions(__LINUX_ERRNO_EXTENSIONS__)
|
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
zephyr_link_libraries(
|
|
|
|
m
|
|
|
|
c
|
2018-01-09 00:06:42 +08:00
|
|
|
${LIBC_LIBRARY_DIR_FLAG} # NB: Optional
|
2017-10-27 21:43:34 +08:00
|
|
|
$<$<BOOL:${CONFIG_NEWLIB_LIBC_FLOAT_PRINTF}>:-u_printf_float>
|
|
|
|
$<$<BOOL:${CONFIG_NEWLIB_LIBC_FLOAT_SCANF}>:-u_scanf_float>
|
|
|
|
gcc # Lib C depends on libgcc. e.g. libc.a(lib_a-fvwrite.o) references __aeabi_idiv
|
|
|
|
)
|
2019-01-25 21:37:56 +08:00
|
|
|
|
|
|
|
if(CONFIG_NEWLIB_LIBC_NANO)
|
|
|
|
zephyr_link_libraries(
|
|
|
|
-specs=nano.specs
|
|
|
|
)
|
|
|
|
zephyr_compile_options(
|
|
|
|
-specs=nano.specs
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|