]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
Makefile adjust to suporte passing parameters
authortadryanom_bot <[email protected]>
Thu, 5 Feb 2026 04:59:04 +0000 (04:59 +0000)
committertadryanom_bot <[email protected]>
Thu, 5 Feb 2026 04:59:04 +0000 (04:59 +0000)
Makefile

index c69bfde6241d25f73ea600009e7e04732f86c2b9..d08066fe011b1cf6e34888e5d06df180b619c12b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,12 +15,29 @@ C_SOURCES += $(wildcard $(SRC_DIR)/mm/*.c)
 
 # --- x86 Configuration ---
 ifeq ($(ARCH),x86)
-    CC := gcc
-    AS := as
-    LD := ld
-    CFLAGS := -m32 -ffreestanding -O2 -Wall -Wextra -Iinclude
-    LDFLAGS := -m elf_i386 -T $(SRC_DIR)/arch/x86/linker.ld
-    ASFLAGS := --32
+    # Default Toolchain Prefix (can be overridden)
+    ifdef CROSS
+        TOOLPREFIX ?= i686-elf-
+    endif
+
+    # Toolchain tools (Allow user override via make CC=...)
+    CC ?= $(TOOLPREFIX)gcc
+    AS ?= $(TOOLPREFIX)as
+    LD ?= $(TOOLPREFIX)ld
+    
+    # Mandatory Architecture Flags
+    ARCH_CFLAGS := -m32 -ffreestanding -Iinclude
+    ARCH_LDFLAGS := -m elf_i386 -T $(SRC_DIR)/arch/x86/linker.ld
+    ARCH_ASFLAGS := --32
+
+    # Default User Flags (Allow override via make CFLAGS=...)
+    CFLAGS ?= -O2 -Wall -Wextra
+    
+    # Merge Flags
+    CFLAGS := $(ARCH_CFLAGS) $(CFLAGS)
+    LDFLAGS := $(ARCH_LDFLAGS) $(LDFLAGS)
+    ASFLAGS := $(ARCH_ASFLAGS) $(ASFLAGS)
+
     ASM_SOURCES := $(wildcard $(SRC_DIR)/arch/x86/*.S)
     C_SOURCES += $(wildcard $(SRC_DIR)/arch/x86/*.c)
 endif