1# SPDX-License-Identifier: Apache-2.0
2
3zephyr_library()
4zephyr_library_sources(
5  assert.c
6  cbprintf.c
7  chk_fail.c
8  errno_wrap.c
9  exit.c
10  locks.c
11  stdio.c
12  )
13
14zephyr_library_compile_options(-fno-lto)
15
16# define __LINUX_ERRNO_EXTENSIONS__ so we get errno defines like -ESHUTDOWN
17# used by the network stack
18zephyr_compile_definitions(__LINUX_ERRNO_EXTENSIONS__)
19
20if(NOT CONFIG_PICOLIBC_USE_MODULE)
21
22  # Use picolibc provided with the toolchain. This requires a new enough
23  # toolchain so that the version of picolibc supports auto-detecting a
24  # Zephyr build (via the __ZEPHYR__ macro) to expose the Zephyr C API
25  zephyr_compile_options(PROPERTY specs picolibc.specs)
26  zephyr_link_libraries(PROPERTY specs picolibc.specs)
27  if(CONFIG_PICOLIBC_IO_FLOAT)
28    zephyr_compile_definitions(PICOLIBC_DOUBLE_PRINTF_SCANF)
29    zephyr_link_libraries(-DPICOLIBC_DOUBLE_PRINTF_SCANF)
30  elseif(CONFIG_PICOLIBC_IO_MINIMAL)
31    zephyr_compile_definitions(PICOLIBC_MINIMAL_PRINTF_SCANF)
32    zephyr_link_libraries(-DPICOLIBC_MINIMAL_PRINTF_SCANF)
33  elseif(CONFIG_PICOLIBC_IO_LONG_LONG)
34    zephyr_compile_definitions(PICOLIBC_LONG_LONG_PRINTF_SCANF)
35    zephyr_link_libraries(-DPICOLIBC_LONG_LONG_PRINTF_SCANF)
36  else()
37    zephyr_compile_definitions(PICOLIBC_INTEGER_PRINTF_SCANF)
38    zephyr_link_libraries(-DPICOLIBC_INTEGER_PRINTF_SCANF)
39  endif()
40
41endif()
42