darling/cmake/wrap_elf.cmake
Ariel Abreu bd13d4edf8
Bring back mldr and start work on darlingserver
The goal of this new branch is to implement Darling entirely in userspace, no LKM necessary.

This first commit re-introduces mldr (a userspace Mach-O loader last used about 4 years ago in 89d6e6ddb1) together with some updates from the Mach-O loading code in the LKM.

This commit also sets up the basis for darlingserver: RPC and process/thread tracking.
2021-12-16 12:00:38 -05:00

31 lines
836 B
CMake

include(darling_lib)
#include(CMakeParseArguments)
function(wrap_elf name elfname)
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/${name}.c
COMMAND
${CMAKE_BINARY_DIR}/src/libelfloader/wrapgen/wrapgen
${elfname}
${CMAKE_CURRENT_BINARY_DIR}/${name}.c
${CMAKE_CURRENT_BINARY_DIR}/${name}_vars.h
DEPENDS
wrapgen
)
if (ARGC LESS 3)
set(destination "/usr/lib/native")
else (ARGC LESS 3)
set(destination ${ARGV2})
endif (ARGC LESS 3)
set(DYLIB_INSTALL_NAME "${destination}/lib${name}.dylib")
include_directories(${CMAKE_SOURCE_DIR}/src/startup/mldr/elfcalls)
add_darling_library(${name} SHARED ${CMAKE_CURRENT_BINARY_DIR}/${name}.c)
target_link_libraries(${name} PRIVATE system)
make_fat(${name})
install(TARGETS ${name} DESTINATION libexec/darling/${destination})
endfunction(wrap_elf)