-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
61 lines (41 loc) · 1.41 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
#----------------------------#
PATH := /x/Tools/GCCARM/bin:$(PATH)
#----------------------------#
SOURCES := source source/res source/sys source/ulc
INCLUDES := include
BUILD := build
TARGET := ulcplayer
#----------------------------#
ARCHCROSS := arm-none-eabi-
ARCHFLAGS := -mcpu=arm7tdmi -mtune=arm7tdmi -mthumb-interwork -mlong-calls
INCLUDEFLAGS := $(foreach dir, $(INCLUDES), -I$(dir))
CCFLAGS := $(ARCHFLAGS) $(INCLUDEFLAGS) -O2 -Wall -Wextra
ASFLAGS := $(ARCHFLAGS) $(INCLUDEFLAGS) -x assembler-with-cpp
LDFLAGS := $(ARCHFLAGS)
CFILES := $(foreach dir, $(SOURCES), $(notdir $(wildcard $(dir)/*.c)))
SFILES := $(foreach dir, $(SOURCES), $(notdir $(wildcard $(dir)/*.s)))
OFILES := $(addprefix $(BUILD)/, $(CFILES:.c=.c.o) $(SFILES:.s=.s.o))
VPATH := $(SOURCES)
#----------------------------#
CC := $(ARCHCROSS)gcc
AS := $(ARCHCROSS)gcc
LD := $(ARCHCROSS)gcc
NM := $(ARCHCROSS)nm
OBJCOPY := $(ARCHCROSS)objcopy
#----------------------------#
all : $(TARGET).gba
$(TARGET).gba : $(BUILD)/$(TARGET).elf | $(BUILD)
$(NM) -S -n $< > MemoryMap.txt
$(OBJCOPY) -O binary $< $@
$(BUILD)/$(TARGET).elf : $(OFILES) | $(BUILD)
$(LD) -nostdlib -T agb.ld -o $@ $^
$(BUILD)/%.c.o : %.c | $(BUILD)
$(CC) $(CCFLAGS) -c -o $@ $<
$(BUILD)/%.s.o : %.s | $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ $<
$(BUILD):; mkdir -p $@
#----------------------------#
.PHONY : clean
clean:
rm -rf $(BUILD) $(TARGET).gba
#----------------------------#