2023-04-02 04:07:27 +03:00
|
|
|
cmake_minimum_required(VERSION 3.26)
|
|
|
|
|
2023-05-10 22:35:20 +03:00
|
|
|
project(libc CXX ASM)
|
2023-04-02 04:07:27 +03:00
|
|
|
|
2023-04-07 02:27:15 +03:00
|
|
|
set(LIBC_SOURCES
|
2024-02-05 17:33:02 +02:00
|
|
|
arpa/inet.cpp
|
2023-05-26 22:21:07 +03:00
|
|
|
assert.cpp
|
2023-04-07 02:27:15 +03:00
|
|
|
ctype.cpp
|
2023-06-11 00:19:20 +03:00
|
|
|
dirent.cpp
|
2023-04-23 14:32:37 +03:00
|
|
|
fcntl.cpp
|
2024-01-03 00:14:49 +02:00
|
|
|
grp.cpp
|
2023-09-23 02:26:23 +03:00
|
|
|
malloc.cpp
|
2023-05-10 02:00:28 +03:00
|
|
|
printf_impl.cpp
|
2023-07-13 11:22:09 +03:00
|
|
|
pwd.cpp
|
2024-01-22 17:01:37 +02:00
|
|
|
scanf_impl.cpp
|
2023-07-21 15:45:02 +03:00
|
|
|
signal.cpp
|
2023-04-07 02:27:15 +03:00
|
|
|
stdio.cpp
|
|
|
|
stdlib.cpp
|
|
|
|
string.cpp
|
2023-12-14 10:59:39 +02:00
|
|
|
strings.cpp
|
2024-02-03 01:24:55 +02:00
|
|
|
stropts.cpp
|
2023-09-27 15:44:05 +03:00
|
|
|
sys/banan-os.cpp
|
2023-09-22 15:41:05 +03:00
|
|
|
sys/mman.cpp
|
2024-02-12 17:26:33 +02:00
|
|
|
sys/select.cpp
|
2024-02-01 23:39:09 +02:00
|
|
|
sys/socket.cpp
|
2023-06-05 14:36:17 +03:00
|
|
|
sys/stat.cpp
|
2023-06-04 17:59:13 +03:00
|
|
|
sys/wait.cpp
|
2023-05-16 19:22:10 +03:00
|
|
|
termios.cpp
|
2023-07-06 00:38:29 +03:00
|
|
|
time.cpp
|
2023-04-07 02:27:15 +03:00
|
|
|
unistd.cpp
|
2023-05-10 22:35:20 +03:00
|
|
|
math.S
|
2023-06-02 17:49:21 +03:00
|
|
|
icxxabi.cpp
|
2024-03-04 11:41:54 +02:00
|
|
|
|
|
|
|
../BAN/BAN/Assert.cpp
|
2023-04-07 02:27:15 +03:00
|
|
|
)
|
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
add_custom_target(libc-headers
|
2023-11-04 17:50:43 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/
|
2023-04-02 04:07:27 +03:00
|
|
|
DEPENDS sysroot
|
|
|
|
)
|
2023-04-06 00:23:02 +03:00
|
|
|
|
2023-10-30 11:06:13 +02:00
|
|
|
add_custom_target(crtx
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crt0.S -o crt0.o
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crti.S -o crti.o
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crtn.S -o crtn.o
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(crtx-install
|
2023-11-04 17:50:43 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy crt0.o ${BANAN_LIB}/
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy crti.o ${BANAN_LIB}/
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy crtn.o ${BANAN_LIB}/
|
2023-10-30 11:06:13 +02:00
|
|
|
DEPENDS crtx
|
|
|
|
)
|
|
|
|
|
2023-04-07 02:27:15 +03:00
|
|
|
add_library(libc ${LIBC_SOURCES})
|
2023-10-30 11:06:13 +02:00
|
|
|
add_dependencies(libc headers crtx-install)
|
2023-04-07 02:27:15 +03:00
|
|
|
|
2024-01-17 20:44:29 +02:00
|
|
|
target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns)
|
2023-12-10 19:20:14 +02:00
|
|
|
target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=)
|
2023-07-31 22:31:17 +03:00
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
add_custom_target(libc-install
|
2023-11-04 17:50:43 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libc.a ${BANAN_LIB}/
|
2023-04-07 02:27:15 +03:00
|
|
|
DEPENDS libc
|
2023-05-31 22:40:15 +03:00
|
|
|
BYPRODUCTS ${BANAN_LIB}/libc.a
|
2023-04-06 00:23:02 +03:00
|
|
|
)
|
|
|
|
|
2023-04-07 02:27:15 +03:00
|
|
|
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|