Luna/libc/CMakeLists.txt
apio 95a33c484e
kernel+libc: Add a memstat() syscall
We can finally show memory usage in userspace.

This could have been done using sysfs, but I'm lazy and don't want to implement that. Maybe in the next release?
2023-08-17 20:15:32 +02:00

85 lines
2.0 KiB
CMake

file(GLOB_RECURSE HEADERS include/*.h)
set(SOURCES
${HEADERS}
src/stdio.cpp
src/stdlib.cpp
src/unistd.cpp
src/errno.cpp
src/string.cpp
src/strftime.cpp
src/fcntl.cpp
src/assert.cpp
src/atexit.cpp
src/ctype.cpp
src/time.cpp
src/init.cpp
src/dirent.cpp
src/setjmp.cpp
src/env.cpp
src/pwd.cpp
src/grp.cpp
src/locale.cpp
src/scanf.cpp
src/signal.cpp
src/termios.cpp
src/utime.cpp
src/strtod.cpp
src/math.cpp
src/sys/stat.cpp
src/sys/mman.cpp
src/sys/wait.cpp
src/sys/ioctl.cpp
src/sys/utsname.cpp
src/sys/mount.cpp
src/sys/pstat.cpp
src/sys/memstat.cpp
src/sys/resource.cpp
src/sys/socket.cpp
src/sys/poll.cpp
)
if(${LUNA_ARCH} STREQUAL "x86_64")
set(SOURCES
${SOURCES}
src/arch/x86_64/syscall.S
src/arch/x86_64/setjmp.S
src/arch/x86_64/sigreturn.S
)
endif()
add_library(crt0 STATIC src/arch/${LUNA_ARCH}/crt0.S)
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/)
target_compile_options(bare_libc PRIVATE ${COMMON_FLAGS})
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
COMMAND /usr/bin/rm *.o
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS bare_libc luna crt0
)
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)")
file(WRITE "${LUNA_BASE}/usr/lib/libstdc++.a" "INPUT(libc.a)")