Files
tp/Makefile
T

261 lines
7.3 KiB
Makefile
Raw Normal View History

2020-09-01 17:26:31 -07:00
WINDOWS := $(shell which wine ; echo $$?)
2021-01-01 22:41:40 -08:00
UNAME_S := $(shell uname -s)
2021-01-18 13:16:09 -06:00
#-------------------------------------------------------------------------------
# Options
#-------------------------------------------------------------------------------
DEBUG ?= 0
ifeq ($(DEBUG), 1)
CFLAGS += -g
else
CFLAGS +=
endif
2020-08-29 17:54:55 -04:00
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
TARGET_COL := wii
TARGET := dolzel2
BUILD_PATH := build
BUILD_DIR := $(BUILD_PATH)/$(TARGET)
TARGET_ISO := $(BUILD_DIR)/dolzel2.iso
2020-08-29 17:54:55 -04:00
2020-11-28 19:18:27 -05:00
SRC_DIRS := $(shell find src/ libs/ -type f -name '*.cpp')
ASM_DIRS := $(shell find asm/ -type f -name '*.s')
2020-08-29 17:54:55 -04:00
# Inputs
LDSCRIPT := $(BUILD_DIR)/ldscript.lcf
# Outputs
DOL := $(BUILD_DIR)/main.dol
DOL_SHIFT := $(BUILD_DIR)/main_shift.dol
ELF := $(DOL:.dol=.elf)
ELF_SHIFT := $(DOL_SHIFT:.dol=.elf)
MAP := $(BUILD_DIR)/dolzel2.map
2020-08-29 17:54:55 -04:00
2021-03-28 22:49:05 +02:00
# include list of object files
2021-12-02 23:38:37 +01:00
include obj_files.mk
2020-08-29 17:54:55 -04:00
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
MWCC_VERSION := 2.7
2020-08-29 17:54:55 -04:00
# Programs
2022-12-24 12:47:48 -07:00
ifeq ($(WINE),) #if WINE varible is unset (wine can be replaced with a less bloated translation layer such as wibo if needed)
2020-08-29 17:54:55 -04:00
ifeq ($(WINDOWS),1)
WINE :=
else
WINE := wine
endif
2022-12-24 12:47:48 -07:00
endif
2020-09-01 17:26:31 -07:00
2022-12-31 19:18:40 -07:00
ifeq ($(WINE_LD),)
WINE_LD := $(WINE)
endif
2021-01-01 22:41:40 -08:00
# Hack for OSX
ifeq ($(UNAME_S),Darwin)
CPP := cpp-10 -P
SHA1SUM := shasum -a 1
else
CPP := cpp -P
SHA1SUM := sha1sum
endif
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
OBJCOPY := $(DEVKITPPC)/bin/powerpc-eabi-objcopy
STRIP := $(DEVKITPPC)/bin/powerpc-eabi-strip
CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc_modded.exe
DOLPHIN_LIB_CC := $(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe
FRANK_CC := $(WINE) tools/mwcc_compiler/1.2.5e/mwcceppc.exe
LD := $(WINE_LD) tools/mwcc_compiler/$(MWCC_VERSION)/mwldeppc.exe
ELF2DOL := $(BUILD_PATH)/elf2dol
YAZ0 := $(BUILD_PATH)/yaz0.so
PYTHON := python3
ICONV := iconv
DOXYGEN := doxygen
MAKEREL := tools/makerel.py
FRANK := tools/frank.py
IMAGENAME := gz2e01.iso
2020-08-29 17:54:55 -04:00
# Options
INCLUDES := -i include -i include/dolphin/ -i src
2020-08-29 17:54:55 -04:00
# Assembler flags
2020-08-29 17:54:55 -04:00
ASFLAGS := -mgekko -I include
# Linker flags
2021-03-31 23:22:32 +02:00
LDFLAGS := -unused -map $(MAP) -fp hard -nodefaults -w off
# Compiler flags
2022-01-04 18:18:23 +01:00
CFLAGS += -Cpp_exceptions off -proc gekko -fp hard -O3 -nodefaults -str pool,readonly,reuse -RTTI off -maxerrors 5 -enum int $(INCLUDES)
2020-08-29 17:54:55 -04:00
DEPFLAGS := $(if $(DISABLE_DEPS),,-MD)
2022-04-24 04:02:50 -07:00
# O4,p for init.c
$(BUILD_DIR)/src/init.o: CFLAGS := -Cpp_exceptions off -proc gekko -fp hard -O4,p -nodefaults -str pool,readonly,reuse -RTTI off -maxerrors 5 -enum int $(INCLUDES)
# __start.c needs mwcc 1.2.5 and O4,p
$(BUILD_DIR)/src/__start.o: CFLAGS := -Cpp_exceptions off -proc gekko -fp hard -O4,p -nodefaults -str pool,readonly,reuse -RTTI off -maxerrors 5 -enum int $(INCLUDES)
$(BUILD_DIR)/src/__start.o: MWCC_VERSION := 1.2.5
$(BUILD_DIR)/src/__start.o: CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe
2022-04-24 04:02:50 -07:00
2020-08-29 17:54:55 -04:00
# elf2dol needs to know these in order to calculate sbss correctly.
SDATA_PDHR := 9
SBSS_PDHR := 10
2020-08-29 17:54:55 -04:00
#-------------------------------------------------------------------------------
# Recipes
#-------------------------------------------------------------------------------
### Default target ###
default: all
2022-01-11 21:12:44 -07:00
dol: $(DOL)
2022-01-11 20:20:58 -07:00
$(SHA1SUM) -c $(TARGET).sha1
2022-01-11 21:12:44 -07:00
all: dirs dol
2020-08-29 17:54:55 -04:00
# Make sure build directory exists before compiling anything
2021-01-01 22:41:40 -08:00
dirs:
2021-12-02 23:38:37 +01:00
@mkdir -p build
@mkdir -p $(BUILD_DIR)
2020-08-29 17:54:55 -04:00
$(DOL): $(ELF) | tools
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
clean:
2021-12-02 23:38:37 +01:00
rm -f -d -r $(BUILD_DIR)/libs
rm -f -d -r $(BUILD_DIR)/src
rm -f $(ELF)
rm -f $(DOL)
2022-01-17 20:19:43 -07:00
rm -f $(ELF_SHIFT)
rm -f $(DOL_SHIFT)
2021-12-02 23:38:37 +01:00
rm -f $(BUILD_DIR)/*.a
2020-08-29 17:54:55 -04:00
2022-01-17 20:19:43 -07:00
clean_game:
rm -r -f -d $(TARGET)/game
2022-12-30 17:45:12 -07:00
rm -r -f -d $(TARGET_ISO)
2022-01-17 20:19:43 -07:00
clean_assets:
rm -r -f -d game
2021-12-02 23:38:37 +01:00
clean_all:
rm -f -d -r build
clean_rels:
rm -f -d -r $(BUILD_DIR)/rel
rm -f $(BUILD_PATH)/*.rel
tools: dirs $(ELF2DOL) $(YAZ0)
2020-08-29 17:54:55 -04:00
2021-06-13 19:47:12 -04:00
assets:
2022-01-15 17:59:59 -07:00
@mkdir -p game
2021-12-02 23:38:37 +01:00
@cd game; $(PYTHON) ../tools/extract_game_assets.py ../$(IMAGENAME)
2021-06-13 19:47:12 -04:00
2021-01-18 13:00:28 -06:00
docs:
$(DOXYGEN) Doxyfile
2021-03-28 22:49:05 +02:00
2021-04-06 18:00:35 +02:00
rels: $(ELF) $(RELS)
@echo generating RELs from .plf
@echo $(RELS) > build/plf_files
$(PYTHON) $(MAKEREL) build --string-table $(BUILD_DIR)/frameworkF.str @build/plf_files $(ELF)
2021-03-28 22:49:05 +02:00
$(ELF): $(LIBS) $(O_FILES)
2021-04-06 18:00:35 +02:00
@echo $(O_FILES) > build/o_files
2021-12-02 23:38:37 +01:00
@$(PYTHON) tools/lcf.py dol --output $(LDSCRIPT)
2021-03-31 23:22:32 +02:00
$(LD) -application $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files $(LIBS)
2020-08-29 17:54:55 -04:00
2022-01-16 15:16:08 -07:00
$(ELF_SHIFT): $(DOL)
2022-01-11 20:20:58 -07:00
@echo $(O_FILES) > build/o_files
2022-01-11 21:12:44 -07:00
@$(PYTHON) tools/lcf.py dol_shift --output $(LDSCRIPT)
2022-01-11 20:20:58 -07:00
$(LD) -application $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files $(LIBS)
$(DOL_SHIFT): $(ELF_SHIFT) | tools
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
2023-01-24 18:59:02 -05:00
2022-01-11 20:20:58 -07:00
shift: dirs $(DOL_SHIFT)
shiftedrels: shift
@echo generating shifted RELs from .plf
@echo $(RELS) > build/plf_files
$(PYTHON) $(MAKEREL) build --string-table $(BUILD_DIR)/frameworkF.str @build/plf_files $(ELF_SHIFT)
game: shiftedrels
2022-01-15 17:59:59 -07:00
@mkdir -p game
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode native
game-fast: shiftedrels
@mkdir -p game
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode oead
2023-01-23 20:45:57 -07:00
game-nocompile:
@mkdir -p game
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode native
game-nocompile-fast:
@mkdir -p game
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode oead
2023-01-23 20:45:57 -07:00
rungame-nocompile: game-nocompile
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
2022-12-30 17:45:12 -07:00
rungame-nocompile-fast: game-nocompile-fast
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
rungame-fast: game-fast
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
rungame: game
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
2022-12-30 17:45:12 -07:00
iso: game
@$(PYTHON) tools/packageISO.py $(BUILD_DIR)/game/ $(TARGET_ISO)
2022-01-15 17:59:59 -07:00
$(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.d
2022-04-24 04:02:50 -07:00
@mkdir -p $(@D)
@echo building... $<
@$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c
@$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $(dir $@) $(basename $@).c
@if [ -z '$(DISABLE_DEPS)' ]; then tools/transform-dep.py '$(basename $@).d' '$(basename $@).d'; touch -c $@; fi
2022-04-24 04:02:50 -07:00
$(BUILD_DIR)/%.o: %.cpp $(BUILD_DIR)/%.d
2021-03-28 22:49:05 +02:00
@mkdir -p $(@D)
@echo building... $<
2021-12-02 23:38:37 +01:00
@$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).cpp
@$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $(dir $@) $(basename $@).cpp
@if [ -z '$(DISABLE_DEPS)' ]; then tools/transform-dep.py '$(basename $@).d' '$(basename $@).d'; touch -c $@; fi
ifndef DISABLE_DEPS
D_FILES := $(O_FILES:.o=.d)
$(D_FILES):
include $(wildcard $(D_FILES))
endif
2021-03-28 22:49:05 +02:00
2021-04-06 18:00:35 +02:00
# shared cpp files for RELs
$(BUILD_DIR)/rel/%.o: rel/%.cpp
@mkdir -p $(@D)
$(CC) $(CFLAGS) -sdata 0 -sdata2 0 -c -o $@ $<
2021-03-28 22:49:05 +02:00
# include library and rel makefiles
-include include_link.mk
2020-08-29 17:54:55 -04:00
2021-12-02 23:38:37 +01:00
# tools
include tools/elf2dol/Makefile
2023-01-24 21:41:20 -07:00
include tools/yaz0/Makefile
2021-12-02 23:38:37 +01:00
2020-08-29 17:54:55 -04:00
### Debug Print ###
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
2021-01-18 13:00:28 -06:00
2022-12-30 17:45:12 -07:00
.PHONY: default all dirs clean tools docs shift game rungame iso print-%