This repository has been archived by the owner on Dec 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (67 loc) · 2.87 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
################################################################################
# These are variables for the GBA toolchain build
# You can add others if you wish to
################################################################################
# The name of your desired GBA game
# This should be a just a name i.e MyFirstGBAGame
# No SPACES AFTER THE NAME.
PROGNAME = PacManTheLostLevels
# The object files you want to compile into your program
# This should be a space (SPACE!) separated list of .o files
OFILES = main.o myLib.o ghost.o end.o title.o Pacman.o text.o
# The header files you have created.
# This is necessary to determine when to recompile for files.
# This should be a space (SPACE!) separated list of .h files
HFILES = myLib.h colors.h dma.h buttons.h dot.h ghost.h end.h title.h rect.h Pacman.h animation.h text.h
# The flags to run the vba program with
# for a list of options run /usr/local/cs2110-tools/bin/vbam
# Most notable ones are -f0 -f1 -f13 -f15
# -f0 : Stretch 1x
# -f1 : Stretch 2x
# -f13 : Stretch 3x
# -f15 : Stretch 4x
VBAOPT = -f1
################################################################################
# These are various settings used to make the GBA toolchain work
# DO NOT EDIT BELOW.
################################################################################
TOOLDIR = /usr/local/cs2110-tools
CFLAGS = -Wall -Werror -std=c99 -pedantic -O2
CFLAGS += -mthumb-interwork -mlong-calls -nostartfiles
LDFLAGS = -L $(TOOLDIR)/lib \
-L $(TOOLDIR)/lib/gcc/arm-thumb-eabi/4.4.1/thumb \
-L $(TOOLDIR)/arm-thumb-eabi/lib \
--script $(TOOLDIR)/arm-thumb-eabi/lib/arm-gba.ld
CC = $(TOOLDIR)/bin/arm-thumb-eabi-gcc
AS = $(TOOLDIR)/bin/arm-thumb-eabi-as
LD = $(TOOLDIR)/bin/arm-thumb-eabi-ld
OBJCOPY = $(TOOLDIR)/bin/arm-thumb-eabi-objcopy
GDB = $(TOOLDIR)/bin/arm-thumb-eabi-gdb
GBADEPS = gbadeps
CFILES = $(OFILES:.o=.c)
################################################################################
# These are the targets for the GBA build system
################################################################################
all: $(GBADEPS) $(PROGNAME).gba
$(PROGNAME).gba: $(PROGNAME).elf
@echo "[LINK] Creating $(PROGNAME).gba"
@$(OBJCOPY) -O binary $(PROGNAME).elf $(PROGNAME).gba
$(PROGNAME).elf: crt0.o $(OFILES)
@echo "[LINK] Linking files together to create $(PROGNAME).elf"
@$(LD) $(LDFLAGS) -o $(PROGNAME).elf $^ -lgcc -lc -lgcc
crt0.o: $(TOOLDIR)/arm-thumb-eabi/lib/crt0.s
@$(AS) -mthumb-interwork $^ -o crt0.o
%.o: %.c
@echo "[COMPILE] Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
clean:
@echo "Removing all .o .elf and .gba files"
@rm -f *.o *.elf *.gba $(GBADEPS)
vba: all
@echo "[RUN] Running Visual Boy Advance"
@$(TOOLDIR)/bin/vbam $(VBAOPT) $(PROGNAME).gba > /dev/null
rebuild: clean all
rebuildvba: clean vba
$(GBADEPS): $(CFILES) $(HFILES)
@$(CC) $(CFLAGS) -MM $(CFILES) > $(GBADEPS)
-include $(GBADEPS)