diff --git a/CMakeLists.txt b/CMakeLists.txt index e08a3e79674..1cac1a5144c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,6 +167,7 @@ else() set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib) set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}strip) set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar) + set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy) endif() foreach(lang ASM C CXX OBJC OBJCXX) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index d432da99806..8b2ace00274 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -413,9 +413,9 @@ add_dependencies(${KERNEL_TARGET} kernel_heap) add_custom_command( TARGET ${KERNEL_TARGET} POST_BUILD - COMMAND ${TOOLCHAIN_PREFIX}objcopy -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${KERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Kernel + COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${KERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Kernel COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/mkmap.sh - COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/embedmap.sh + COMMAND ${CMAKE_COMMAND} -E env OBJCOPY=${CMAKE_OBJCOPY} sh ${CMAKE_CURRENT_SOURCE_DIR}/embedmap.sh BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Kernel ${CMAKE_CURRENT_BINARY_DIR}/kernel.map ) diff --git a/Kernel/embedmap.sh b/Kernel/embedmap.sh index 2f341fd97d6..58e33e8a1fa 100644 --- a/Kernel/embedmap.sh +++ b/Kernel/embedmap.sh @@ -1,5 +1,6 @@ #!/bin/sh tmp=$(mktemp) (cat kernel.map; printf '%b' '\0') > "$tmp" -objcopy --update-section .ksyms="$tmp" Kernel +OBJCOPY="${OBJCOPY:-objcopy}" +"$OBJCOPY" --update-section .ksyms="$tmp" Kernel rm -f "$tmp"