Makefile 2.27 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
#	OBJS     += src/pimp_mixer_clip_arm.o
51
52
endif

53
	
54
.PHONY: all clean run debug
55

56
all: bin/example.gba
57

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

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

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

debug:
	make -C example debug
71

72
73
bin/converter:
	make -C converter
74

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

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

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

83
84
85
86
87
88
%.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)

Erik Faye-Lund's avatar
Erik Faye-Lund committed
89
90
91
%.s: %.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -S -fverbose-asm $(THUMB) -c $< -o $@

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

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

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