Files
pukeko-3ds/Makefile
2025-05-10 13:52:29 +00:00

62 lines
1.6 KiB
Makefile

.SUFFIXES:
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
TARGET := pukeko-3ds
BUILD := build
SRCDIRS := program/src libpukeko/src
INCLUDE := -I$(CURDIR)/include \
-I$(CURDIR)/libpukeko/include \
-I$(CURDIR)/program/include \
-I$(DEVKITPRO)/libctru/include \
-I$(BUILD)
# Updated architecture flags
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mfpu=vfp
CFLAGS := -g -Wall -O2 -mword-relocations \
-ffunction-sections $(ARCH) \
$(INCLUDE) -D__3DS__
# These are crucial for 3DS devkitARM - use 3dsx.specs
LDFLAGS := -specs=3dsx.specs $(ARCH) -L$(DEVKITPRO)/libctru/lib
# Make sure to include standard C library
LIBS := -lctru -lm
# Use find to recurse
CFILES := $(shell find $(SRCDIRS) -name '*.c')
OFILES := $(patsubst %.c,$(BUILD)/%.o,$(CFILES))
.PHONY: all clean
all: $(BUILD) $(TARGET).3dsx
$(TARGET).3dsx: $(BUILD)/$(TARGET).elf
@echo "[3DSX] $@"
@$(DEVKITPRO)/tools/bin/3dsxtool $< $@ $(if $(filter $(TARGET).smdh,$(wildcard $(TARGET).smdh)),--smdh=$(TARGET).smdh) $(if $(strip $(ROMFS)),--romfs=$(ROMFS))
$(BUILD)/$(TARGET).elf: $(OFILES)
@mkdir -p $(dir $@)
@echo "[LD] $@"
@$(CC) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)
# 🧱 C build rule
$(BUILD)/%.o: %.c
@mkdir -p $(dir $@)
@echo "[CC] $<"
@$(CC) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@
$(BUILD):
@mkdir -p $@
clean:
@echo "Cleaning build files..."
@rm -rf $(BUILD) $(TARGET).3dsx $(TARGET).elf
# ⛑ Include generated dependency files
-include $(patsubst %.o,%.d,$(OFILES))