When using multiboot2, GRUB may set a graphical framebuffer instead of text mode, causing VGA text writes to 0xB8000 to be invisible. - Add MULTIBOOT_HEADER_TAG_FRAMEBUFFER to multiboot2 header requesting 80x25 text mode (depth=0) - Add 'set gfxpayload=text' to grub.cfg as additional safeguard This fixes blank display when running under UTM/QEMU with certain VGA device configurations.
59 lines
2.3 KiB
CMake
59 lines
2.3 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(ClaudeOS C ASM)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
# We are building a kernel, so we don't want standard libraries
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffreestanding -m32 -fno-pie -fno-pic -fno-builtin -fno-stack-protector -mno-sse -mno-mmx -g -O2 -Wall -Wextra")
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -m32 -fno-pie -fno-pic")
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32 -nostdlib -no-pie")
|
|
|
|
# Define build output directory
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
add_subdirectory(src)
|
|
|
|
# Create output directories
|
|
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/release)
|
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/isodir/boot/grub)
|
|
|
|
# Build user-mode applications as flat binaries.
|
|
set(APPS_BIN_DIR ${CMAKE_BINARY_DIR}/apps_bin)
|
|
file(MAKE_DIRECTORY ${APPS_BIN_DIR})
|
|
add_custom_target(apps
|
|
COMMAND ${CMAKE_SOURCE_DIR}/scripts/build_apps.sh ${CMAKE_SOURCE_DIR}/apps ${APPS_BIN_DIR}
|
|
COMMENT "Building user-mode applications"
|
|
)
|
|
|
|
# Generate CPIO initial ramdisk from built app binaries.
|
|
set(INITRD_FILE ${CMAKE_BINARY_DIR}/isodir/boot/initrd.cpio)
|
|
add_custom_command(
|
|
OUTPUT ${INITRD_FILE}
|
|
COMMAND ${CMAKE_SOURCE_DIR}/scripts/gen_initrd.sh ${APPS_BIN_DIR} ${INITRD_FILE}
|
|
DEPENDS apps
|
|
COMMENT "Generating CPIO initial ramdisk"
|
|
)
|
|
add_custom_target(initrd DEPENDS ${INITRD_FILE})
|
|
|
|
# Create grub.cfg for ISO - includes module2 for the initrd
|
|
file(WRITE ${CMAKE_BINARY_DIR}/isodir/boot/grub/grub.cfg "set timeout=0\nset default=0\nsearch --set=root --file /boot/kernel.bin\nmenuentry \"ClaudeOS\" {\n set gfxpayload=text\n multiboot2 /boot/kernel.bin\n module2 /boot/initrd.cpio\n}")
|
|
|
|
|
|
# ISO Generation
|
|
add_custom_target(iso ALL
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/kernel ${CMAKE_BINARY_DIR}/isodir/boot/kernel.bin
|
|
COMMAND grub-mkrescue -o ${CMAKE_SOURCE_DIR}/release/claude-os.iso ${CMAKE_BINARY_DIR}/isodir
|
|
DEPENDS kernel initrd
|
|
COMMENT "Generating bootable ISO image"
|
|
)
|
|
|
|
# Test target
|
|
add_custom_target(test_images
|
|
COMMAND sh ${CMAKE_SOURCE_DIR}/test_images.sh
|
|
DEPENDS iso
|
|
COMMENT "Testing generated images in QEMU"
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|