pikmin2/Makefile

132 lines
3.5 KiB
Makefile
Raw Normal View History

ifneq ($(findstring MINGW,$(shell uname)),)
WINDOWS := 1
endif
ifneq ($(findstring MSYS,$(shell uname)),)
WINDOWS := 1
endif
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
NAME := pikmin2
VERSION := usa
#VERSION := usa.demo
BUILD_DIR := build/$(NAME).$(VERSION)
# Inputs
S_FILES := $(wildcard asm/*.s)
C_FILES := $(wildcard src/*.c)
CPP_FILES := $(wildcard src/*.cpp)
CPP_FILES += $(wildcard src/*.cp)
LDSCRIPT := $(BUILD_DIR)/ldscript.lcf
2021-10-23 00:07:01 +01:00
READMEGEN := tools/UpdateReadme.exe
# Outputs
DOL := $(BUILD_DIR)/main.dol
ELF := $(DOL:.dol=.elf)
2021-10-21 14:06:39 -04:00
MAP := $(BUILD_DIR)/pikmin2UP.MAP
include obj_files.mk
O_FILES := $(GROUP_0_FILES) $(JSYSTEM) $(DOLPHIN)\
$(YAMASHITA) $(KANDO) $(NISHIMURA) $(OGAWA) $(HIKINO) $(MORIMURA) $(EBISAWA) $(KONO)\
$(BOOTUP) $(COMMON) $(GC) $(UTILITY)
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
MWCC_VERSION := 2.6
2021-11-06 21:33:59 -05:00
MWLD_VERSION := 2.6
# Programs
ifeq ($(WINDOWS),1)
WINE :=
AS := $(DEVKITPPC)/bin/powerpc-eabi-as.exe
CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp.exe -P
else
2021-11-06 21:33:59 -05:00
WINE ?= wine
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp -P
endif
2021-10-03 16:01:08 -04:00
CC = $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe
LD := $(WINE) tools/mwcc_compiler/$(MWLD_VERSION)/mwldeppc.exe
ELF2DOL := tools/elf2dol
SHA1SUM := sha1sum
2021-11-06 21:33:59 -05:00
PYTHON := python3
2021-10-09 15:31:31 -04:00
# POSTPROC := tools/postprocess.py
# Options
INCLUDES := -i include/
ASFLAGS := -mgekko -I include/
# this set of LDFLAGS generates a mapfile and makes linking take several minutes.
# LDFLAGS := -map $(MAP) -fp hard -nodefaults
# this set of LDFLAGS is faster, but does not generate a mapfile.
# LDFLAGS := -fp hard -nodefaults
# this set of LDFLAGS is faster, but does not generate a mapfile. Generates no warnings.
LDFLAGS := -fp hard -nodefaults -w off
2021-11-12 20:22:09 -05:00
CFLAGS := -Cpp_exceptions off -inline auto -proc gekko -RTTI off -fp hard -fp_contract on -rostr -O4,p -use_lmw_stmw on -sdata 8 -sdata2 8 -nodefaults -msgstyle gcc $(INCLUDES)
# for postprocess.py
2021-10-09 15:31:31 -04:00
# PROCFLAGS := -fsymbol-fixup
2021-10-03 15:56:42 -04:00
$(BUILD_DIR)/src/Dolphin/dvdFatal.o: MWCC_VERSION := 1.0
$(BUILD_DIR)/src/Dolphin/__start.o: MWCC_VERSION := 1.0
2021-11-10 18:26:33 -05:00
$(BUILD_DIR)/src/Dolphin/OSLink.o: MWCC_VERSION := 1.0
2021-10-03 15:56:42 -04:00
#-------------------------------------------------------------------------------
# Recipes
#-------------------------------------------------------------------------------
### Default target ###
default: all
all: $(DOL)
ALL_DIRS := $(sort $(dir $(O_FILES)))
# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $(ALL_DIRS)
.PHONY: tools
$(LDSCRIPT): ldscript.lcf
$(CPP) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<
$(DOL): $(ELF) | tools
2021-11-06 21:56:40 -05:00
$(ELF2DOL) $< $@
$(SHA1SUM) -c sha1/$(NAME).$(VERSION).sha1
ifneq ($(findstring -map,$(LDFLAGS)),)
2021-10-07 17:56:53 +01:00
$(PYTHON) calcprogress.py $@
endif
2021-10-23 00:07:01 +01:00
./$(READMEGEN)
clean:
rm -f -d -r build
$(MAKE) -C tools clean
tools:
$(MAKE) -C tools
$(ELF): $(O_FILES) $(LDSCRIPT)
@echo $(O_FILES) > build/o_files
$(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD_DIR)/%.o: %.cpp
$(CC) $(CFLAGS) -c -o $@ $<
### Debug Print ###
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true