summaryrefslogtreecommitdiff
path: root/arm9/lib/Makefile
blob: 51c030759a0f2fbf0f376c37de1c542f824e5e34 (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
82
83
84
85
86
87
88
89
90
91
# Try to include devkitarm if installed
TOOLCHAIN := $(DEVKITARM)

ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools
endif

# If you are using WSL, it is recommended you build with NOWINE=1.
WSLENV ?= no
ifeq ($(WSLENV),)
NOWINE = 1
else
NOWINE = 0
endif

ifeq ($(OS),Windows_NT)
EXE := .exe
WINE :=
else
EXE :=
WINE := wine
endif

ifeq ($(NOWINE),1)
WINE :=
endif

# Compare result of arm9, arm7, and ROM to sha1 hash(s)
COMPARE ?= 1

##################### Compiler Options #######################

MWCCVERSION = 1.2/sp2p3

CROSS   := arm-none-eabi-

MWCCARM  = ../../tools/mwccarm/$(MWCCVERSION)/mwccarm.exe
# Argh... due to EABI version shenanigans, we can't use GNU LD to link together
# MWCC built objects and GNU built ones. mwldarm, however, doesn't care, so we
# have to use mwldarm for now.
# TODO: Is there a hack workaround to let us go back to GNU LD? Ideally, the
# only dependency should be MWCCARM.
MWLDARM  = ../../tools/mwccarm/$(MWCCVERSION)/mwldarm.exe
MWASMARM = ../../tools/mwccarm/$(MWCCVERSION)/mwasmarm.exe
SCANINC = ../../tools/scaninc/scaninc$(EXE)

AS      = $(WINE) $(MWASMARM)
CC      = $(WINE) $(MWCCARM)
CPP     := cpp -P
LD      = $(WINE) $(MWLDARM)
AR      := $(CROSS)ar
OBJDUMP := $(CROSS)objdump
OBJCOPY := $(CROSS)objcopy

# ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o
MWASFLAGS = -proc arm5te -ir ../..
MWCFLAGS = -O4,p -proc arm946e -fp soft -lang c99 -Cpp_exceptions off -i include -ir include-mw -ir arm9/lib/libc/include -ir arm9/lib/libnns/include -ir arm9/lib/NitroSDK/include -W all
MWLDFLAGS = -library -nodead -w off -proc v5te -interworking -pic
ARFLAGS = rcS

export MWCIncludes := libc/include libnns/include NitroSDK/include

################ Targets #################

LIBS := libsyscall.a
.PHONY: all clean

all: libs $(LIBS)
	@:

libs:
	$(MAKE) -C libc
	$(MAKE) -C libnns
	$(MAKE) -C NitroSDK

clean:
	$(MAKE) clean -C libc
	$(MAKE) clean -C libnns
	$(MAKE) clean -C NitroSDK
	$(RM) $(LIBS)

libsyscall.a: syscall/_svc_mw.o

%.a:
	$(AR) $(ARFLAGS) -o $@ $^

%.o: %.c
	$(CC) $(MWCFLAGS) -o $@ $<

%.o: %.s
	$(AS) $(MWASFLAGS) -o $@ $<