about summary refs log tree commit diff stats
path: root/gba/Makefile
diff options
context:
space:
mode:
authorFIX94 <fix94.1@gmail.com>2016-04-08 00:19:16 +0200
committerFIX94 <fix94.1@gmail.com>2016-04-08 00:19:16 +0200
commitdb276d8e521ae6b8ea9fb40c33d6961d713f31b7 (patch)
tree464ed30d0f26d20f48cad7b6efef2dd13b060ee8 /gba/Makefile
parent9d737f20c4566fdabac90549f6e9e476a3bb0d4f (diff)
downloadgen3uploader-db276d8e521ae6b8ea9fb40c33d6961d713f31b7.tar.gz
gen3uploader-db276d8e521ae6b8ea9fb40c33d6961d713f31b7.tar.bz2
gen3uploader-db276d8e521ae6b8ea9fb40c33d6961d713f31b7.zip
first commit, enjoy
Diffstat (limited to 'gba/Makefile')
-rw-r--r--gba/Makefile168
1 files changed, 168 insertions, 0 deletions
diff --git a/gba/Makefile b/gba/Makefile new file mode 100644 index 0000000..99dfbb6 --- /dev/null +++ b/gba/Makefile
@@ -0,0 +1,168 @@
1#---------------------------------------------------------------------------------
2# Clear the implicit built in rules
3#---------------------------------------------------------------------------------
4.SUFFIXES:
5#---------------------------------------------------------------------------------
6ifeq ($(strip $(DEVKITARM)),)
7$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
8endif
9
10include $(DEVKITARM)/gba_rules
11
12#---------------------------------------------------------------------------------
13# TARGET is the name of the output, if this ends with _mb a multiboot image is generated
14# BUILD is the directory where object files & intermediate files will be placed
15# SOURCES is a list of directories containing source code
16# DATA is a list of directories containing data files
17# INCLUDES is a list of directories containing header files
18#---------------------------------------------------------------------------------
19TARGET := $(shell basename $(CURDIR))_mb
20BUILD := build
21SOURCES := source
22DATA :=
23GRAPHICS := gfx
24INCLUDES :=
25
26#---------------------------------------------------------------------------------
27# options for code generation
28#---------------------------------------------------------------------------------
29ARCH := -mthumb -mthumb-interwork
30
31CFLAGS := -g -Wall -O3\
32 -mcpu=arm7tdmi -mtune=arm7tdmi\
33 -fomit-frame-pointer\
34 -ffast-math \
35 $(ARCH)
36
37CFLAGS += $(INCLUDE)
38
39CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
40
41ASFLAGS := $(ARCH)
42LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map
43
44#---------------------------------------------------------------------------------
45# any extra libraries we wish to link with the project
46#---------------------------------------------------------------------------------
47LIBS := -lgba
48
49#---------------------------------------------------------------------------------
50# list of directories containing libraries, this must be the top level containing
51# include and lib
52#---------------------------------------------------------------------------------
53LIBDIRS := $(LIBGBA)
54
55#---------------------------------------------------------------------------------
56# no real need to edit anything past this point unless you need to add additional
57# rules for different file extensions
58#---------------------------------------------------------------------------------
59ifneq ($(BUILD),$(notdir $(CURDIR)))
60#---------------------------------------------------------------------------------
61
62export OUTPUT := $(CURDIR)/$(TARGET)
63export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
64 $(foreach dir,$(DATA),$(CURDIR)/$(dir))
65
66export DEPSDIR := $(CURDIR)/$(BUILD)
67
68#---------------------------------------------------------------------------------
69# automatically build a list of object files for our project
70#---------------------------------------------------------------------------------
71CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
72CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
73SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
74BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
75BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp)))
76
77#---------------------------------------------------------------------------------
78# use CXX for linking C++ projects, CC for standard C
79#---------------------------------------------------------------------------------
80ifeq ($(strip $(CPPFILES)),)
81#---------------------------------------------------------------------------------
82 export LD := $(CC)
83#---------------------------------------------------------------------------------
84else
85#---------------------------------------------------------------------------------
86 export LD := $(CXX)
87#---------------------------------------------------------------------------------
88endif
89#---------------------------------------------------------------------------------
90
91export OFILES := $(addsuffix .o,$(BINFILES)) \
92 $(BMPFILES:.bmp=.o) \
93 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
94
95#---------------------------------------------------------------------------------
96# build a list of include paths
97#---------------------------------------------------------------------------------
98export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
99 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
100 -I$(CURDIR)/$(BUILD)
101
102#---------------------------------------------------------------------------------
103# build a list of library paths
104#---------------------------------------------------------------------------------
105export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
106
107.PHONY: $(BUILD) clean
108
109#---------------------------------------------------------------------------------
110$(BUILD):
111 @[ -d $@ ] || mkdir -p $@
112 @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
113
114all : $(BUILD)
115#---------------------------------------------------------------------------------
116clean:
117 @echo clean ...
118 @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba
119
120#---------------------------------------------------------------------------------
121else
122
123DEPENDS := $(OFILES:.o=.d)
124
125#---------------------------------------------------------------------------------
126# main targets
127#---------------------------------------------------------------------------------
128$(OUTPUT).gba : $(OUTPUT).elf
129
130$(OUTPUT).elf : $(OFILES)
131
132
133#---------------------------------------------------------------------------------
134# The bin2o rule should be copied and modified
135# for each extension used in the data directories
136#---------------------------------------------------------------------------------
137
138#---------------------------------------------------------------------------------
139# This rule links in binary data with the .bin extension
140#---------------------------------------------------------------------------------
141%.bin.o : %.bin
142#---------------------------------------------------------------------------------
143 @echo $(notdir $<)
144 @$(bin2o)
145
146#---------------------------------------------------------------------------------
147# This rule links in binary data with the .raw extension
148#---------------------------------------------------------------------------------
149%.raw.o : %.raw
150#---------------------------------------------------------------------------------
151 @echo $(notdir $<)
152 @$(bin2o)
153
154#---------------------------------------------------------------------------------
155# This rule creates assembly source files using grit
156# grit takes an image file and a .grit describing how the file is to be processed
157# add additional rules like this for each image extension
158# you use in the graphics folders
159#---------------------------------------------------------------------------------
160%.s %.h : %.bmp %.grit
161#---------------------------------------------------------------------------------
162 grit $< -fts -o$*
163
164-include $(DEPENDS)
165
166#---------------------------------------------------------------------------------
167endif
168#---------------------------------------------------------------------------------