| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- # ═══════════════════════════════════════════════════════════════════
- # ArkOS Build System — Top-Level Makefile
- # ═══════════════════════════════════════════════════════════════════
- #
- # Targets:
- # make build — Full incremental build (cached Swift/SPM)
- # make run — Launch ArkOS in QEMU (BIOS mode)
- # make run-uefi — Launch ArkOS in QEMU (UEFI mode)
- # make clean — Remove all build artifacts and caches
- #
- # ═══════════════════════════════════════════════════════════════════
- # Project root is one level above this Makefile (arkos/Makefile)
- ROOT := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/..)
- TOOLS := $(ROOT)/tools
- ARKOS := $(ROOT)/arkos
- CLANG := $(ARKOS)/prebuilts/clang/bin/clang
- .PHONY: build run run-uefi clean
- # ── Build ──────────────────────────────────────────────────────────
- # Compiles tools/build orchestrator, then runs the full pipeline.
- build:
- @$(MAKE) --no-print-directory -C $(TOOLS)
- @$(TOOLS)/build $(ARKOS)
- # ── Run (BIOS) ─────────────────────────────────────────────────────
- # Launches ArkOS in QEMU with:
- # - 2 GB RAM, 2 CPU cores
- # - VirtIO GPU for hardware-accelerated display
- # - VirtIO NIC with user-mode networking (TCP/IP stack via QEMU)
- # - Three disk images: boot, system, vendor
- # - KVM acceleration (falls back to software emulation)
- run:
- @echo "Starting ArkOS in QEMU (BIOS mode)..."
- @qemu-system-x86_64 \
- -m 2048 \
- -smp 2 \
- -drive file=finished/boot.img,format=raw,index=0,media=disk,if=virtio \
- -drive file=finished/sys.img,format=raw,index=1,media=disk,if=virtio \
- -drive file=finished/vend.img,format=raw,index=2,media=disk,if=virtio \
- -vga virtio -debugcon file:ovmf.log -global isa-debugcon.iobase=0x402 \
- -netdev user,id=net0 \
- -device virtio-net-pci,netdev=net0 \
- -enable-kvm 2>/dev/null || \
- qemu-system-x86_64 \
- -m 2048 \
- -smp 2 \
- -drive file=finished/boot.img,format=raw,index=0,media=disk,if=virtio \
- -drive file=finished/sys.img,format=raw,index=1,media=disk,if=virtio \
- -drive file=finished/vend.img,format=raw,index=2,media=disk,if=virtio \
- -vga virtio -debugcon file:ovmf.log -global isa-debugcon.iobase=0x402 \
- -netdev user,id=net0 \
- -device virtio-net-pci,netdev=net0 \
- -serial stdio
- # ── Run (UEFI) ────────────────────────────────────────────────────
- run-uefi:
- @echo "Starting ArkOS in QEMU (UEFI mode)..."
- @qemu-system-x86_64 \
- -bios /usr/share/edk2/x64/OVMF.4m.fd \
- -m 2048 \
- -smp 2 \
- -drive file=finished/boot.img,format=raw,index=0,media=disk,if=virtio \
- -drive file=finished/sys.img,format=raw,index=1,media=disk,if=virtio \
- -drive file=finished/vend.img,format=raw,index=2,media=disk,if=virtio \
- -device virtio-vga,xres=1080,yres=1900 -debugcon file:ovmf.log -global isa-debugcon.iobase=0x402 \
- -netdev user,id=net0 \
- -device virtio-net-pci,netdev=net0 \
- -enable-kvm 2>/dev/null || \
- qemu-system-x86_64 \
- -bios /usr/share/edk2/x64/OVMF.4m.fd \
- -m 2048 \
- -smp 2 \
- -drive file=finished/boot.img,format=raw,index=0,media=disk,if=virtio \
- -drive file=finished/sys.img,format=raw,index=1,media=disk,if=virtio \
- -drive file=finished/vend.img,format=raw,index=2,media=disk,if=virtio \
- -device virtio-vga,xres=1080,yres=1900 -debugcon file:ovmf.log -global isa-debugcon.iobase=0x402 \
- -netdev user,id=net0 \
- -device virtio-net-pci,netdev=net0
- # ── Clean ──────────────────────────────────────────────────────────
- # Removes ALL build artifacts including SPM cache.
- clean:
- rm -rf out_staging finished boot/assets
- @$(MAKE) --no-print-directory -C $(TOOLS) clean
- # ═══════════════════════════════════════════════════════════════════
- # Binary Compilation Targets
- # ═══════════════════════════════════════════════════════════════════
- # These are invoked by tools/build via `make -C <arkos-dir> <target>`.
- # They use direct swiftc compilation for minimal overhead.
- # ═══════════════════════════════════════════════════════════════════
- # Extract the Verified Boot signing key from vendor config
- ARK_KEY := $(shell if [ -f vendor/verify/securebuild.ark ]; then \
- grep "^ARK-OS-" vendor/verify/securebuild.ark | tr -d '[:space:]'; \
- else echo "NO_KEY"; fi)
- # ── fb_helper.o — Framebuffer ioctl bridge (C → Swift interop) ────
- out_staging/fb_helper.o: system/core/fb_helper.c
- gcc -c system/core/fb_helper.c -o out_staging/fb_helper.o
- # ── swift_splash — Boot Animation ────────────────────────────────
- # Moved to ui_daemon
- # (Removed swift_splash target)
- # ── arkrt — ArkOS Runtime Daemon (PID 2) ──────────────────────────
- out_staging/arkrt: arkrt/main.swift arkrt/KernelBridge.swift \
- arkrt/CommandRouter.swift arkrt/IPC.swift \
- arkrt/ServiceManager.swift arkrt/NetworkService.swift
- swiftc -O -static-executable \
- arkrt/main.swift arkrt/KernelBridge.swift \
- arkrt/CommandRouter.swift arkrt/IPC.swift \
- arkrt/ServiceManager.swift arkrt/NetworkService.swift \
- -o out_staging/arkrt
- # ── init — PID 1 process (mounts filesystems, verifies boot) ─────
- out_staging/init: system/core/init.c vendor/verify/sha256.c
- gcc -static vendor/verify/sha256.c system/core/init.c \
- -Ivendor/verify -DARK_KEY=\""$(ARK_KEY)"\" \
- -o out_staging/init
- # ── Bootloader binaries (BIOS + UEFI) ────────────────────────────
- out_staging/bootloader.bin: boot/source/bootloader.asm
- nasm -f bin boot/source/bootloader.asm -o out_staging/bootloader.bin
- out_staging/stage2.bin: boot/source/stage2.asm
- nasm -f bin boot/source/stage2.asm -o out_staging/stage2.bin
- out_staging/BOOTX64.EFI: boot/source/bootloader.c
- gcc -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol \
- -fno-stack-protector -fpic -fshort-wchar -mno-red-zone -DEFI_FUNCTION_WRAPPER \
- -c boot/source/bootloader.c -o out_staging/bootloader_uefi.o
- ld -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic \
- /usr/lib/crt0-efi-x86_64.o out_staging/bootloader_uefi.o \
- -o out_staging/bootloader_uefi.so -lgnuefi -lefi -L/usr/lib
- objcopy -j .text -j .sdata -j .data -j .rodata -j .dynamic -j .dynsym \
- -j .rel -j .rela -j .reloc -j .eh_frame \
- -O pei-x86-64 --subsystem 10 out_staging/bootloader_uefi.so out_staging/BOOTX64.EFI
- # ── ui_daemon — Display Compositor ─────────────────────────────────
- out_staging/system/ui_daemon: system/display/main.swift system/display/splash.swift out_staging/fb_helper.o
- @mkdir -p out_staging/system
- @swiftc -O -static-executable \
- system/display/main.swift system/display/splash.swift out_staging/fb_helper.o \
- -o out_staging/system/ui_daemon
- # ── ui_test — Setup / Welcome app ────────────────────────────────
- out_staging/system/ui_test: system/apps/ui_test.swift frameworks/ArkGraphics/ArkGraphics.swift
- mkdir -p out_staging/system
- swiftc -O -static-executable \
- system/apps/ui_test.swift frameworks/ArkGraphics/ArkGraphics.swift \
- -o out_staging/system/ui_test
|