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

index f3bc50f3b094cd35aa695d6eec7c5e4424607dec..c733f7f1878025cdc16027609a3be91cecb25e6f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -24,12 +24,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