Makefile 2.24 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
# Makefile for pimpmobile module player example

ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
endif

GBAEMU    ?= vba
DEVKITARM  = $(DEVKITPRO)/devkitARM
LIBGBA     = $(DEVKITPRO)/libgba
PIMPMOBILE = ..

12
PREFIX ?= arm-eabi-
13
14
15
16
17
18
19
20
21
22
23
CC      = $(PREFIX)gcc
CXX     = $(PREFIX)g++
OBJCOPY = $(PREFIX)objcopy
STRIP   = $(PREFIX)strip
LD      = $(PREFIX)g++
AS      = $(PREFIX)as
AR      = $(PREFIX)ar

CPPFLAGS = -I$(DEVKITARM)/include -I$(LIBGBA)/include -I$(PIMPMOBILE)/include
CFLAGS   = -mthumb-interwork -mlong-calls
CXXFLAGS = -mthumb-interwork -mlong-calls -fconserve-space -fno-rtti -fno-exceptions
Erik Faye-Lund's avatar
   
Erik Faye-Lund committed
24
LDFLAGS  = -mthumb-interwork -Wl,--gc-section -Wl,-Map,$(basename $@).map -L$(LIBGBA)/lib -lgba
25
26
27
28
29
30
31
ASFLAGS  = -mthumb-interwork

ARM   = -marm
THUMB = -mthumb

OBJS = \
	example.o \
Erik Faye-Lund's avatar
   
Erik Faye-Lund committed
32
	libgbfs.o
33
34

MODULES = \
35
	../testbench/env_sustain.xm
36
37
38
39
40
#	eye.mod \
#	rhino.mod \
#	melkedemo2.mod \
#	hypermmx.xm \
#	eastwing.xm \
41
42

BIN_MODULES = $(MODULES:=.bin)
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

TARGET = ../bin/example.gba
CONVERTER = ../bin/converter

ifeq ($(DEBUG), 1)
	CPPFLAGS += -DDEBUG
	CXXFLAGS += -g3 -ggdb
	CFLAGS   += -g3 -ggdb
else
	CPPFLAGS += -DRELEASE -DNDEBUG
	CXXFLAGS += -O3 -fomit-frame-pointer
	CFLAGS   += -O3 -fomit-frame-pointer
endif
	
.PHONY: all clean run debug

all: $(TARGET)

clean:
62
	$(RM) $(TARGET) $(TARGET:.gba=.elf) $(OBJS) $(OBJS:.o=.d) data.gbfs sample_bank.bin $(BIN_MODULES) *~
63
64
65
66
67
68
69
70

run: $(TARGET)
	$(GBAEMU) $(TARGET)

debug: $(TARGET:.gba=.elf)
	$(DEVKITPRO)/insight/bin/arm-elf-insight.exe &
	$(DEVKITPRO)/vba/VisualBoyAdvance-SDL.exe -Gtcp:55555 example.elf

71
data.gbfs: sample_bank.bin $(BIN_MODULES)
72

73
74
75
76
77
78
79
80
$(CONVERTER)::
	make -C ../converter

$(PIMPMOBILE)/lib/libpimpmobile.a::
	make -C .. lib/libpimpmobile.a

$(TARGET:.gba=.elf): $(OBJS) $(PIMPMOBILE)/lib/libpimpmobile.a

81
$(BIN_MODULES) sample_bank.bin : $(MODULES) $(CONVERTER)
82
83
	$(CONVERTER) $(MODULES)

84
85
86
%.gbfs:
	gbfs $@ $^

87
88
89
%.elf:
	$(LD) -specs=gba.specs $^ $(LDFLAGS) -o $@

90
%.bin: %.elf
91
	$(OBJCOPY) -O binary $< $@
92
	padbin 256 $@
Erik Faye-Lund's avatar
   
Erik Faye-Lund committed
93
	gbafix $@ -t$(basename $@)
94

95
96
%.gba: %.bin data.gbfs
	cat $^ > $@
97
98
99
100

%.o: %.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(THUMB) -c $< -o $@ -MMD -MF $(@:.o=.d)

101
102
103
%.o: %.c
	$(CC) $(CPPFLAGS) $(CFLAGS) $(THUMB) -c $< -o $@ -MMD -MF $(@:.o=.d)

104
-include $(OBJS:.o=.d)