Updated Makefile and splited objects and assets objects

This commit is contained in:
Ulysse Cura 2025-08-12 19:44:57 +02:00
parent c66ddc94a5
commit 6bd85dfb8f
1 changed files with 13 additions and 8 deletions

View File

@ -20,7 +20,8 @@ CXXFLAGS = -std=c++17 -g -I.
LDFLAGS =
# Deduce objects
OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o) $(ASSETS:%=$(BUILD_DIR)/%.o)
OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o)
ASSETS_OBJECTS = $(ASSETS:%=$(BUILD_DIR)/%.o)
# Verbose mode
ifeq ($(VERBOSE), 1)
@ -39,16 +40,16 @@ TOTAL_FILES := $(shell echo $$(($(words $(SOURCES))+1)))
CURRENT_FILE := 0
# Default targets
all: $(BUILD_DIR) $(OUTPUT) end
all: build_dir $(OUTPUT) end
# Create build directory
$(BUILD_DIR):
$(Q)mkdir -p $(dir $(OBJECTS))
build_dir:
$(Q)mkdir -p $(dir $(OBJECTS)) $(dir $(ASSETS_OBJECTS))
# Link target
$(OUTPUT): $(OBJECTS)
$(OUTPUT): $(OBJECTS) $(ASSETS_OBJECTS)
@echo "[100%] $(YELLOW)Linking $(OUTPUT)$(RESET)"
$(Q)$(CXX) $(LDFLAGS) -o $@ $(OBJECTS)
$(Q)$(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(ASSETS_OBJECTS)
# Build .o files from .cpp
$(BUILD_DIR)/%.o: %.cpp
@ -58,9 +59,13 @@ $(BUILD_DIR)/%.o: %.cpp
$(Q)mkdir -p $(dir $@)
$(Q)$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
# Arch and BFD header version
ARCH := $(shell arch)
BFD_VER := $(shell objcopy --info 2>/dev/null | grep -m1 '^elf')
# Convert .png.o from .png
$(BUILD_DIR)/%.png.o: %.png
fxconv --toolchain= --cg $< -o $@
$(BUILD_DIR)/%.o: %
fxconv --cg --toolchain= --arch=$(ARCH) --outputtarget=$(BFD_VER) $< -o $@
# Source files dependencies
-include $(OBJECTS:.o=.d)