SRC_DIR := src
BUILD_DIR := build/$(ARCH)
+# --- Submodule auto-init ---
+# If lwIP source is missing, the submodules haven't been initialized.
+LWIP_SENTINEL := third_party/lwip/src/core/init.c
+$(LWIP_SENTINEL):
+ @echo " GIT Initializing submodules..."
+ @git submodule update --init --recursive
+
+# Apply lwIP patches (once, after submodule init)
+.lwip_patched: $(LWIP_SENTINEL)
+ @if git apply --check patches/lwip-tcpip-volatile.patch 2>/dev/null; then \
+ git apply patches/lwip-tcpip-volatile.patch; \
+ echo " PATCH lwip-tcpip-volatile"; \
+ fi
+ @touch $@
+
# Minimal kernel sources shared across all architectures
KERNEL_COMMON := main.c console.c utils.c cmdline.c driver.c cpu_features.c
C_SOURCES := $(addprefix $(SRC_DIR)/kernel/,$(KERNEL_COMMON))
all: $(KERNEL_NAME)
-$(KERNEL_NAME): $(OBJ)
+$(KERNEL_NAME): .lwip_patched $(OBJ)
@echo " LD $@"
@$(LD) $(LDFLAGS) -n -o $@ $(BOOT_OBJ) $(KERNEL_OBJ) $(shell $(CC) $(ARCH_CFLAGS) -print-libgcc-file-name)
@$(AS) $(ASFLAGS) $< -o $@
clean:
- rm -rf build $(KERNEL_NAME) $(INITRD_IMG) adros-*.iso
+ rm -rf build $(KERNEL_NAME) $(INITRD_IMG) adros-*.iso .lwip_patched
@$(MAKE) -C user/ulibc clean --no-print-directory 2>/dev/null || true
@if [ -f user/doom/Makefile ]; then $(MAKE) -C user/doom clean --no-print-directory 2>/dev/null || true; fi
+diff --git a/third_party/lwip/src/api/tcpip.c b/third_party/lwip/src/api/tcpip.c
+index 0891f9e..e0ae887 100644
--- a/third_party/lwip/src/api/tcpip.c
+++ b/third_party/lwip/src/api/tcpip.c
-@@ -55,8 +55,8 @@
+@@ -55,9 +55,9 @@
+ #define TCPIP_MSG_VAR_ALLOC(name) API_VAR_ALLOC(struct tcpip_msg, MEMP_TCPIP_MSG_API, name, ERR_MEM)
#define TCPIP_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_TCPIP_MSG_API, name)
-/* global variables */
+static volatile tcpip_init_done_fn tcpip_init_done;
+static void * volatile tcpip_init_done_arg;
static sys_mbox_t tcpip_mbox;
+
+ #if LWIP_TCPIP_CORE_LOCKING
all: check-doomgeneric doom.elf
check-doomgeneric:
- @if [ ! -d doomgeneric ]; then \
- echo "ERROR: doomgeneric/ directory not found."; \
- echo "Run: git clone https://github.com/ozkl/doomgeneric.git"; \
+ @if [ ! -f doomgeneric/doomgeneric/doomgeneric.h ]; then \
+ echo "ERROR: doomgeneric/ submodule not initialized."; \
+ echo "Run from repo root: git submodule update --init --recursive"; \
exit 1; \
fi