Makefile 2.21 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
42
	OBJS     += src/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/mixer_arm.iwram.o
Erik Faye-Lund's avatar
Erik Faye-Lund committed
48
	OBJS     += src/mixer_arm_asm.o
49
#	OBJS     += src/mixer_portable.iwram.o
50
51
endif

52
	
53
.PHONY: all clean run debug
54

55
all: bin/example.gba
56

57
58
59
bin/example.gba: lib/libpimpmobile.a
	make -C example

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

65
66
67
68
69
run:
	make -C example run

debug:
	make -C example debug
70

71
72
bin/converter:
	make -C converter
73

74
75
bin/lut_gen: lut_gen.cpp src/math.cpp src/config.h
	g++ lut_gen.cpp src/math.cpp -o bin/lut_gen
76

77
78
79
80
81
82
lib/libpimpmobile.a: $(OBJS)

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

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

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

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

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

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

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