Files
RedBear-OS/Makefile
T
vasilito 660e3e001d Merge upstream/master into submodule/kernel
Sync the kernel fork with 10 upstream commits (context timer-separation
with unblock_context/wakeup_context, dtb MMIO/bus-address translation
+ tests, event read_with_timeout support, proc wakeup paths, dup2
rewrite with rollback, futex Weak context_lock + unblock_context,
memory/init ordering, and more). Satisfies the verify-fork-functions
gate (11 previously-missing upstream functions now present).

Conflicts resolved (5 files; 9 auto-merged):

- src/syscall/futex.rs: took upstream's version wholesale (Weak
  context_lock, upgrade+unblock_context, TimeSpec::to_nanos,
  get_futex_stat, addr_space strong_count cleanup); re-applied the RB
  FUTEX_WAIT_MULTIPLE/FUTEX_REQUEUE implementations adapted to the
  Weak API, with wake-index bookkeeping preserved
  (Context::futex_wake_index survives in context.rs).

- src/event.rs: merged EventQueue with both RB's fd-refcount refs and
  upstream's timeout_opt (init in new()); kept RB's EventCounter/
  eventfd block; added upstream's read_with_timeout +
  EVENT_TIMEOUT_ID write handling; deduplicated EAGAIN/EINTR imports.

- src/scheme/proc.rs: upstream imports minus UnmapVec (RB deleted that
  machinery from context/memory.rs — import-only dependency);
  ContextHandle::Start keeps RB's require_zero_offset + upstream's
  wakeup_context; FORCEKILL region takes upstream's
  is_dead()/being_sigkilled form.

- src/syscall/fs.rs: took upstream's dup2 structure (natural
  self-dup-with-buf handling — preserves the relibc dup2(ft,ft,
  "refresh") semantic — plus rollback on insert failure), adapted to
  the fork's 4-arg duplicate_file and read/token_split conventions.

- src/arch/aarch64/start.rs: kept upstream's new PageMapper/
  acpi::init_before_mem/memory::init_mm init block.

Verified: repo cook kernel --force-rebuild successful;
verify-fork-functions.sh --no-fetch kernel passes.
2026-07-19 07:02:19 +09:00

100 lines
2.5 KiB
Makefile

# Red Bear OS kernel patches applied via individual patch files
.PHONY: all check
SOURCE:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
export RUST_TARGET_PATH=$(SOURCE)/targets
ifeq ($(TARGET),)
ARCH?=$(shell uname -m)
else
ARCH?=$(shell echo "$(TARGET)" | cut -d - -f1)
endif
BUILD?=$(CURDIR)/build/$(ARCH)
DESTDIR?=./sysroot
ifeq ($(ARCH),riscv64gc)
override ARCH:=riscv64
GNU_TARGET=riscv64-unknown-redox
else ifeq ($(ARCH),i686)
override ARCH:=i586
GNU_TARGET=i686-unknown-redox
else
GNU_TARGET=$(ARCH)-unknown-redox
endif
OBJCOPY?=$(GNU_TARGET)-objcopy
all: $(BUILD)/kernel $(BUILD)/kernel.sym
LD_SCRIPT=$(SOURCE)/linkers/$(ARCH).ld
LOCKFILE=$(SOURCE)/Cargo.lock
MANIFEST=$(SOURCE)/Cargo.toml
TARGET_SPEC=$(RUST_TARGET_PATH)/$(ARCH)-unknown-kernel.json
KERNEL_CARGO_FEATURES?=
$(BUILD):
mkdir -p "$@"
$(BUILD)/kernel.all: $(LD_SCRIPT) $(LOCKFILE) $(MANIFEST) $(TARGET_SPEC) $(shell find $(SOURCE) -name "*.rs" -type f) | $(BUILD)
cargo rustc \
--bin kernel \
--manifest-path "$(MANIFEST)" \
--target "$(TARGET_SPEC)" \
--release \
-Z build-std=core,alloc -Zbuild-std-features=compiler-builtins-mem -Z json-target-spec \
--features=$(KERNEL_CARGO_FEATURES) \
-- \
-C link-arg=-T -Clink-arg="$(LD_SCRIPT)" \
-C link-arg=-z -Clink-arg=max-page-size=0x1000 \
--emit link="$(BUILD)/kernel.all"
$(BUILD)/kernel.sym: $(BUILD)/kernel.all
$(OBJCOPY) \
--only-keep-debug \
"$(BUILD)/kernel.all" \
"$(BUILD)/kernel.sym"
$(BUILD)/kernel: $(BUILD)/kernel.all
$(OBJCOPY) \
--strip-debug \
"$(BUILD)/kernel.all" \
"$(BUILD)/kernel"
KERNEL_CHECK_FEATURES?=
check:
cargo check \
--bin kernel \
--manifest-path "$(MANIFEST)" \
--target "$(TARGET_SPEC)" \
-Z build-std=core,alloc -Zbuild-std-features=compiler-builtins-mem -Z json-target-spec \
--features=$(KERNEL_CHECK_FEATURES)
clean:
rm -rf build sysroot target config.toml
install: all
@mkdir -pv "$(DESTDIR)/usr/lib/boot/"
cp -v $(BUILD)/kernel.all "$(DESTDIR)/usr/lib/boot/"
cp -v $(BUILD)/kernel.sym "$(DESTDIR)/usr/lib/boot/"
cp -v $(BUILD)/kernel "$(DESTDIR)/usr/lib/boot/"
# test if booting
# to ensure it's using this kernel, set COOKBOOK_SOURCE_IDENT env before build
test: all
$(MAKE) install
REDOXER_SYSROOT=$(DESTDIR) redoxer exec uname -a
# test with interactive gui
test-gui: all
$(MAKE) install
REDOXER_SYSROOT=$(DESTDIR) redoxer exec --gui ion
# test with relibc tests
test-relibc: all
$(MAKE) install
REDOXER_SYSROOT=$(DESTDIR) redoxer pkg relibc-tests-bins
REDOXER_SYSROOT=$(DESTDIR) redoxer exec relibc-tests-runner