2023-01-22 14:00:20 +00:00
|
|
|
file(GLOB_RECURSE HEADERS include/*.h)
|
2023-01-06 12:31:14 +00:00
|
|
|
|
|
|
|
set(SOURCES
|
|
|
|
${HEADERS}
|
|
|
|
src/stdio.cpp
|
|
|
|
src/stdlib.cpp
|
|
|
|
src/unistd.cpp
|
2023-01-06 16:35:07 +00:00
|
|
|
src/errno.cpp
|
|
|
|
src/string.cpp
|
2023-04-13 19:09:27 +00:00
|
|
|
src/strftime.cpp
|
2023-03-11 16:45:20 +00:00
|
|
|
src/fcntl.cpp
|
2023-01-22 11:51:30 +00:00
|
|
|
src/assert.cpp
|
2023-01-06 18:40:25 +00:00
|
|
|
src/atexit.cpp
|
2023-01-06 19:48:08 +00:00
|
|
|
src/ctype.cpp
|
2023-01-06 23:21:08 +00:00
|
|
|
src/time.cpp
|
2023-03-18 18:23:18 +00:00
|
|
|
src/init.cpp
|
2023-03-28 23:06:57 +00:00
|
|
|
src/dirent.cpp
|
2023-03-28 17:40:48 +00:00
|
|
|
src/setjmp.cpp
|
2023-04-07 13:03:38 +00:00
|
|
|
src/env.cpp
|
2023-04-08 14:30:18 +00:00
|
|
|
src/pwd.cpp
|
2023-05-06 10:11:35 +00:00
|
|
|
src/grp.cpp
|
2023-03-12 14:32:09 +00:00
|
|
|
src/sys/stat.cpp
|
2023-01-13 18:08:02 +00:00
|
|
|
src/sys/mman.cpp
|
2023-03-23 21:42:24 +00:00
|
|
|
src/sys/wait.cpp
|
2023-04-09 09:24:13 +00:00
|
|
|
src/sys/ioctl.cpp
|
2023-04-24 19:02:04 +00:00
|
|
|
src/sys/utsname.cpp
|
2023-05-17 18:30:15 +00:00
|
|
|
src/sys/mount.cpp
|
2023-05-18 19:48:47 +00:00
|
|
|
src/sys/pstat.cpp
|
2023-05-20 10:48:17 +00:00
|
|
|
src/sys/resource.cpp
|
2023-01-06 12:31:14 +00:00
|
|
|
)
|
|
|
|
|
2023-01-21 21:44:16 +00:00
|
|
|
if(${LUNA_ARCH} STREQUAL "x86_64")
|
2023-01-06 12:31:14 +00:00
|
|
|
set(SOURCES
|
|
|
|
${SOURCES}
|
|
|
|
src/arch/x86_64/syscall.S
|
2023-03-28 17:40:48 +00:00
|
|
|
src/arch/x86_64/setjmp.S
|
2023-01-06 12:31:14 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2023-01-21 21:44:16 +00:00
|
|
|
add_library(crt0 STATIC src/arch/${LUNA_ARCH}/crt0.S)
|
2023-01-06 12:31:14 +00:00
|
|
|
add_custom_command(
|
|
|
|
TARGET crt0
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_OBJECTS:crt0> ${LUNA_BASE}/usr/lib/crt0.o
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(bare_libc STATIC ${SOURCES})
|
|
|
|
|
|
|
|
target_link_libraries(bare_libc PUBLIC luna)
|
|
|
|
|
|
|
|
target_include_directories(bare_libc PUBLIC include/)
|
|
|
|
|
2023-04-07 10:02:49 +00:00
|
|
|
target_compile_options(bare_libc PRIVATE ${COMMON_FLAGS})
|
|
|
|
|
2023-01-06 12:31:14 +00:00
|
|
|
target_link_options(bare_libc PRIVATE -nostdlib)
|
|
|
|
|
|
|
|
set_target_properties(bare_libc PROPERTIES CXX_STANDARD 20)
|
|
|
|
|
|
|
|
add_custom_target(libc
|
|
|
|
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:bare_libc>
|
|
|
|
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:luna>
|
|
|
|
COMMAND ${CMAKE_AR} -rcs ${CMAKE_CURRENT_BINARY_DIR}/libc.a *.o
|
2023-04-12 16:11:36 +00:00
|
|
|
COMMAND /usr/bin/rm *.o
|
2023-01-06 12:31:14 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2023-01-06 16:59:54 +00:00
|
|
|
DEPENDS bare_libc luna crt0
|
2023-01-06 12:31:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
TARGET libc
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy ${CMAKE_CURRENT_BINARY_DIR}/libc.a ${LUNA_BASE}/usr/lib/libc.a
|
|
|
|
)
|
|
|
|
|
|
|
|
file(WRITE "${LUNA_BASE}/usr/lib/libm.a" "INPUT(libc.a)")
|
2023-03-29 15:56:56 +00:00
|
|
|
file(WRITE "${LUNA_BASE}/usr/lib/libstdc++.a" "INPUT(libc.a)")
|