2021-09-27 04:00:46 +00:00
|
|
|
ifneq ($(findstring MINGW,$(shell uname)),)
|
|
|
|
WINDOWS := 1
|
|
|
|
endif
|
|
|
|
ifneq ($(findstring MSYS,$(shell uname)),)
|
|
|
|
WINDOWS := 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Files
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
TARGET_COL := gc
|
|
|
|
|
|
|
|
NAME := pikmin2
|
|
|
|
VERSION := usa
|
|
|
|
#VERSION := usa.demo
|
|
|
|
|
|
|
|
BUILD_DIR := build/$(NAME).$(VERSION)
|
|
|
|
|
2021-09-30 02:44:13 +00:00
|
|
|
SRC_DIRS := src src/plugProjectHikinoU src/plugProjectKonoU
|
|
|
|
ASM_DIRS := asm asm/plugProjectHikinoU asm/plugProjectKonoU
|
2021-09-27 04:00:46 +00:00
|
|
|
|
|
|
|
# Inputs
|
|
|
|
S_FILES := $(wildcard asm/*.s)
|
|
|
|
C_FILES := $(wildcard src/*.c)
|
2021-09-30 00:20:15 +00:00
|
|
|
CPP_FILES := $(wildcard src/*.cpp)
|
2021-09-27 04:00:46 +00:00
|
|
|
LDSCRIPT := $(BUILD_DIR)/ldscript.lcf
|
|
|
|
|
|
|
|
# Outputs
|
|
|
|
DOL := $(BUILD_DIR)/main.dol
|
|
|
|
ELF := $(DOL:.dol=.elf)
|
|
|
|
MAP := $(BUILD_DIR)/pikmin2.map
|
|
|
|
|
|
|
|
include obj_files.mk
|
|
|
|
|
|
|
|
O_FILES := $(INIT_O_FILES) $(EXTAB_O_FILES) $(EXTABINDEX_O_FILES) $(TEXT_O_FILES) \
|
|
|
|
$(CTORS_O_FILES) $(DTORS_O_FILES) $(RODATA_O_FILES) $(DATA_O_FILES) \
|
|
|
|
$(BSS_O_FILES) $(SDATA_O_FILES) $(SBSS_O_FILES) $(SDATA2_O_FILES) \
|
|
|
|
$(SBSS2_O_FILES) \
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Tools
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
MWCC_VERSION := 1.0
|
|
|
|
MWLD_VERSION := 2.7e
|
|
|
|
|
|
|
|
# Programs
|
|
|
|
ifeq ($(WINDOWS),1)
|
|
|
|
WINE :=
|
2021-09-30 00:20:15 +00:00
|
|
|
AS := $(DEVKITPPC)/bin/powerpc-eabi-as.exe
|
|
|
|
OBJCOPY := $(DEVKITPPC)/bin/powerpc-eabi-objcopy.exe
|
|
|
|
CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp.exe -P
|
2021-09-27 04:00:46 +00:00
|
|
|
else
|
|
|
|
WINE := wine
|
2021-09-30 00:20:15 +00:00
|
|
|
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
|
|
|
|
OBJCOPY := $(DEVKITPPC)/bin/powerpc-eabi-objcopy
|
|
|
|
CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp -P
|
2021-09-27 04:00:46 +00:00
|
|
|
endif
|
|
|
|
CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe
|
|
|
|
LD := $(WINE) tools/mwcc_compiler/$(MWLD_VERSION)/mwldeppc.exe
|
|
|
|
ELF2DOL := tools/elf2dol
|
|
|
|
SHA1SUM := sha1sum
|
|
|
|
PYTHON := python3
|
|
|
|
|
|
|
|
POSTPROC := tools/postprocess.py
|
|
|
|
|
|
|
|
# Options
|
2021-09-30 00:20:15 +00:00
|
|
|
INCLUDES := -i include/
|
2021-09-27 04:00:46 +00:00
|
|
|
|
|
|
|
ASFLAGS := -mgekko -I include/
|
|
|
|
LDFLAGS := -map $(MAP) -fp hard -nodefaults
|
|
|
|
CFLAGS := -Cpp_exceptions off -proc gekko -fp hard -O4,p -nodefaults -msgstyle gcc $(INCLUDES)
|
|
|
|
|
|
|
|
# for postprocess.py
|
|
|
|
PROCFLAGS := -fprologue-fixup=old_stack
|
|
|
|
|
|
|
|
# elf2dol needs to know these in order to calculate sbss correctly.
|
|
|
|
SDATA_PDHR := 9
|
|
|
|
SBSS_PDHR := 10
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Recipes
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
### Default target ###
|
|
|
|
|
|
|
|
default: all
|
|
|
|
|
|
|
|
all: $(DOL)
|
|
|
|
|
|
|
|
ALL_DIRS := build $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))
|
|
|
|
|
|
|
|
# Make sure build directory exists before compiling anything
|
|
|
|
DUMMY != mkdir -p $(ALL_DIRS)
|
|
|
|
|
|
|
|
$(LDSCRIPT): ldscript.lcf
|
|
|
|
$(CPP) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<
|
|
|
|
|
|
|
|
$(DOL): $(ELF) | tools
|
|
|
|
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
|
|
|
|
$(SHA1SUM) -c sha1/$(NAME).$(VERSION).sha1
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f -d -r build
|
|
|
|
|
|
|
|
$(ELF): $(O_FILES) $(LDSCRIPT)
|
|
|
|
$(LD) $(LDFLAGS) -lcf $(LDSCRIPT) $(O_FILES) -o $@
|
|
|
|
# The Metrowerks linker doesn't generate physical addresses in the ELF program headers. This fixes it somehow.
|
|
|
|
$(OBJCOPY) $@ $@
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.s
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2021-09-30 00:20:15 +00:00
|
|
|
#$(PYTHON) $(POSTPROC) $(PROCFLAGS) $@
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.cpp
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
#$(PYTHON) $(POSTPROC) $(PROCFLAGS) $@
|
2021-09-27 04:00:46 +00:00
|
|
|
|
|
|
|
### Debug Print ###
|
|
|
|
|
|
|
|
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|