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
|
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
|
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
|
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-09-27 15:44:05 +03:00
|
|
|
sys/banan-os.cpp
|
2023-09-22 15:41:05 +03:00
|
|
|
sys/mman.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
|
2023-04-07 02:27:15 +03:00
|
|
|
)
|
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
add_custom_target(libc-headers
|
2023-08-28 11:38:17 +03:00
|
|
|
COMMAND sudo rsync -a ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/
|
2023-04-02 04:07:27 +03:00
|
|
|
DEPENDS sysroot
|
2023-08-23 10:35:16 +03:00
|
|
|
USES_TERMINAL
|
2023-04-02 04:07:27 +03:00
|
|
|
)
|
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
|
|
|
|
COMMAND sudo cp crt0.o ${BANAN_LIB}/
|
|
|
|
COMMAND sudo cp crti.o ${BANAN_LIB}/
|
|
|
|
COMMAND sudo cp crtn.o ${BANAN_LIB}/
|
|
|
|
DEPENDS crtx
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
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
|
|
|
|
2023-08-17 20:49:52 +03:00
|
|
|
target_compile_options(libc PRIVATE -g -Wstack-usage=512)
|
2023-07-31 22:31:17 +03:00
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
add_custom_target(libc-install
|
2023-08-23 10:35:16 +03:00
|
|
|
COMMAND sudo cp ${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-08-23 10:35:16 +03:00
|
|
|
USES_TERMINAL
|
2023-04-06 00:23:02 +03:00
|
|
|
)
|
|
|
|
|
2023-04-07 02:27:15 +03:00
|
|
|
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|