# Configuration BUILD_DIR := build/pspeu PSP_EU_TARGETS := stwrp tt_000 # Flags AS_FLAGS += -EL -I include/ -G0 -march=allegrex -mabi=eabi MWCCPSP_FLAGS := -gccinc -Iinclude -D_internal_version_$(VERSION) -Op -c -lang c -sdatathreshold 0 -char unsigned MWLDPSP_FLAGS := -partial -nostdlib -msgstyle gcc -sym full,elf -g # Tools ALLEGREX_AS := $(BIN_DIR)/allegrex-as AS := $(ALLEGREX_AS) WIBO := $(BIN_DIR)/wibo MWCCPSP := $(BIN_DIR)/mwccpsp.exe CCPSP := MWCIncludes=$(BIN_DIR) $(WIBO) $(MWCCPSP) MWASPSP := $(WIBO) $(BIN_DIR)/asm_psp_elf.exe -gnu MWLDPSP := $(WIBO) $(BIN_DIR)/mwldpsp.exe MWCCGAP_DIR := $(TOOLS_DIR)/mwccgap MWCCGAP_APP := $(MWCCGAP_DIR)/mwccgap.py MWCCGAP := $(PYTHON) $(MWCCGAP_APP) SPLAT_PIP := splat split # Helper Functions define list_src_files_psp $(foreach dir,$(ASM_DIR)/$(1),$(wildcard $(dir)/**.s)) $(foreach dir,$(ASM_DIR)/$(1)/data,$(wildcard $(dir)/**.s)) $(foreach dir,$(SRC_DIR)/$(1),$(wildcard $(dir)/**.c)) $(foreach dir,$(ASSETS_DIR)/$(1),$(wildcard $(dir)/**)) endef define list_o_files_psp $(foreach file,$(call list_src_files_psp,$(1)),$(BUILD_DIR)/$(file).o) endef # Targets build_pspeu: $(addsuffix _psp,$(PSP_EU_TARGETS)) extract_pspeu: $(addprefix $(BUILD_DIR)/,$(addsuffix .ld,$(PSP_EU_TARGETS))) $(WIBO): wget -O $@ https://github.com/decompals/wibo/releases/download/0.6.13/wibo sha256sum --check $(WIBO).sha256 chmod +x $(WIBO) $(MWCCPSP): $(WIBO) $(BIN_DIR)/mwccpsp_219 $(MWCCGAP_APP): git submodule init $(MWCCGAP_DIR) git submodule update $(MWCCGAP_DIR) tt_000_psp: $(BUILD_DIR)/tt_000.bin stwrp_psp: $(BUILD_DIR)/wrp.bin $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf $(OBJCOPY) -O binary $< $@ $(BUILD_DIR)/wrp.bin: $(BUILD_DIR)/stwrp.elf $(OBJCOPY) -O binary $< $@ $(BUILD_DIR)/st%.ld: $(CONFIG_DIR)/splat.pspeu.st%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.st%.txt $(SPLAT_PIP) $< $(BUILD_DIR)/tt_%.ld: $(CONFIG_DIR)/splat.pspeu.tt_%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.tt_%.txt $(SPLAT_PIP) $< $(BUILD_DIR)/tt_%.elf: $(BUILD_DIR)/tt_%.ld $$(call list_o_files_psp,servant/tt_$$*) $(BUILD_DIR)/assets/servant/tt_%/mwo_header.bin.o $(call link,tt_$*,$@) ST_WRP_MERGE = st_update e_particles e_room_fg st_common st_debug e_breakable popup warp e_red_door $(BUILD_DIR)/stwrp.elf: $(BUILD_DIR)/stwrp.ld $(addprefix $(BUILD_DIR)/src/st/wrp/,$(addsuffix .c.o,$(ST_WRP_MERGE))) $$(call list_o_files_psp,st/wrp_psp) $(BUILD_DIR)/assets/st/wrp/mwo_header.bin.o $(call link,stwrp,$@) # Recipes $(BUILD_DIR)/%.s.o: %.s @mkdir -p $(dir $@) $(AS) $(AS_FLAGS) -o $@ $< $(BUILD_DIR)/%.c.o: %.c $(MWCCPSP) $(MWCCGAP_APP) @mkdir -p $(dir $@) $(MWCCGAP) $< $@ --mwcc-path $(MWCCPSP) --use-wibo --wibo-path $(WIBO) --as-path $(AS) --asm-dir-prefix asm/pspeu $(MWCCPSP_FLAGS) $(BUILD_DIR)/assets/%/mwo_header.bin.o: assets/%/mwo_header.bin @mkdir -p $(dir $@) $(LD) -r -b binary -o $@ $<