2023-04-02 04:07:27 +03:00
|
|
|
cmake_minimum_required(VERSION 3.26)
|
|
|
|
|
2023-04-02 04:48:56 +03:00
|
|
|
if(DEFINED ENV{BANAN_ARCH})
|
|
|
|
set(BANAN_ARCH $ENV{BANAN_ARCH})
|
2023-04-06 12:36:18 +03:00
|
|
|
else()
|
|
|
|
set(BANAN_ARCH x86_64)
|
2023-04-02 04:48:56 +03:00
|
|
|
endif()
|
|
|
|
|
2023-04-06 12:36:18 +03:00
|
|
|
set(TOOLCHAIN_PREFIX ${CMAKE_SOURCE_DIR}/toolchain/local)
|
|
|
|
|
2023-10-05 18:52:05 +03:00
|
|
|
if(EXISTS ${TOOLCHAIN_PREFIX}/bin/${BANAN_ARCH}-banan_os-g++)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}/bin/${BANAN_ARCH}-banan_os-g++)
|
|
|
|
set(CMAKE_CXX_COMPILER_WORKS True)
|
|
|
|
|
|
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}/bin/${BANAN_ARCH}-banan_os-gcc)
|
|
|
|
set(CMAKE_C_COMPILER_WORKS True)
|
2023-04-02 04:48:56 +03:00
|
|
|
endif()
|
|
|
|
|
2023-09-27 13:49:01 +03:00
|
|
|
if(DEFINED QEMU_ACCEL)
|
|
|
|
set(QEMU_ACCEL -accel ${QEMU_ACCEL})
|
|
|
|
endif()
|
|
|
|
|
2023-10-16 01:37:57 +03:00
|
|
|
if(DEFINED UEFI_BOOT)
|
|
|
|
set(UEFI_BOOT 1)
|
|
|
|
endif()
|
|
|
|
|
2023-09-23 02:28:25 +03:00
|
|
|
add_compile_options(-mno-sse -mno-sse2)
|
|
|
|
add_compile_definitions(__enable_sse=0)
|
|
|
|
|
2023-04-02 04:48:56 +03:00
|
|
|
project(banan-os CXX)
|
|
|
|
|
2023-08-23 10:35:16 +03:00
|
|
|
set(BANAN_BASE_SYSROOT ${CMAKE_SOURCE_DIR}/base-sysroot.tar.gz)
|
2023-04-02 04:07:27 +03:00
|
|
|
set(BANAN_SYSROOT ${CMAKE_BINARY_DIR}/sysroot)
|
|
|
|
set(BANAN_INCLUDE ${BANAN_SYSROOT}/usr/include)
|
2023-04-07 02:27:15 +03:00
|
|
|
set(BANAN_LIB ${BANAN_SYSROOT}/usr/lib)
|
2023-05-11 16:19:53 +03:00
|
|
|
set(BANAN_BIN ${BANAN_SYSROOT}/usr/bin)
|
2023-04-02 04:07:27 +03:00
|
|
|
set(BANAN_BOOT ${BANAN_SYSROOT}/boot)
|
|
|
|
set(DISK_IMAGE_PATH ${CMAKE_BINARY_DIR}/banan-os.img)
|
|
|
|
|
|
|
|
add_subdirectory(kernel)
|
|
|
|
add_subdirectory(BAN)
|
|
|
|
add_subdirectory(libc)
|
2023-04-12 22:20:18 +03:00
|
|
|
add_subdirectory(LibELF)
|
2023-05-11 16:19:53 +03:00
|
|
|
add_subdirectory(userspace)
|
2023-04-02 04:07:27 +03:00
|
|
|
|
|
|
|
add_custom_target(sysroot
|
|
|
|
COMMAND mkdir -p ${BANAN_SYSROOT}
|
2023-08-23 10:35:16 +03:00
|
|
|
COMMAND cd ${BANAN_SYSROOT} && sudo tar xf ${BANAN_BASE_SYSROOT}
|
2023-08-23 20:48:40 +03:00
|
|
|
USES_TERMINAL
|
2023-04-02 04:07:27 +03:00
|
|
|
)
|
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
add_custom_target(headers
|
|
|
|
DEPENDS kernel-headers
|
|
|
|
DEPENDS ban-headers
|
|
|
|
DEPENDS libc-headers
|
2023-04-12 22:20:18 +03:00
|
|
|
DEPENDS libelf-headers
|
2023-04-06 00:23:02 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(toolchain
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" PREFIX="${TOOLCHAIN_PREFIX}" ARCH="${BANAN_ARCH}" ${CMAKE_SOURCE_DIR}/toolchain/build.sh
|
|
|
|
DEPENDS headers
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2023-06-02 18:39:42 +03:00
|
|
|
add_custom_target(libstdc++
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env LIBSTDCPP="1" ${CMAKE_SOURCE_DIR}/toolchain/build.sh
|
|
|
|
DEPENDS libc-install
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2023-04-02 04:07:27 +03:00
|
|
|
add_custom_target(image
|
2023-10-16 01:37:57 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" TOOLCHAIN="${TOOLCHAIN_PREFIX}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/image.sh
|
2023-04-02 04:07:27 +03:00
|
|
|
DEPENDS kernel-install
|
|
|
|
DEPENDS ban-install
|
|
|
|
DEPENDS libc-install
|
2023-05-11 16:19:53 +03:00
|
|
|
DEPENDS userspace-install
|
2023-08-23 10:35:16 +03:00
|
|
|
DEPENDS libelf-install
|
2023-04-02 04:07:27 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(image-full
|
2023-10-16 01:37:57 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" TOOLCHAIN="${TOOLCHAIN_PREFIX}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/image-full.sh
|
2023-04-02 04:07:27 +03:00
|
|
|
DEPENDS kernel-install
|
|
|
|
DEPENDS ban-install
|
|
|
|
DEPENDS libc-install
|
2023-05-11 16:19:53 +03:00
|
|
|
DEPENDS userspace-install
|
2023-08-23 10:35:16 +03:00
|
|
|
DEPENDS libelf-install
|
2023-04-02 04:07:27 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2023-08-31 21:37:30 +03:00
|
|
|
add_custom_target(check-fs
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/check-fs.sh
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2023-04-02 04:07:27 +03:00
|
|
|
add_custom_target(qemu
|
2023-10-16 01:37:57 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio ${QEMU_ACCEL}
|
2023-09-27 13:49:01 +03:00
|
|
|
DEPENDS image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(qemu-nographic
|
2023-10-16 01:37:57 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/qemu.sh -nographic ${QEMU_ACCEL}
|
2023-09-20 21:07:21 +03:00
|
|
|
DEPENDS image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(qemu-debug
|
2023-10-16 01:37:57 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio -d int -no-reboot
|
2023-04-02 04:07:27 +03:00
|
|
|
DEPENDS image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(bochs
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/bochs.sh
|
|
|
|
DEPENDS image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|