-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.gba
87 lines (66 loc) · 2.51 KB
/
Makefile.gba
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
# path to gcc arm and other files - they are not all pd so simpler to not include them
GCCPATH=d:/work/devkitPro/devkitARM/bin
GBASPEC=$(GCCPATH)/../arm-none-eabi/lib/gba.specs
GBALINK=$(GCCPATH)/../arm-none-eabi/lib/gba_cart.ld
GBACRT=$(GCCPATH)/../arm-none-eabi/lib/gba_crt0.o
# path to VgmComp2 (needed on GBA for sound emulation)
VGMCOMP2=d:/work/ti/vgmcomp2/Players/libgbavgm2
# gba specific
GBAFIX=$(GCCPATH)/../../tools/bin/gbafix.exe
# Full paths to the executables used
GAS=$(GCCPATH)/arm-none-eabi-as.exe
LD=$(GCCPATH)/arm-none-eabi-ld.exe
CC=$(GCCPATH)/arm-none-eabi-gcc.exe
AR=$(GCCPATH)/arm-none-eabi-ar.exe
OBJCOPY=$(GCCPATH)/arm-none-eabi-objcopy.exe
C_FLAGS=\
-g -Wall -O2 -Xlinker -Map=output.map\
-mcpu=arm7tdmi -mtune=arm7tdmi -fsigned-char \
-save-temps -funroll-loops -fno-builtin \
-fsigned-char -DBUILD_GBA \
-DPRINTF_DISABLE_SUPPORT_FLOAT -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL \
-DPRINTF_DISABLE_SUPPORT_LONG_LONG -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T \
-DUSE_SN_PSG -DGBA -I../ -I$(VGMCOMP2) -I$(VGMCOMP2)/../CPlayer \
-mthumb -mthumb-interwork -fno-delete-null-pointer-checks
RM = cmd //c del
LDFLAGS = -g -mthumb -mthumb-interwork -Wl,-Map,$(notdir $*.map) -L. -L$(VGMCOMP2)/build -Wl,--wrap=main
LIBS = -l:libti99_gba.a -l:libgbavgm2.a
# extension on output files
EXT=o
# output file
NAME=libti99_gba.a
include ../Makefile.sources
# these files are not included as GCC has better ones
# str_memcmp.$(EXT)
# str_memcpy.$(EXT)
# str_memmove.$(EXT)
# str_memset.$(EXT)
# str_strcmp.$(EXT)
# str_strcpy.$(EXT)
# str_strlen.$(EXT)
# str_strncpy.$(EXT)
# this one I need to figure out how to override...
# vdp_puts.$(EXT)
OBJECT_LIST+=vdp_puts.$(EXT)
OBJECT_LIST+=gba_intwrap.$(EXT)
# Recipe to compile the library
all: library example.gba test.gba
library: $(OBJECT_LIST)
$(RM) testlib.$(EXT) testlib.asm
$(AR) -rcs $(NAME) $(OBJECT_LIST)
test.gba: test.elf
$(OBJCOPY) -O binary $< $@
$(GBAFIX) $@
test.elf: library testlib.$(EXT) $(GBACRT)
$(CC) $(LDFLAGS) testlib.$(EXT) -specs=$(GBASPEC) $(LIBS) -o test.elf
example.gba: example.elf
$(OBJCOPY) -O binary $< $@
$(GBAFIX) $@
example.elf: library example.$(EXT) $(GBACRT)
$(CC) $(LDFLAGS) example.$(EXT) -specs=$(GBASPEC) $(LIBS) -o example.elf
# Recipe to compile all assembly files
%.o: ../%.assembly
$(GAS) -g -mthumb -mthumb-interwork $< -o $@
# Recipe to compile all C files
%.o: ../%.c
$(CC) -c $< $(C_FLAGS) $(INCLUDES) -o $@