Makefile 2.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
# Makefile for pimpmobile module player

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

DEVKITARM = $(DEVKITPRO)/devkitARM
LIBGBA    = $(DEVKITPRO)/libgba

10
PREFIX ?= arm-eabi-
11
12
13
14
15
CC      = $(PREFIX)gcc
CXX     = $(PREFIX)g++
OBJCOPY = $(PREFIX)objcopy
STRIP   = $(PREFIX)strip
LD      = $(PREFIX)g++
Erik Faye-Lund's avatar
Erik Faye-Lund committed
16
AS      = $(PREFIX)as
17
18
19
20
21
22
23
24
25
26
27
AR      = $(PREFIX)ar

CPPFLAGS = -I$(DEVKITARM)/include -I$(LIBGBA)/include
CFLAGS   = -mthumb-interwork -mlong-calls
CXXFLAGS = -mthumb-interwork -mlong-calls -fconserve-space -fno-rtti -fno-exceptions
LDFLAGS  = -mthumb-interwork -Wl,--gc-section -Wl,-Map,$(basename $@).map
ASFLAGS  = -mthumb-interwork

ARM   = -marm
THUMB = -mthumb

28
# TODO: profile what code to put where
Erik Faye-Lund's avatar
Erik Faye-Lund committed
29
OBJS = \
Erik Faye-Lund's avatar
Erik Faye-Lund committed
30
31
	src/pimp_gba.o         \
	src/pimp_render.o      \
32
	src/pimp_envelope.o    \
Erik Faye-Lund's avatar
Erik Faye-Lund committed
33
34
35
	src/pimp_debug.o       \
	src/pimp_mod_context.o \
	src/pimp_math.iwram.o  \
Erik Faye-Lund's avatar
Erik Faye-Lund committed
36
	src/pimp_mixer.iwram.o
Erik Faye-Lund's avatar
Erik Faye-Lund committed
37

38
39
ifeq ($(DEBUG), 1)
	CPPFLAGS += -DDEBUG
Erik Faye-Lund's avatar
Erik Faye-Lund committed
40
41
	CXXFLAGS += -g3 -ggdb
	CFLAGS   += -g3 -ggdb
Erik Faye-Lund's avatar
Erik Faye-Lund committed
42
	OBJS     += src/pimp_mixer_portable.o
43
44
45
46
else
	CPPFLAGS += -DRELEASE -DNDEBUG
	CXXFLAGS += -O3 -fomit-frame-pointer
	CFLAGS   += -O3 -fomit-frame-pointer
Erik Faye-Lund's avatar
Erik Faye-Lund committed
47
	OBJS     += src/pimp_mixer_arm.o
48
49
endif

50
	
51
.PHONY: all clean run debug
52

53
all: bin/example.gba
54

55
56
57
bin/example.gba: lib/libpimpmobile.a
	make -C example

58
clean:
59
60
	$(RM) bin/* $(OBJS) $(OBJS:.o=.d) lib/libpimpmobile.a *~ src/*~ include/*~
	make -C converter clean
61
	make -C example clean
62

63
64
65
66
67
run:
	make -C example run

debug:
	make -C example debug
68

69
70
bin/converter:
	make -C converter
71

Erik Faye-Lund's avatar
Erik Faye-Lund committed
72
73
bin/lut_gen: lut_gen.cpp src/pimp_math.cpp src/pimp_config.h
	g++ $^ -o $@
74

75
76
77
78
79
80
lib/libpimpmobile.a: $(OBJS)

%.a:
	$(AR) $(ARFLAGS) $@ $?

%.iwram.o: %.cpp
81
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(ARM) -c $< -o $@ -MMD -MF $(@:.o=.d)
82
83

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

Erik Faye-Lund's avatar
Erik Faye-Lund committed
86
87
88
%.o: %.s
	$(CC) -x assembler-with-cpp -trigraphs $(ASFLAGS) -c $< -o $@ -MMD -MF $(@:.o=.d)

89
90
91
92
93
94
%.iwram.s: %.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -S -fverbose-asm $(ARM) -c $< -o $@

%.s: %.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -S -fverbose-asm $(THUMB) -c $< -o $@

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