2021-07-18 12:47:32 +00:00
|
|
|
set(SOURCES
|
2021-09-07 01:01:13 +00:00
|
|
|
UBSanitizer.cpp
|
2021-09-07 00:49:38 +00:00
|
|
|
../MiniStdLib.cpp
|
2021-07-18 12:47:32 +00:00
|
|
|
)
|
2021-08-28 17:41:14 +00:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
set(SOURCES
|
|
|
|
${SOURCES}
|
2021-09-25 21:53:42 +00:00
|
|
|
Arch/aarch64/GPIO.cpp
|
2021-09-19 01:41:39 +00:00
|
|
|
Arch/aarch64/Mailbox.cpp
|
2021-09-12 13:42:27 +00:00
|
|
|
Arch/aarch64/MainIdRegister.cpp
|
2021-09-17 15:00:46 +00:00
|
|
|
Arch/aarch64/MMIO.cpp
|
2021-10-02 19:50:23 +00:00
|
|
|
Arch/aarch64/Timer.cpp
|
2021-09-26 18:10:10 +00:00
|
|
|
Arch/aarch64/UART.cpp
|
2021-09-27 01:33:21 +00:00
|
|
|
Arch/aarch64/boot.S
|
2021-09-06 17:11:16 +00:00
|
|
|
Arch/aarch64/init.cpp
|
2021-08-28 17:41:14 +00:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(SOURCES
|
|
|
|
${SOURCES}
|
|
|
|
Arch/x86/boot.S
|
|
|
|
Arch/x86/multiboot.S
|
|
|
|
# FIXME: Eventually, some of these should build on aarch64 too.
|
|
|
|
init.cpp
|
|
|
|
../../Userland/Libraries/LibELF/Relocation.cpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-07-18 12:47:32 +00:00
|
|
|
|
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "i686")
|
|
|
|
set(PREKERNEL_TARGET Prekernel32)
|
2021-08-28 17:41:14 +00:00
|
|
|
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
2021-07-18 12:47:32 +00:00
|
|
|
set(PREKERNEL_TARGET Prekernel64)
|
2021-08-28 17:41:14 +00:00
|
|
|
else()
|
|
|
|
set(PREKERNEL_TARGET Prekernel)
|
2021-07-18 12:47:32 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-26 13:10:51 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
|
|
|
|
|
2021-07-18 12:47:32 +00:00
|
|
|
add_executable(${PREKERNEL_TARGET} ${SOURCES})
|
2021-09-12 13:09:36 +00:00
|
|
|
target_compile_options(${PREKERNEL_TARGET} PRIVATE -no-pie -fno-pic -fno-threadsafe-statics)
|
2021-07-18 12:47:32 +00:00
|
|
|
|
2021-09-27 00:16:46 +00:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
set(PREKERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Arch/aarch64/linker.ld")
|
|
|
|
else()
|
|
|
|
set(PREKERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/linker.ld")
|
|
|
|
endif()
|
|
|
|
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${PREKERNEL_LINKER_SCRIPT} -nostdlib LINKER:--no-pie)
|
|
|
|
set_target_properties(${PREKERNEL_TARGET} PROPERTIES LINK_DEPENDS ${PREKERNEL_LINKER_SCRIPT})
|
2021-07-18 12:47:32 +00:00
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2021-09-17 14:01:46 +00:00
|
|
|
target_link_libraries(${PREKERNEL_TARGET} PRIVATE gcc)
|
2021-09-07 08:21:36 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
2021-09-17 14:01:46 +00:00
|
|
|
target_link_libraries(${PREKERNEL_TARGET} PRIVATE "clang_rt.builtins-${SERENITY_CLANG_ARCH}" c++abi)
|
2021-07-13 14:43:45 +00:00
|
|
|
endif()
|
2021-07-18 12:47:32 +00:00
|
|
|
|
2021-08-28 17:41:14 +00:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
|
|
|
|
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
|
|
|
|
)
|
|
|
|
endif()
|
2021-07-18 12:47:32 +00:00
|
|
|
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Prekernel" DESTINATION boot)
|
2021-08-25 03:28:51 +00:00
|
|
|
|
|
|
|
# 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}")
|