summaryrefslogtreecommitdiff
path: root/Makefile
blob: b7ac205f3609e2b846ea66b3e972eacd2d0e1197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
NAME := pso-gc

BUILD_DIR := build/$(NAME)

DOL := $(BUILD_DIR)/PsoV3.dol
ELF := $(DOL:.dol=.elf)

WINE := wine
export WINEDEBUG ?= -all
DEVKITPPC := /opt/devkitpro/devkitPPC

MWCC_VERSION := 1.3.2
MWLD_VERSION := 1.3.2

ASM_INPUTS := $(wildcard asm/*.s)
C_INPUTS := $(wildcard src/*.c)
CPP_INPUTS := $(wildcard src/*.cpp)
LDSCRIPT := $(BUILD_DIR)/ldscript.lcf

AS := $(DEVKITPPC)/bin/powerpc-eabi-as
CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp -P

CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe
LD := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwldeppc.exe

INCLUDES := -i include -i include/dolphin -i include/libc
ASM_INCLUDES := -I include/

ifdef LD_TEST
TEST_LD := -DLD_TEST
else
TEST_LD :=
endif

LDFLAGS := -fp hard -nodefaults

ASFLAGS := -mgekko $(ASM_INCLUDES)

CFLAGS_BASE := -I- $(INCLUDES) $(TEST_LD) -nodefaults -proc gekko -fp hard -O4 -use_lmw_stmw on -str reuse -rostr -sdata2 4

CFLAGS := $(CFLAGS_BASE)
CXXFLAGS := $(CFLAGS_BASE) -Cpp_exceptions off -RTTI off

include obj_files.mk

$(BUILD_DIR)/src/pso/TProtocol.o: CXXFLAGS += -inline none

ALL_DIRS := $(sort $(dir $(O_FILES)))

default: all

all: $(ELF)

DUMMY != mkdir -p $(ALL_DIRS)

$(LDSCRIPT): ldscript.lcf
	$(CPP) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<

clean:
	rm -f -d -r build
	find . -name '*.o' -exec rm {} +

$(ELF): $(O_FILES) $(LDSCRIPT)
	@echo $(O_FILES) > build/o_files
	$(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files

$(BUILD_DIR)/%.o: %.s
	@echo Assembling $<
	$(QUIET) $(AS) $(ASFLAGS) -o $@ $<

$(BUILD_DIR)/%.o: %.c
	@echo "Compiling " $<
	$(QUIET) $(CC) -lang=c $(CFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<

$(BUILD_DIR)/%.o: %.cp
	@echo "Compiling " $<
	$(QUIET) $(CC) $(CXXFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<

$(BUILD_DIR)/%.o: %.cpp
	@echo "Compiling " $<
	$(QUIET) $(CC) -lang=c++ $(CXXFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<