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-04-02 04:48:56 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
2023-04-06 12:36:18 +03:00
|
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}/bin/${BANAN_ARCH}-banan_os-g++)
|
2023-04-02 04:48:56 +03:00
|
|
|
set(CMAKE_CXX_COMPILER_WORKS True)
|
|
|
|
|
2023-09-18 21:48:37 +03:00
|
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}/bin/${BANAN_ARCH}-banan_os-gcc)
|
|
|
|
set(CMAKE_C_COMPILER_WORKS True)
|
|
|
|
|
2023-04-06 12:36:18 +03:00
|
|
|
if(NOT EXISTS ${CMAKE_CXX_COMPILER})
|
|
|
|
set(CMAKE_CXX_COMPILER g++)
|
2023-04-02 04:48:56 +03:00
|
|
|
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
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/image.sh
|
|
|
|
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
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/image-full.sh
|
|
|
|
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-09-20 21:07:21 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/qemu.sh -accel kvm
|
|
|
|
DEPENDS image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(qemu-debug
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/qemu.sh -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
|
|
|
|
)
|