1# SPDX-License-Identifier: Apache-2.0
2
3# As minimal libc will be built as a zephyr_library, clear c_library to
4# prevent accidentally requiring or linking against another libc implementation.
5set_property(TARGET linker PROPERTY c_library "")
6
7zephyr_system_include_directories(include)
8
9zephyr_library()
10
11set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated)
12set(STRERROR_TABLE_H ${GEN_DIR}/libc/minimal/strerror_table.h)
13
14zephyr_library_compile_options($<TARGET_PROPERTY:compiler,no_builtin>)
15
16zephyr_library_sources(
17  source/stdlib/atoi.c
18  source/stdlib/strtol.c
19  source/stdlib/strtoul.c
20  source/stdlib/strtoll.c
21  source/stdlib/strtoull.c
22  source/stdlib/bsearch.c
23  source/stdlib/exit.c
24  source/stdlib/qsort.c
25  source/string/strerror.c
26  source/string/strncasecmp.c
27  source/string/strstr.c
28  source/string/string.c
29  source/string/strspn.c
30  source/stdout/stdout_console.c
31  source/stdout/sprintf.c
32  source/stdout/fprintf.c
33  source/math/sqrtf.c
34  source/math/sqrt.c
35  ${STRERROR_TABLE_H}
36)
37
38if(CONFIG_MINIMAL_LIBC_TIME)
39  zephyr_library_sources(source/time/gmtime.c)
40endif()
41
42zephyr_library_sources_ifdef(CONFIG_MINIMAL_LIBC_RAND source/stdlib/rand.c)
43
44add_custom_command(
45  OUTPUT ${STRERROR_TABLE_H}
46  COMMAND
47  ${PYTHON_EXECUTABLE}
48  ${ZEPHYR_BASE}/scripts/build/gen_strerror_table.py
49  -i include/errno.h
50  -o ${STRERROR_TABLE_H}
51  DEPENDS include/errno.h
52  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
53)
54