ladybird/Kernel/Prekernel/CMakeLists.txt
Jakub V. Flasar 6d2c298b66 Kernel: Move aarch64 Prekernel into Kernel
As there is no need for a Prekernel on aarch64, the Prekernel code was
moved into Kernel itself. The functionality remains the same.

SERENITY_KERNEL_AND_INITRD in run.sh specifies a kernel and an inital
ramdisk to be used by the emulator. This is needed because aarch64
does not need a Prekernel and the other ones do.
2022-03-12 14:54:12 -08:00

46 lines
1.8 KiB
CMake

set(SOURCES
UBSanitizer.cpp
../MiniStdLib.cpp
boot.S
multiboot.S
init.cpp
../../Userland/Libraries/LibELF/Relocation.cpp
)
if ("${SERENITY_ARCH}" STREQUAL "i686")
set(PREKERNEL_TARGET Prekernel32)
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
set(PREKERNEL_TARGET Prekernel64)
elseif("${SERENITY_ARCH}" STREQUAL "aarch64")
message(SEND_ERROR "Prekernel is not needed on aarch64 and should not be compiled!")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
add_executable(${PREKERNEL_TARGET} ${SOURCES})
target_compile_options(${PREKERNEL_TARGET} PRIVATE -no-pie -fno-pic -fno-threadsafe-statics)
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld -nostdlib LINKER:--no-pie)
set_target_properties(${PREKERNEL_TARGET} PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(${PREKERNEL_TARGET} PRIVATE gcc)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
target_link_libraries(${PREKERNEL_TARGET} PRIVATE clang_rt.builtins)
endif()
add_custom_command(
TARGET ${PREKERNEL_TARGET} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Prekernel" DESTINATION boot)
# Remove options which the Prekernel environment doesn't support.
get_target_property(PREKERNEL_TARGET_OPTIONS ${PREKERNEL_TARGET} COMPILE_OPTIONS)
list(REMOVE_ITEM PREKERNEL_TARGET_OPTIONS "-fsanitize-coverage=trace-pc")
list(REMOVE_ITEM PREKERNEL_TARGET_OPTIONS "-fsanitize=kernel-address")
set_target_properties(${PREKERNEL_TARGET} PROPERTIES COMPILE_OPTIONS "${PREKERNEL_TARGET_OPTIONS}")