2023-02-10 23:20:40 +09:00
|
|
|
MAKE := make
|
|
|
|
|
2022-11-27 06:38:23 +09:00
|
|
|
CC := powerpc-eabi-gcc
|
2022-12-11 07:41:12 +09:00
|
|
|
CFLAGS := -O3 -I. -Wa,-mregnames,-mgekko -Wall -fno-asynchronous-unwind-tables -fno-unwind-tables -fverbose-asm -gdwarf
|
2022-11-27 06:38:23 +09:00
|
|
|
|
|
|
|
AS := powerpc-eabi-as
|
|
|
|
ASFLAGS := -mregnames -mgekko
|
|
|
|
|
|
|
|
OD := powerpc-eabi-objdump
|
2022-12-11 08:14:07 +09:00
|
|
|
ODFLAGS := -EB -D -b binary -m powerpc:750 -M gekko -a -p -h -F --full-content
|
|
|
|
ODASMFLAGS := -EB -D -b binary -m powerpc:750 -M gekko --no-show-raw-insn --no-addresses
|
2022-11-27 06:38:23 +09:00
|
|
|
|
|
|
|
LD := powerpc-eabi-ld
|
2022-12-11 07:41:12 +09:00
|
|
|
LDFLAGS := --unresolved-symbols=ignore-in-object-files --enable-non-contiguous-regions -EB --nmagic
|
2022-11-27 06:38:23 +09:00
|
|
|
|
|
|
|
OBJCOPY := powerpc-eabi-objcopy
|
2023-02-10 23:20:40 +09:00
|
|
|
#OBJCOPYFLAGS = -O binary $(foreach e,$(LD_FILES),--add-gnu-debuglink=$e) --gap-fill 0x00 --pad-to 0x81800000
|
|
|
|
OBJCOPYFLAGS = -O binary $(foreach e,$(LD_FILES),--add-gnu-debuglink=$e)
|
|
|
|
|
|
|
|
PY := python3
|
|
|
|
BIN2GCT := $(PY) gecko/bin2gct.py
|
2022-11-27 06:38:23 +09:00
|
|
|
|
|
|
|
SRC_DIR := source
|
|
|
|
INC_DIR := include
|
2023-02-10 23:20:40 +09:00
|
|
|
LD_DIR := ldscript
|
2022-11-27 06:38:23 +09:00
|
|
|
OUT_DIR := out
|
|
|
|
OBJ_DIR := obj
|
|
|
|
|
2023-02-10 23:20:40 +09:00
|
|
|
GECKO_DIR := gecko
|
|
|
|
GECKO_OUT_DIR := out
|
2022-11-27 06:38:23 +09:00
|
|
|
|
2023-02-10 23:20:40 +09:00
|
|
|
OUT_MAP := main.map
|
2022-11-27 06:38:23 +09:00
|
|
|
OUT_MAIN := main.out
|
|
|
|
OUT_BIN := main.bin
|
2022-12-11 07:41:12 +09:00
|
|
|
OUT_LST := main.lst
|
2022-12-11 08:14:07 +09:00
|
|
|
OUT_ASM := main.asm
|
2023-02-10 23:20:40 +09:00
|
|
|
OUT_LOADER_TXT = loader.txt
|
|
|
|
OUT_LOADER_GCT = loader.gct
|
2022-11-27 06:38:23 +09:00
|
|
|
|
2022-11-27 12:57:16 +09:00
|
|
|
GMSE01 := 1
|
|
|
|
GMSJ01 := 2
|
|
|
|
GMSP01 := 3
|
|
|
|
GMSJ0A := 4
|
|
|
|
|
|
|
|
TARGET_VERSION = $($(GAME_VERSION))
|
|
|
|
|
2022-11-27 06:38:23 +09:00
|
|
|
SRC_FILES := $(wildcard source/*.c)
|
|
|
|
OBJ_FILES := $(SRC_FILES:.c=.o)
|
2023-02-10 23:20:40 +09:00
|
|
|
LD_FILES := $(LD_DIR)/sms.ld $(LD_DIR)/$(GAME_VERSION).ld
|
|
|
|
GECKO_FILE_LOADER := $(GECKO_DIR)/$(GECKO_OUT_DIR)/gecko-gosub.bin
|
|
|
|
GECKO_FILES := $(GECKO_FILE_LOADER) $(GECKO_DIR)/$(GECKO_OUT_DIR)/gecko-return.bin
|
2022-11-27 06:38:23 +09:00
|
|
|
|
|
|
|
OBJS := main.o card.o
|
|
|
|
|
2023-02-10 23:20:40 +09:00
|
|
|
all: $(OUT_DIR)/$(OUT_BIN) $(OUT_DIR)/$(OUT_LST) $(OUT_DIR)/$(OUT_ASM) $(OUT_DIR)/$(OUT_LOADER_TXT)
|
2022-12-11 08:14:07 +09:00
|
|
|
|
|
|
|
$(OUT_DIR)/$(OUT_ASM): $(OUT_DIR)/$(OUT_BIN)
|
|
|
|
$(OD) $(ODASMFLAGS) $(OUT_DIR)/$(OUT_BIN) | grep -Pe "^\t(?!Address)" | sed 's/^\t//' > $(OUT_DIR)/$(OUT_ASM)
|
2022-11-27 06:38:23 +09:00
|
|
|
|
2022-12-11 07:41:12 +09:00
|
|
|
$(OUT_DIR)/$(OUT_LST): $(OUT_DIR)/$(OUT_BIN)
|
|
|
|
$(OD) $(ODFLAGS) $(OUT_DIR)/$(OUT_BIN) > $(OUT_DIR)/$(OUT_LST)
|
2022-11-27 06:38:23 +09:00
|
|
|
|
|
|
|
$(OUT_DIR)/$(OUT_BIN): $(OUT_DIR)/$(OUT_MAIN)
|
2022-12-11 09:02:56 +09:00
|
|
|
$(OBJCOPY) $(OBJCOPYFLAGS) $< $@
|
2022-11-27 06:38:23 +09:00
|
|
|
|
2023-02-10 23:20:40 +09:00
|
|
|
$(OUT_DIR)/$(OUT_MAIN): check-set-GAME_VERSION $(OBJ_FILES) $(LD_FILES) $(OUT_DIR)
|
|
|
|
$(LD) $(LDFLAGS) -o $@ -T $(LD_FILES) -Map $(OUT_DIR)/$(OUT_MAP) $(OBJ_FILES)
|
2022-11-27 06:38:23 +09:00
|
|
|
|
2023-02-10 23:20:40 +09:00
|
|
|
$(OBJ_FILES): $(SRC_FILES) check-set-GAME_VERSION #check-set-TARGET_VERSION
|
2022-11-27 12:57:16 +09:00
|
|
|
$(CC) $(CFLAGS) -D VERSION=$(TARGET_VERSION) -I $(INC_DIR) -o $@ -c $(@:.o=.c)
|
2022-11-27 06:38:23 +09:00
|
|
|
|
2023-02-10 23:20:40 +09:00
|
|
|
$(OUT_DIR)/$(OUT_LOADER_TXT): $(OUT_DIR)/$(OUT_BIN) $(OUT_DIR)/$(OUT_MAP) $(GECKO_FILE_LOADER) | $(OUT_DIR)
|
|
|
|
$(BIN2GCT) hook:$(OUT_DIR)/$(OUT_MAP):$(OUT_DIR)/$(OUT_BIN):onReadOptionBlock C0:$(GECKO_FILE_LOADER) > $@
|
|
|
|
$(GECKO_FILES):
|
|
|
|
$(MAKE) -C$(GECKO_DIR) OUT_DIR=$(GECKO_OUT_DIR) $(patsubst $(GECKO_DIR)/%,%,$@)
|
|
|
|
|
2022-11-27 06:38:23 +09:00
|
|
|
$(OUT_DIR):
|
|
|
|
mkdir -p $@
|
|
|
|
|
2022-11-27 12:57:16 +09:00
|
|
|
check-set-%:
|
|
|
|
@ if [ "${${*}}" = "" ]; then \
|
|
|
|
echo "Variable $* not set"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
2022-11-27 06:38:23 +09:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2023-02-10 23:20:40 +09:00
|
|
|
$(RM) -rv $(OUT_DIR) $(OBJ_FILES)
|
|
|
|
$(MAKE) -C$(GECKO_DIR) $@
|