-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (82 loc) · 3.4 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
################################################################################
# These are variables for the GBA toolchain build
# You can add others if you wish to
# Name: Nick Keller
################################################################################
# The name of your desired GBA game
# This should be a just a name i.e MyFirstGBAGame
# No SPACES AFTER THE NAME.
PROGNAME = Snake
# 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 list.o LosingScreen.o WinningScreen.o WelcomeScreen.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 list.h LosingScreen.h WinningScreen.h WelcomeScreen.h
################################################################################
# These are various settings used to make the GBA toolchain work
# DO NOT EDIT BELOW.
################################################################################
TOOLDIR = /usr/local/cs2110-tools
ARMLIB = $(TOOLDIR)/arm-thumb-eabi/lib
CFLAGS = -Wall -std=c99 -pedantic
CFLAGS += -mthumb-interwork -mlong-calls -nostartfiles -MMD -MP -I $(TOOLDIR)/include
LDFLAGS = -L $(TOOLDIR)/lib \
-L $(TOOLDIR)/lib/gcc/arm-thumb-eabi/4.4.1/thumb \
-L $(ARMLIB) \
--script $(ARMLIB)/arm-gba.ld
LDDEBUG = -L $(TOOLDIR)/lib -lgbaio
CDEBUG = -g -DDEBUG
CRELEASE = -O2
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
CFILES = $(OFILES:.o=.c)
################################################################################
# These are the targets for the GBA build system
################################################################################
all : CFLAGS += $(CRELEASE)
all : $(PROGNAME).gba
@echo "[FINISH] Created $(PROGNAME).gba"
.PHONY : all clean
$(PROGNAME).gba : $(PROGNAME).elf
@echo "[LINK] Linking objects together to create $(PROGNAME).gba"
@$(OBJCOPY) -O binary $(PROGNAME).elf $(PROGNAME).gba
$(PROGNAME).elf : crt0.o $(OFILES)
@$(LD) $(LDFLAGS) -o $(PROGNAME).elf $^ -lgcc -lc -lgcc $(LDDEBUG)
@rm -f *.d
crt0.o : $(ARMLIB)/crt0.s
@$(AS) -mthumb-interwork $^ -o crt0.o
%.o : %.c
@echo "[COMPILE] Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
%.o : %.s
@echo "[AS] Assembling $<"
@$(AS) $< -o $@ -mthumb -mthumb-interwork
clean :
@echo "[CLEAN] Removing all compiled files"
@rm -f *.o *.elf *.gba *.d *~
vba : CFLAGS += $(CRELEASE)
vba : $(PROGNAME).gba
@echo "[EXECUTE] Running Emulator VBA-M"
@vbam $(VBAOPT) $(PROGNAME).gba > /dev/null 2> /dev/null
wxvba : CFLAGS += $(CRELEASE)
wxvba : $(PROGNAME).gba
@echo "[EXECUTE] Running Emulator WXVBAM"
@wxvbam $(PROGNAME).gba
med : CFLAGS += $(CRELEASE)
med : $(PROGNAME).gba
@echo "[EXECUTE] Running Emulator MEDNAFEN"
@mednafen $(PROGNAME).gba > /dev/null 2> /dev/null
debugvba : CFLAGS += $(CDEBUG)
debugvba : $(PROGNAME).gba
@echo "[DEBUG] Running game in VBA-M"
@vbam $(VBAOPT) $(PROGNAME).gba
debugwxvba : CFLAGS += $(CDEBUG)
debugwxvba : $(PROGNAME).gba
@echo "[DEBUG] Running game in WXVBAM"
@wxvbam $(PROGNAME).gba
-include $(CFILES:%.c=%.d)