diff --git a/userspace/CMakeLists.txt b/userspace/CMakeLists.txt index 56654dc3bc..00881bddd7 100644 --- a/userspace/CMakeLists.txt +++ b/userspace/CMakeLists.txt @@ -53,7 +53,6 @@ add_custom_target(userspace) foreach(project ${USERSPACE_PROJECTS}) add_subdirectory(${project}) - add_dependencies(${project} crtx-install) add_dependencies(userspace ${project}) # This is to allow cmake to link when libc updates target_link_options(${project} PRIVATE -nolibc) diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index 163c394f77..00cbcdbc35 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -35,15 +35,15 @@ add_library(libc ${LIBC_SOURCES}) target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns -nostdlib) target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=) -add_library(crt0 OBJECT arch/${BANAN_ARCH}/crt0.S) -add_library(crti OBJECT arch/${BANAN_ARCH}/crti.S) -add_library(crtn OBJECT arch/${BANAN_ARCH}/crtn.S) -add_custom_target(crtx-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crt0.o - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crti.o - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crtn.o - DEPENDS crt0 crti crtn sysroot -) +function(add_crtx crtx) + add_custom_target(${crtx} COMMAND ${CMAKE_CXX_COMPILER} -c -o ${crtx}.o ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/${crtx}.S) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${crtx}.o DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL) + add_dependencies(libc ${crtx}) +endfunction() + +add_crtx(crt0) +add_crtx(crti) +add_crtx(crtn) banan_include_headers(libc ban) banan_include_headers(libc kernel)