]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
fix(build): auto-init submodules, auto-apply lwIP patch, fix corrupt patch
authorTulio A M Mendes <[email protected]>
Fri, 3 Apr 2026 20:07:27 +0000 (17:07 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 3 Apr 2026 20:07:27 +0000 (17:07 -0300)
The build system now handles submodules and patches automatically so
a fresh 'git clone' + 'make' works without manual steps:

- Makefile: add LWIP_SENTINEL target that runs 'git submodule update
  --init --recursive' if lwIP sources are missing.
- Makefile: add .lwip_patched marker target that applies the lwIP
  volatile patch (patches/lwip-tcpip-volatile.patch) once after
  submodule init. Kernel build depends on this marker.
- Makefile: clean target now removes .lwip_patched marker.
- patches/lwip-tcpip-volatile.patch: regenerated with correct hunk
  header (@@ -55,9 +55,9 @@ instead of broken @@ -55,8 +55,8 @@)
  and repo-root-relative paths (third_party/lwip/...).
- user/doom/Makefile: fix error message to reference 'git submodule
  update --init' instead of 'git clone'. Check for actual header file
  instead of just directory existence.
- .gitignore: add .lwip_patched marker, remove temp hello/hello.c.

.gitignore
Makefile
patches/lwip-tcpip-volatile.patch
user/doom/Makefile

index d34e866553db23c3168c399412bab50506702b68..b9e626fcc48b26a29e0f6c88b5a1c8146caff776 100644 (file)
@@ -45,6 +45,5 @@ toolchain/logs/
 # third_party/lwip -> git submodule
 # user/doom/doomgeneric -> git submodule
 
-# Others
-hello
-hello.c
+# Build markers
+.lwip_patched
index ed20683624a9f12288abca1b319c4eda42142e42..45968437f76e1a6aea94fb01d550a6b6452b73bf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,21 @@ KERNEL_NAME := adros-$(ARCH).bin
 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))
@@ -184,7 +199,7 @@ KERNEL_OBJ := $(filter-out $(BOOT_OBJ), $(OBJ))
 
 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)
 
@@ -397,7 +412,7 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.S
        @$(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
 
index a905fec8f45c1fa8c8a4035cda7a75f8078d8b45..f197c388a5efc5a065c1ef5100800821bb24bfe7 100644 (file)
@@ -1,6 +1,9 @@
+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 */
@@ -10,3 +13,5 @@
 +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
index 5301dd779d61d54e57e62ccdc347bf550e42ccd9..595f70dac39fd8a4ff26679ebf89f2665f87d0ae 100644 (file)
@@ -65,9 +65,9 @@ ALL_OBJ := $(DG_OBJ) $(ADAPTER_OBJ)
 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