-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·210 lines (165 loc) · 7.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
endif
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
export PATH := $(DEVKITPPC)/bin:$(PATH)
#export LIBML_MAJOR := 1
#export LIBML_MINOR := 6
#export LIBML_PATCH := 0
#---------------------------------------------------------------------------------
PREFIX := powerpc-eabi
#---------------------------------------------------------------------------------
CC := $(PREFIX)-gcc
CXX := $(PREFIX)-g++
AS := $(PREFIX)-as
AR := $(PREFIX)-ar
LD := $(PREFIX)-ld
OBJCOPY := $(PREFIX)-objcopy
BUILD := build
GCC_VERSION := $(shell $(DEVKITPPC)/bin/$(CC) -dumpversion)
DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d)
#---------------------------------------------------------------------------------
ifeq ($(strip $(PLATFORM)),)
#---------------------------------------------------------------------------------
export BASEDIR := $(CURDIR)
export MLDIR := $(BASEDIR)/source
export DEPS := $(BASEDIR)/deps
export LIBS := $(BASEDIR)/lib
export INCDIR := $(BASEDIR)/include/
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LIBDIR := $(LIBS)/$(PLATFORM)
export DEPSDIR := $(DEPS)/$(PLATFORM)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
MLLIB := $(LIBDIR)/source
#---------------------------------------------------------------------------------
INCLUDES := -I$(BASEDIR)/include -I$(DEVKITPRO)/libogc/include
MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
ifeq ($(PLATFORM),wii)
MACHDEP += -DHW_RVL
endif
#ifeq ($(PLATFORM),cube)
#MACHDEP += -DHW_DOL
#endif
CFLAGS := -DGAMECUBE -O2 -Wall $(MACHDEP) -fno-strict-aliasing $(INCLUDES)
#---------------------------------------------------------------------------------
VPATH := $(MLDIR)
#---------------------------------------------------------------------------------
MLOBJ := ML_draw.o ML_init.o \
ML_input.o ML_modplayer.o ML_mp3player.o \
ML_time.o ML_video.o ML_system.o ML_sprites.o \
ML_font.o ML_backgrounds.o ML_images.o \
ML_math.o \
PNG.o globals.o MLlib_SplashScreen.png.o
#---------------------------------------------------------------------------------
# Build rules:
#---------------------------------------------------------------------------------
%.o : %.c
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
#---------------------------------------------------------------------------------
%.o : %.cpp
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
#---------------------------------------------------------------------------------
%.png.o : %.png
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.o : %.S
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -D_LANGUAGE_ASSEMBLY -Wa,-mgekko -c $< -o $@
#---------------------------------------------------------------------------------
%.o : %.s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(AS) -mgekko -Qy $< -o $@
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
$(AR) -rc $@ $^
#---------------------------------------------------------------------------------
all: wii
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
#wii: include/libversion.h
wii:
#---------------------------------------------------------------------------------
@[ -d $(LIBS)/wii ] || mkdir -p $(LIBS)/wii
@[ -d $(DEPS)/wii ] || mkdir -p $(DEPS)/wii
@[ -d wii ] || mkdir -p wii
@$(MAKE) PLATFORM=wii libs -C wii -f $(CURDIR)/Makefile
@mv $(LIBS)/wii/source.a $(BASEDIR)/lib/wii/libMLlib.a
#---------------------------------------------------------------------------------
#cube: include/libversion.h
#cube:
#---------------------------------------------------------------------------------
# @[ -d $(LIBS)/cube ] || mkdir -p $(LIBS)/cube
# @[ -d $(DEPS)/cube ] || mkdir -p $(DEPS)/cube
# @[ -d cube ] || mkdir -p cube
# @$(MAKE) PLATFORM=cube libs -C cube -f $(CURDIR)/Makefile
##---------------------------------------------------------------------------------
#include/libversion.h: Makefile
##---------------------------------------------------------------------------------
# @echo "#ifndef __LIBVERSION_H__" > $@
# @echo "#define __LIBVERSION_H__" >> $@
# @echo >> $@
# @echo "#define _V_MAJOR_ $(LIBML_MAJOR)" >> $@
# @echo "#define _V_MINOR_ $(LIBML_MINOR)" >> $@
# @echo "#define _V_PATCH_ $(LIBML_PATCH)" >> $@
# @echo >> $@
# @echo "#define _V_DATE_ __DATE__" >> $@
# @echo "#define _V_TIME_ __TIME__" >> $@
# @echo >> $@
# @echo '#define _V_STRING "libML Release '$(LIBML_MAJOR).$(LIBML_MINOR).$(LIBML_PATCH)'"' >> $@
# @echo >> $@
# @echo "#endif // __LIBVERSION_H__" >> $@
#---------------------------------------------------------------------------------
$(MLLIB).a: $(MLOBJ)
#---------------------------------------------------------------------------------
.PHONY: libs install dist docs cube wii
##---------------------------------------------------------------------------------
install:
##---------------------------------------------------------------------------------
@mkdir -p $(DEVKITPRO)/MLlib/lib
@mkdir -p $(DEVKITPRO)/MLlib/include
@cp -rv $(INCDIR)*.h $(DEVKITPRO)/MLlib/include/
@cp -rv $(LIBS)/wii/libMLlib.a $(DEVKITPRO)/MLlib/lib/
#---------------------------------------------------------------------------------
dist:
#---------------------------------------------------------------------------------
@tar --exclude=*CVS* --exclude=wii --exclude=cube --exclude=*deps* \
--exclude=*.bz2 --exclude=*lib/* --exclude=*docs/* \
-cvjf MLlib-src-$(DATESTRING).tar.bz2 *
@tar -cvjf MLlib-$(DATESTRING).tar.bz2 include source
LIBRARIES := $(MLLIB).a
#---------------------------------------------------------------------------------
libs: $(LIBRARIES)
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
clean:
#---------------------------------------------------------------------------------
rm -fr $(MLPATH)/include
rm -fr $(MLPATH)/lib
rm -fr wii
rm -fr $(DEPS)
rm -fr $(LIBS)
rm -f *.map
#---------------------------------------------------------------------------------
docs:
#---------------------------------------------------------------------------------
doxygen mllib.dox
-include $(DEPSDIR)/*.d