From 0220b5361eadf50b536c7e1ed46a4393817d4ad7 Mon Sep 17 00:00:00 2001 From: Itamar Date: Fri, 20 Nov 2020 14:18:53 +0200 Subject: LibC: Also build a static version of libc --- CMakeLists.txt | 10 ++++++++++ Libraries/LibC/CMakeLists.txt | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aa600954c..6ea5d54de3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,16 @@ function(serenity_libc target_name fs_name) serenity_generated_sources(${target_name}) endfunction() +function(serenity_libc_static target_name fs_name) + serenity_install_headers("") + serenity_install_sources("Libraries/LibC") + add_library(${target_name} ${SOURCES}) + install(TARGETS ${target_name} ARCHIVE DESTINATION usr/lib) + set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name}) + target_link_directories(${target_name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) + serenity_generated_sources(${target_name}) +endfunction() + function(serenity_bin target_name) add_executable(${target_name} ${SOURCES}) target_sources(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/Libraries/LibC/crt0_shared.cpp) diff --git a/Libraries/LibC/CMakeLists.txt b/Libraries/LibC/CMakeLists.txt index 0078b058e3..b8bc5ec760 100644 --- a/Libraries/LibC/CMakeLists.txt +++ b/Libraries/LibC/CMakeLists.txt @@ -66,6 +66,11 @@ add_custom_command( ) set(SOURCES ${LIBC_SOURCES} ${AK_SOURCES} ${ELF_SOURCES}) + +serenity_libc_static(LibCStatic c) +target_link_libraries(LibCStatic crt0) +add_dependencies(LibCStatic LibM) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") serenity_libc(LibC c) target_link_libraries(LibC crt0) -- cgit v1.2.3