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
|
2024-08-09 17:01:41 +03:00
|
|
|
dlfcn.cpp
|
2024-09-04 21:16:04 +03:00
|
|
|
errno.cpp
|
2023-04-23 14:32:37 +03:00
|
|
|
fcntl.cpp
|
2024-11-03 20:25:35 +02:00
|
|
|
fenv.cpp
|
2024-08-09 17:01:41 +03:00
|
|
|
ftw.cpp
|
2024-01-03 00:14:49 +02:00
|
|
|
grp.cpp
|
2024-08-05 00:53:27 +03:00
|
|
|
inttypes.cpp
|
2024-12-02 02:39:03 +02:00
|
|
|
libgen.cpp
|
2024-07-30 11:33:02 +03:00
|
|
|
locale.cpp
|
2023-09-23 02:26:23 +03:00
|
|
|
malloc.cpp
|
2024-07-30 11:33:02 +03:00
|
|
|
math.cpp
|
2024-06-17 20:55:50 +03:00
|
|
|
netdb.cpp
|
2024-08-22 14:28:01 +03:00
|
|
|
poll.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
|
2024-08-07 17:03:26 +03:00
|
|
|
setjmp.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
|
2023-09-27 15:44:05 +03:00
|
|
|
sys/banan-os.cpp
|
2024-08-09 16:54:30 +03:00
|
|
|
sys/ioctl.cpp
|
2023-09-22 15:41:05 +03:00
|
|
|
sys/mman.cpp
|
2024-08-22 14:28:39 +03:00
|
|
|
sys/resource.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
|
2024-12-02 06:55:35 +02:00
|
|
|
sys/statvfs.cpp
|
2024-07-31 23:24:23 +03:00
|
|
|
sys/time.cpp
|
2024-07-31 23:54:26 +03:00
|
|
|
sys/utsname.cpp
|
2023-06-04 17:59:13 +03:00
|
|
|
sys/wait.cpp
|
2024-08-22 14:28:39 +03:00
|
|
|
syslog.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
|
2024-08-09 17:01:41 +03:00
|
|
|
utime.cpp
|
|
|
|
wchar.cpp
|
2023-06-02 17:49:21 +03:00
|
|
|
icxxabi.cpp
|
2024-03-04 11:41:54 +02:00
|
|
|
|
2024-08-07 17:03:26 +03:00
|
|
|
arch/${BANAN_ARCH}/setjmp.S
|
|
|
|
|
2024-06-18 13:14:35 +03:00
|
|
|
../../../BAN/BAN/Assert.cpp
|
2023-04-07 02:27:15 +03:00
|
|
|
)
|
|
|
|
|
2024-08-28 17:07:15 +03:00
|
|
|
add_library(objlibc OBJECT ${LIBC_SOURCES})
|
|
|
|
target_compile_definitions(objlibc PRIVATE __arch=${BANAN_ARCH})
|
2024-08-09 15:16:49 +03:00
|
|
|
|
2024-08-28 17:07:15 +03:00
|
|
|
target_compile_options(objlibc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns -fno-exceptions -fpic -nolibc)
|
|
|
|
target_compile_options(objlibc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=)
|
2023-07-31 22:31:17 +03:00
|
|
|
|
2024-06-21 17:10:58 +03:00
|
|
|
function(add_crtx crtx)
|
2024-06-22 17:30:00 +03:00
|
|
|
add_custom_target(${crtx}
|
|
|
|
COMMAND ${CMAKE_CXX_COMPILER} -c -o ${CMAKE_INSTALL_LIBDIR}/${crtx}.o ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/${crtx}.S
|
|
|
|
DEPENDS sysroot
|
|
|
|
)
|
2024-08-28 17:07:15 +03:00
|
|
|
add_dependencies(objlibc ${crtx})
|
2024-06-21 17:10:58 +03:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
add_crtx(crt0)
|
|
|
|
add_crtx(crti)
|
|
|
|
add_crtx(crtn)
|
2023-04-06 00:23:02 +03:00
|
|
|
|
2024-08-28 17:07:15 +03:00
|
|
|
banan_include_headers(objlibc ban)
|
|
|
|
banan_include_headers(objlibc kernel)
|
|
|
|
|
|
|
|
banan_install_headers(objlibc)
|
|
|
|
|
2024-09-02 21:28:02 +03:00
|
|
|
add_library(libc-static STATIC $<TARGET_OBJECTS:objlibc>)
|
2024-08-28 17:07:15 +03:00
|
|
|
add_library(libc-shared SHARED $<TARGET_OBJECTS:objlibc>)
|
|
|
|
|
2024-09-05 12:52:25 +03:00
|
|
|
target_link_options(libc-static PRIVATE -nostdlib)
|
|
|
|
target_link_options(libc-shared PRIVATE -nostdlib)
|
2024-06-19 04:20:23 +03:00
|
|
|
|
2024-09-02 21:28:02 +03:00
|
|
|
install(TARGETS libc-static OPTIONAL)
|
2024-08-28 17:07:15 +03:00
|
|
|
install(TARGETS libc-shared OPTIONAL)
|
|
|
|
|
2024-09-02 21:28:02 +03:00
|
|
|
set_target_properties(libc-static PROPERTIES OUTPUT_NAME libc)
|
2024-08-28 17:07:15 +03:00
|
|
|
set_target_properties(libc-shared PROPERTIES OUTPUT_NAME libc)
|
2024-06-19 04:20:23 +03:00
|
|
|
|
2024-09-05 12:58:35 +03:00
|
|
|
add_library(libc ALIAS libc-shared)
|
2024-09-05 12:54:22 +03:00
|
|
|
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libgcc_s.so OUTPUT_VARIABLE LIBGCC_S_LINK OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
file(REAL_PATH ${LIBGCC_S_LINK} LIBGCC_S)
|
|
|
|
install(FILES ${LIBGCC_S} DESTINATION ${CMAKE_INSTALL_LIBDIR} RENAME libgcc_s.so
|
|
|
|
PERMISSIONS
|
|
|
|
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE
|
|
|
|
WORLD_READ WORLD_EXECUTE
|
|
|
|
)
|