-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (76 loc) · 3.02 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
################################################################################
# These are variables for the GBA toolchain build
# You can add others if you wish to
# Batshal Regmi
################################################################################
# TA-TODO: Put your application name here.
# This should be a just a name i.e MyFirstGBAProgram
# No SPACES AFTER THE NAME.
PROGNAME = App
# TA-TODO: Add the C files you want compiled here (replace extension with .o)
# OFILES should contain all the object files you want to compile into your
# program. However, feel free to comment the first line out and define the object files
# yourself. For example if you have main.c and myLib.c then in the following
# line you would put main.o and myLib.o.
OFILES := $(shell find . -name '*.c' ! -name 'client.c' | sed 's/\.c/\.o/g')
# OFILES = gba.o font.o main.o images/*.o
################################################################################
# These are various settings used to make the GBA toolchain work
# DO NOT EDIT BELOW.
################################################################################
.PHONY: all
all: CFLAGS += $(CDEBUG) -I../shared
all: LDFLAGS += $(LDDEBUG)
all: $(PROGNAME).gba
@echo "[FINISH] Created $(PROGNAME).gba"
include /opt/cs2110-tools/GBAVariables.mak
LDFLAGS += --specs=nosys.specs
# Adjust default compiler warnings and errors
CFLAGS += -Wstrict-prototypes -Wold-style-definition -Werror=vla
.PHONY: debug
debug: CFLAGS += $(CDEBUG) -I../shared
debug: LDFLAGS += $(LDDEBUG)
debug: $(PROGNAME).gba
@echo "[FINISH] Created $(PROGNAME).gba"
$(PROGNAME).gba: clean $(PROGNAME).elf client
@echo "[LINK] Linking objects together to create $(PROGNAME).gba"
@$(OBJCOPY) -O binary $(PROGNAME).elf $(PROGNAME).gba
$(PROGNAME).elf: crt0.o $(GCCLIB)/crtbegin.o $(GCCLIB)/crtend.o $(GCCLIB)/crti.o $(GCCLIB)/crtn.o $(OFILES) libc_sbrk.o
$(CC) -o $(PROGNAME).elf $^ $(LDFLAGS)
.PHONY: client
client: client.c
@gcc -o client client.c
.PHONY: mgba
mgba: debug
@./client ${PROGNAME}.gba
@echo "[EXECUTE] Running emulator mGBA"
.PHONY: gdb
gdb: debug
@./client ${PROGNAME}.gba gdb
@sleep 1
@echo "[EXECUTE] Attempting to connect to GDB server."
@echo " Make sure mGBA is already running on the host machine!"
@gdb-multiarch -ex 'file $(PROGNAME).elf' -ex 'target remote host.docker.internal:2345'
.PHONY: submit
submit: clean
@rm -f submission.tar.gz
@tar --exclude="examples" -czvf submission.tar.gz *
.PHONY: maze
maze: client
@echo "[EXECUTE] Running emulator mGBA"
@echo " Please see emulator.log if this fails"
@./client examples/maze/Maze.gba
.PHONY: mario
mario: client
@echo "[EXECUTE] Running emulator mGBA"
@echo " Please see emulator.log if this fails"
@./client examples/mario/Mario.gba
.PHONY: pong
pong: client
@echo "[EXECUTE] Running emulator mGBA"
@echo " Please see emulator.log if this fails"
@./client examples/pong/Pong.gba
.PHONY: clean
clean:
@echo "[CLEAN] Removing all compiled files"
rm -f *.o *.elf *.gba *.log */*.o *.sav */*/*.sav client