gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu
```
-## 2. Building & Running (x86)
+## 2. Getting the Source
+
+```bash
+git clone --recursive https://github.com/tadryanom/AdrOS.git
+cd AdrOS
+```
+
+If you already cloned without `--recursive`, initialize the submodules:
+```bash
+git submodule update --init --recursive
+```
+
+The build system will auto-initialize submodules and apply required patches
+if they haven't been set up yet.
+
+## 3. Building & Running (x86)
This is the primary target (standard PC).
- `QEMU_DEBUG=1` enables QEMU logging to `qemu.log` using `-d guest_errors,cpu_reset -D qemu.log`.
- `QEMU_INT=1` appends `-d int` to QEMU debug flags.
-## 3. Building DOOM
+## 4. Building DOOM
-The DOOM port uses the [doomgeneric](https://github.com/ozkl/doomgeneric) engine with an AdrOS-specific platform adapter.
+The DOOM port uses the [doomgeneric](https://github.com/ozkl/doomgeneric) engine (included as a git submodule) with an AdrOS-specific platform adapter.
### Setup
```bash
-cd user/doom
-git clone https://github.com/ozkl/doomgeneric.git
-make
+# Submodules should already be initialized (see section 2).
+# If not: git submodule update --init --recursive
+make doom
```
-This produces `user/doom/doom.elf` (\~450KB). The main `Makefile` will **automatically include** `doom.elf` in the initrd if it exists.
+This produces `user/doom/doom.elf` (~450KB). The main `Makefile` will **automatically include** `doom.elf` in the initrd if it exists.
### Running DOOM
```bash
- `doom1.wad` (shareware) accessible from the filesystem
- Kernel support: `/dev/fb0` (mmap framebuffer), `/dev/kbd` (raw PS/2 scancodes), `nanosleep`, `clock_gettime`
-## 4. Building & Running (ARM64)
+## 5. Building & Running (ARM64)
### Build
```bash
- To quit QEMU when using `-nographic`: press `Ctrl+A`, release, then `x`.
- ARM64 boots with PL011 UART at 0x09000000, EL2→EL1 transition, FP/SIMD enabled.
-## 5. Building & Running (RISC-V 64)
+## 6. Building & Running (RISC-V 64)
### Build
```bash
- To quit: `Ctrl+A`, then `x`.
- RISC-V boots with NS16550 UART at 0x10000000, M-mode, `-bios none`.
-## 6. Building & Running (MIPS32)
+## 7. Building & Running (MIPS32)
### Build
```bash
- To quit: `Ctrl+A`, then `x`.
- MIPS32 boots with 16550 UART at ISA I/O 0x3F8 (KSEG1 0xB80003F8), `-march=mips32r2`.
-## 7. Common Troubleshooting
+## 8. Common Troubleshooting
- **"Multiboot header not found"**: Check whether `grub-file --is-x86-multiboot2 adros-x86.bin` returns success (0). If it fails, the section order in `linker.ld` may be wrong.
- **"Triple Fault (infinite reset)"**: Usually caused by paging (VMM) issues or a misconfigured IDT. Run `make ARCH=x86 run QEMU_DEBUG=1` and inspect `qemu.log`.
SRC_DIR := src
BUILD_DIR := build/$(ARCH)
+.DEFAULT_GOAL := all
+
# --- Submodule auto-init ---
-# If lwIP source is missing, the submodules haven't been initialized.
+# If any submodule source is missing, run git submodule update.
LWIP_SENTINEL := third_party/lwip/src/core/init.c
-$(LWIP_SENTINEL):
+DOOM_SENTINEL := user/doom/doomgeneric/doomgeneric/doomgeneric.h
+$(LWIP_SENTINEL) $(DOOM_SENTINEL):
@echo " GIT Initializing submodules..."
@git submodule update --init --recursive
INITRD_DEPS := $(MKINITRD) $(FULLTEST_ELF) $(USER_CMD_ELFS) $(LDSO_ELF) $(ULIBC_SO) $(PIE_SO) $(PIE_ELF) $(FSTAB)
# doom (build via 'make doom', included in initrd if present)
-doom: $(ULIBC_LIB) $(ULIBC_SO)
+doom: $(DOOM_SENTINEL) $(ULIBC_LIB) $(ULIBC_SO)
@$(MAKE) --no-print-directory -C user/doom TOPDIR=$(CURDIR) ULIBC_BUILDDIR="$(ULIBC_BUILDDIR)"
# Include doom.elf if it has been built