# Configuration BUILD_DIR := build/pspeu PSP_EU_TARGETS := dra stwrp tt_000 # Flags AS_FLAGS += -EL -I include/ -G0 -march=allegrex -mabi=eabi MWCCPSP_FLAGS := -gccinc -Iinclude -D_internal_version_$(VERSION) -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) dra_psp: $(BUILD_DIR)/dra.bin 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)/dra.ld: $(CONFIG_DIR)/splat.pspeu.dra.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.dra.txt $(SPLAT_PIP) $< $(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) $< ST_DRA_MERGE = 624DC $(BUILD_DIR)/dra.elf: $(BUILD_DIR)/dra.ld $(addprefix $(BUILD_DIR)/src/dra/,$(addsuffix .c.o,$(ST_DRA_MERGE))) $$(call list_o_files_psp,dra_psp) $(call link,dra,$@) $(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 $@ $< # DRA appears to be compiled with -O4,p. This will control that flag. # May need to modify if other -O4,p functions are found in other overlays. # Works for now. Look in git history for a different approach which filters by individual .o file. OPT_HIGH = -O4,p #need this because otherwise the comma breaks the if-statement OPTIMIZATION = $(if $(findstring dra, $@), $(OPT_HIGH), -Op) $(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) $(OPTIMIZATION) $(BUILD_DIR)/assets/%/mwo_header.bin.o: assets/%/mwo_header.bin @mkdir -p $(dir $@) $(LD) -r -b binary -o $@ $<