Files
tp/Makefile
T

193 lines
4.6 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
2021-12-02 23:38:37 +01:00
BUILD_PATH := build
BUILD_DIR := $(BUILD_PATH)/$(TARGET)
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
2022-01-11 20:20:58 -07:00
DOL_SHIFT := $(BUILD_DIR)/main_shift.dol
2020-08-29 17:54:55 -04:00
ELF := $(DOL:.dol=.elf)
2022-01-11 20:20:58 -07:00
ELF_SHIFT := $(DOL_SHIFT:.dol=.elf)
2020-08-29 17:54:55 -04:00
MAP := $(BUILD_DIR)/dolzel2.map
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
ifeq ($(WINDOWS),1)
WINE :=
else
WINE := wine
endif
2020-09-01 17:26:31 -07:00
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
2021-06-13 19:47:12 -04:00
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
OBJCOPY := $(DEVKITPPC)/bin/powerpc-eabi-objcopy
STRIP := $(DEVKITPPC)/bin/powerpc-eabi-strip
2021-12-02 23:38:37 +01:00
CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc_patched.exe
2021-06-13 19:47:12 -04:00
LD := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwldeppc.exe
2021-12-02 23:38:37 +01:00
ELF2DOL := $(BUILD_PATH)/elf2dol
2021-06-13 19:47:12 -04:00
PYTHON := python3
2021-12-02 23:38:37 +01:00
ICONV := iconv
2021-06-13 19:47:12 -04:00
DOXYGEN := doxygen
2021-12-02 23:38:37 +01:00
MAKEREL := tools/makerel.py
2021-06-13 19:47:12 -04:00
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
# elf2dol needs to know these in order to calculate sbss correctly.
SDATA_PDHR := 9
SBSS_PDHR := 10
#-------------------------------------------------------------------------------
# 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
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: $(ELF2DOL)
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
2021-12-02 23:38:37 +01:00
@$(PYTHON) $(MAKEREL) build --string-table $(BUILD_DIR)/frameworkF.str $(RELS) $(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)
@cp -v $(ELF_SHIFT) $(ELF)
2022-01-11 20:20:58 -07:00
$(DOL_SHIFT): $(ELF_SHIFT) | tools
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
@cp -v $(DOL_SHIFT) $(DOL)
2022-01-11 20:20:58 -07:00
shift: dirs $(DOL_SHIFT)
2022-01-15 17:59:59 -07:00
game: | shift rels
@mkdir -p game
@$(PYTHON) tools/package_game_assets.py game $(BUILD_DIR)
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
2021-04-06 18:00:35 +02:00
#
$(BUILD_DIR)/%.o: %.cpp
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) -c -o $@ $(basename $@).cpp
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
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-01-15 17:59:59 -07:00
.PHONY: default all dirs clean tools docs shift game rungame print-%