about summary refs log tree commit diff stats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile131
1 files changed, 131 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f7dcdae --- /dev/null +++ b/Makefile
@@ -0,0 +1,131 @@
1#---------------------------------------------------------------------------------
2# Clear the implicit built in rules
3#---------------------------------------------------------------------------------
4.SUFFIXES:
5#---------------------------------------------------------------------------------
6ifeq ($(strip $(DEVKITPPC)),)
7$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
8endif
9
10include $(DEVKITPPC)/wii_rules
11
12#---------------------------------------------------------------------------------
13# TARGET is the name of the output
14# BUILD is the directory where object files & intermediate files will be placed
15# SOURCES is a list of directories containing source code
16# INCLUDES is a list of directories containing extra header files
17#---------------------------------------------------------------------------------
18TARGET := boot
19BUILD := build
20SOURCES := source
21DATA := data
22INCLUDES := source
23
24#---------------------------------------------------------------------------------
25# options for code generation
26#---------------------------------------------------------------------------------
27
28CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
29CXXFLAGS = $(CFLAGS)
30
31LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
32
33#---------------------------------------------------------------------------------
34# any extra libraries we wish to link with the project
35#---------------------------------------------------------------------------------
36LIBS := -lfat -logc
37
38
39#---------------------------------------------------------------------------------
40# list of directories containing libraries, this must be the top level containing
41# include and lib
42#---------------------------------------------------------------------------------
43LIBDIRS := $(DEVKITPPC)/lib $(CURDIR)
44
45#---------------------------------------------------------------------------------
46# no real need to edit anything past this point unless you need to add additional
47# rules for different file extensions
48#---------------------------------------------------------------------------------
49ifneq ($(BUILD),$(notdir $(CURDIR)))
50#---------------------------------------------------------------------------------
51
52export OUTPUT := $(CURDIR)/$(TARGET)
53
54export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
55 $(foreach dir,$(DATA),$(CURDIR)/$(dir))
56
57export DEPSDIR := $(CURDIR)/$(BUILD)
58
59#---------------------------------------------------------------------------------
60# automatically build a list of object files for our project
61#---------------------------------------------------------------------------------
62CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
63CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
64sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
65SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
66BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
67
68#---------------------------------------------------------------------------------
69# use CXX for linking C++ projects, CC for standard C
70#---------------------------------------------------------------------------------
71ifeq ($(strip $(CPPFILES)),)
72 export LD := $(CC)
73else
74 export LD := $(CXX)
75endif
76
77export OFILES := $(addsuffix .o,$(BINFILES)) \
78 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
79 $(sFILES:.s=.o) $(SFILES:.S=.o)
80
81#---------------------------------------------------------------------------------
82# build a list of include paths
83#---------------------------------------------------------------------------------
84export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
85 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
86 -I$(CURDIR)/$(BUILD) \
87 -I$(LIBOGC_INC)
88
89#---------------------------------------------------------------------------------
90# build a list of library paths
91#---------------------------------------------------------------------------------
92export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
93 -L$(LIBOGC_LIB)
94
95export OUTPUT := $(CURDIR)/$(TARGET)
96.PHONY: $(BUILD) clean
97
98#---------------------------------------------------------------------------------
99$(BUILD):
100 @[ -d $@ ] || mkdir -p $@
101 @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
102
103#---------------------------------------------------------------------------------
104clean:
105 @echo clean ...
106 @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol $(CURDIR)/data/gba_mb.gba
107
108#---------------------------------------------------------------------------------
109else
110
111DEPENDS := $(OFILES:.o=.d)
112
113#---------------------------------------------------------------------------------
114# main targets
115#---------------------------------------------------------------------------------
116$(OUTPUT).dol: $(OUTPUT).elf
117$(OUTPUT).elf: $(OFILES)
118
119#---------------------------------------------------------------------------------
120# This rule links in binary data with the .jpg extension
121#---------------------------------------------------------------------------------
122%.gba.o : %.gba
123#---------------------------------------------------------------------------------
124 @echo $(notdir $<)
125 $(bin2o)
126
127-include $(DEPENDS)
128
129#---------------------------------------------------------------------------------
130endif
131#---------------------------------------------------------------------------------