Makefile 2.41 KB
Newer Older
1
# Makefile for pimpmobile module player
2
3
# Copyright (C) 2005-2006 Jrn Nystad and Erik Faye-Lund
# For conditions of distribution and use, see copyright notice in LICENSE.TXT
4
5
6
7
8
9
10
11

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

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

12
PREFIX ?= arm-eabi-
13
14
15
16
17
CC      = $(PREFIX)gcc
CXX     = $(PREFIX)g++
OBJCOPY = $(PREFIX)objcopy
STRIP   = $(PREFIX)strip
LD      = $(PREFIX)g++
Erik Faye-Lund's avatar
Erik Faye-Lund committed
18
AS      = $(PREFIX)as
19
20
21
22
23
24
25
26
27
28
29
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

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

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

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

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

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

82
83
84
85
86
87
%.iwram.o: %.c
	$(CC) $(CPPFLAGS) $(CFLAGS) $(ARM) -c $< -o $@ -MMD -MF $(@:.o=.d)

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

88
%.iwram.o: %.cpp
89
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(ARM) -c $< -o $@ -MMD -MF $(@:.o=.d)
90
91

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

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

97
98
99
100
101
102
%.iwram.s: %.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -S -fverbose-asm $(ARM) -c $< -o $@

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

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