refactor: add architecture

This commit is contained in:
2026-10-02 13:32:40 +02:00
parent c4fb939e48
commit 387db2dcf7
11 changed files with 283 additions and 53 deletions
+20 -8
View File
@@ -1,18 +1,23 @@
TARGET := towos.elf
ISO := towos.iso
CC := x86_64-elf-gcc
CXX := x86_64-elf-g++
LD := x86_64-elf-ld
AS := x86_64-elf-as
# Possible values: x86_64
TARGET_ARCH ?= $(shell uname -m)
CC := $(TARGET_ARCH)-elf-gcc
CXX := $(TARGET_ARCH)-elf-g++
LD := $(TARGET_ARCH)-elf-ld
AS := $(TARGET_ARCH)-elf-as
CXXFLAGS := \
-std=c++17 \
-Ikernel \
-ffreestanding \
-fno-exceptions \
-fno-rtti \
-fno-stack-protector \
-fno-stack-check \
-fno-threadsafe-statics \
-fno-pic \
-fno-pie \
-fno-use-cxa-atexit \
@@ -20,7 +25,11 @@ CXXFLAGS := \
-Wall \
-Wextra \
-Wpedantic \
-O2
-O2 \
-mno-sse \
-mno-sse2 \
-mno-mmx \
-mno-80387
ASFLAGS := \
--64
@@ -29,19 +38,22 @@ LDFLAGS := \
-T linker.ld \
-nostdlib \
-no-pie \
--build-id=none
--build-id=none \
--no-warn-rwx-segments
SRC_DIR := kernel
BIN_DIR := bin
BUILD_DIR := build
CXXSOURCES := $(shell find $(SRC_DIR) -type f -name '*.cpp')
CXXSOURCES := $(shell find $(SRC_DIR) -type f -name '*.cpp' -not -path "*/arch/*" -o -type f -name '*.cpp' -path "*/arch/$(TARGET_ARCH)/*")
SSOURCES := $(shell find $(SRC_DIR) -type f -name '*.S' -not -path "*/arch/*" -o -type f -name '*.S' -path "*/arch/$(TARGET_ARCH)/*")
CXXOBJECTS := $(patsubst $(SRC_DIR)/%.cpp,$(BIN_DIR)/%.o,$(CXXSOURCES))
SSOURCES := $(shell find $(SRC_DIR) -type f -name '*.S')
SOBJECTS := $(patsubst $(SRC_DIR)/%.S,$(BIN_DIR)/%.S.o,$(SSOURCES))
OBJECTS := $(CXXOBJECTS) $(SOBJECTS)
.PHONY: all run debug check clean
all: $(BUILD_DIR)/$(ISO)