summaryrefslogtreecommitdiff
path: root/demo/GNUmakefile
blob: b3f038b98c1c74a834c2cd1ded593dfec2e44c01 (plain) (blame)
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
# Copyright 2022-2023 Gabriel Jensen.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.

# TOOLS

AS      := arm-none-eabi-as
CC      := arm-none-eabi-gcc
#CC      := clang --target=arm-none-eabi
LD      := arm-none-eabi-ld
OBJCOPY := arm-none-eabi-objcopy

# TOOL FLAGS

CFLAGS := \
	-I../ax/include \
	-Iinclude       \
	-Oz             \
	-Wall           \
	-Wextra         \
	-Wpedantic      \
	-ffreestanding  \
	-fshort-enums   \
	-mcpu=arm7tdmi  \
	-mthumb         \
	-nostdlib       \
	-std=c2x

LDFLAGS := \
	-L../ax       \
	-Tscript.ld   \
	-znoexecstack

# BINARIES

OBJS := \
	source/chkkeys.o   \
	source/chgcol.o    \
	source/initdat.o   \
	source/initgfx.o   \
	source/loop.o      \
	source/setcolbdr.o \
	source/start.o

ROMHDR := hdr.o

LDLIBS := \
	-lax

IMG := demo.gba

# TARGETS

.PHONY: clean purge

$(IMG): $(ROMHDR) $(OBJS)
	$(LD) $(LDFLAGS) -odemo.elf $(^) $(LDLIBS)
	$(OBJCOPY) -Obinary demo.elf $(@)
	agbsum -psi$(@)

clean:
	$(RM) $(OBJS) $(ROMHDR) demo.elf

purge: clean
	$(RM) $(IMG)