-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·103 lines (79 loc) · 2.86 KB
/
Makefile
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
92
93
94
95
96
97
98
99
100
101
102
103
VERSION = 2.0
DEVKITPRO ?= $(HOME)/devkitPro
ifeq ($(PLATFORM), win32)
ifeq ($(CROSS),)
DEVKITPRO := /c/devkitPro
endif
endif
DEVKITARM ?= $(DEVKITPRO)/devkitARM
PIMPMOBILE = ./pimpmobile_r1
# only used on Linux
APPDIR ?= $(shell pwd)
CXXFLAGS = -g -DDB_VERSION="\"$(VERSION)\"" -DAPPDIR="\"$(APPDIR)\"" -Wall
AFLAGS = -Iruntime
# options
#CXXFLAGS += -DNDEBUG
CXXFLAGS += -O2
CXXFLAGS += -DBUG_FOR_BUG
CXX = $(CROSS)g++
ARMCC = $(DEVKITARM)/bin/arm-none-eabi-gcc
ARMOBJCOPY = $(DEVKITARM)/bin/arm-none-eabi-objcopy
CRTDIR=$(DEVKITPRO)/devkitARM/lib/gcc/arm-none-eabi/$(shell $(ARMCC) -dumpversion)
LIBS = -lsndfile -lfreeimage
ifeq ($(PLATFORM), win32)
SUFF = .exe
else
SUFF =
endif
BOBJS = DBC.o.$(PLATFORM)
MOBJS = MF.o.$(PLATFORM) MF_mappy.o.$(PLATFORM)
all: win_cross linux
$(MAKE) -C examples
win_cross: runtime.gba runpimp.gba
$(MAKE) _all CROSS=i686-w64-mingw32- PLATFORM=win32
linux: runtime.gba runpimp.gba
if test `uname -s` = Linux ; then $(MAKE) _all PLATFORM=linux ; fi
_all: dbc$(SUFF) mf$(SUFF) converter$(SUFF)
clean:
rm -f dbc.exe dbc mf.exe mf *.o.* run*.gba run*.elf runtime_syms_*.h
rm -f converter converter.exe
rm -f dbapi/dbapi.chm docs/dbapi.chm
$(MAKE) -C $(PIMPMOBILE) clean
$(MAKE) -C examples clean
doc: dbapi/dbapi.chm
cp -p dbapi/dbapi.chm docs/
dbapi/dbapi.chm: dbapi/dbapi.hhp dbapi/dbapi.hhc dbapi/*.htm
cd dbapi ; chmcmd dbapi.hhp
rm -f dbapi/bla.something # WTF?
chmod 644 dbapi/dbapi.chm
mf$(SUFF): $(MOBJS)
$(CXX) -o $@ $(MOBJS) $(LDFLAGS) $(LIBS)
dbc$(SUFF): $(BOBJS)
$(CXX) -o $@ DBC.o.$(PLATFORM) $(LDFLAGS)
DBC.o.$(PLATFORM): DBC.h os.h
MF.o.$(PLATFORM): os.h runtime_syms_pimp.h runtime_syms_rt.h MF.h
$(BOBJS): %.o.$(PLATFORM): %.cpp
$(CXX) -c $(CXXFLAGS) $< -o $@
$(MOBJS): %.o.$(PLATFORM): %.cpp
$(CXX) -c $(CXXFLAGS) $< -o $@
runtime.elf: runtime/runtime.s runtime/runtime_common.s runtime/helpers.c
$(ARMCC) $(AFLAGS) -Ttext=0x8000000 -nostdlib $< runtime/helpers.c -o runtime.elf
runtime.gba: runtime.elf
$(ARMOBJCOPY) -O binary $< $@
runtime_syms_pimp.h: runpimp.elf extract_syms.sh
./extract_syms.sh $< RP >$@
runtime_syms_rt.h: runtime.elf extract_syms.sh
./extract_syms.sh $< RT >$@
runpimp.elf: runtime/runpimp.c runtime/helpers.c runtime/runtime_common.s runtime/gba_crt0.s runtime/gba_cart.ld $(PIMPMOBILE)/lib/libpimp_gba.a
$(ARMCC) $(AFLAGS) -nostdlib -I$(DEVKITPRO)/libgba/include \
-I$(PIMPMOBILE)/include -marm -T runtime/gba_cart.ld runtime/gba_crt0.s $(CRTDIR)/crti.o \
$(CRTDIR)/crtbegin.o $< runtime/helpers.c $(PIMPMOBILE)/lib/libpimp_gba.a -L \
$(DEVKITPRO)/libgba/lib -lgcc -lsysbase -lc -lgba $(CRTDIR)/crtend.o \
$(CRTDIR)/crtn.o -o $@
runpimp.gba: runpimp.elf
$(ARMOBJCOPY) -O binary $< $@
converter$(SUFF):
$(MAKE) -C $(PIMPMOBILE)/converter TARGET=$@ CXX=$(CXX) LD=$(CXX)
cp -p $(PIMPMOBILE)/converter/converter$(SUFF) .
$(PIMPMOBILE)/lib/libpimp_gba.a:
$(MAKE) -C $(PIMPMOBILE) lib/libpimp_gba.a