-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (45 loc) · 1.36 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
BINPATH := $(realpath ../SDK/devkitARM/bin)
PATH := $(BINPATH):$(PATH)
# --- Project details -------------------------------------------------
TARGET := test
OBJS := $(TARGET).o
LIBS_S := $(wildcard libs/sources/*.cpp)
LIBS_B := $(addprefix libs/bin/, $(notdir $(LIBS_S)))
LIBS_B := $(LIBS_B:.cpp=.o)
# --- Build defines ---------------------------------------------------
PREFIX := arm-none-eabi-
export CC := $(PREFIX)gcc
export LD := $(PREFIX)gcc
export OBJCOPY := $(PREFIX)objcopy
ARCH := -mthumb-interwork -mthumb
SPECS := -specs=gba.specs
export CFLAGS := $(ARCH) -Wall -fno-strict-aliasing
export LDFLAGS := $(ARCH) $(SPECS)
.PHONY : build clean libs
# --- Build -----------------------------------------------------------
# Build process starts here!
build: $(TARGET).gba
# Strip and fix header (step 3,4)
$(TARGET).gba : $(TARGET).elf
$(OBJCOPY) -v -O binary $< $@
-@gbafix $@
# Link (step 2)
$(TARGET).elf : $(OBJS)
$(LD) $^ $(LIBS_B) $(LDFLAGS) -o $@
$(LIBS_B): $(LIBS_S)
make libs
# Compile (step 1)
$(OBJS) : %.o : %.cpp $(wildcard h/*)
$(CC) -c $< $(CFLAGS) -o $@
# --- Clean -----------------------------------------------------------
clean :
@rm -fv *.gba
@rm -fv *.elf
@rm -fv *.o
cleanlibs:
@rm -fv libs/bin/*
#---- Compile libraries ------------------------------------
libs:
mkdir -p libs/bin
cd libs && $(MAKE)
#EOF