-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Makefile.libogc
354 lines (307 loc) · 11 KB
/
Makefile.libogc
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#---------------------------------------------------------------------------------
.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)
ifeq ($(PLATFORM),)
PLATFORM=wii
endif
#---------------------------------------------------------------------------------
# change shell on Snow Leopard
#---------------------------------------------------------------------------------
UNAME_S := $(shell uname -s)
UNAME_R := $(shell uname -r)
ifneq (,$(findstring Darwin,$(UNAME_S)))
ifneq (,$(findstring 10.8.0,$(UNAME_R)))
export SHELL=/bin/bash
endif
endif
#---------------------------------------------------------------------------------
# path to tools
#---------------------------------------------------------------------------------
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
#---------------------------------------------------------------------------------
# the prefix on the compiler executables
#---------------------------------------------------------------------------------
PREFIX := powerpc-eabi-
export AS := $(PREFIX)as
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
ISVC=$(or $(VCBUILDHELPER_COMMAND),$(MSBUILDEXTENSIONSPATH32),$(MSBUILDEXTENSIONSPATH))
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
@rm -f $@
$(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.m
$(CC) $(OBJCFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.s
$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.S
$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
bin2s -a 32 $< | $(AS) -o $(@)
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef
BUILD := build
BUILD_LITE = 1
CURDIR = .
export BASEDIR := $(CURDIR)
export DEPSDIR := $(BASEDIR)/wii/libogc/deps
export LWIPDIR := $(BASEDIR)/wii/libogc/lwip
export OGCDIR := $(BASEDIR)/wii/libogc/libogc
export DBDIR := $(BASEDIR)/wii/libogc/libdb
export BTEDIR := $(BASEDIR)/wii/libogc/lwbt
export WIIUSEDIR := $(BASEDIR)/wii/libogc/wiiuse
export LIBWIIKEYB := $(BASEDIR)/wii/libogc/libwiikeyboard
export STUBSDIR := $(BASEDIR)/wii/libogc/lockstubs
export LIBS := $(BASEDIR)/wii/libogc/libs
export INCDIR := $(BASEDIR)/wii/libogc/include
export LIBDIR := $(LIBS)/$(PLATFORM)
#---------------------------------------------------------------------------------
BBALIB := $(LIBDIR)/libbba
OGCLIB := $(LIBDIR)/libogc
DBLIB := $(LIBDIR)/libdb
BTELIB := $(LIBDIR)/libbte
WIIUSELIB := $(LIBDIR)/libwiiuse
WIIKEYBLIB := $(LIBDIR)/libwiikeyboard
STUBSLIB := $(LIBDIR)/libgclibstubs
#---------------------------------------------------------------------------------
DEFAULTINCDIR := $(BASEDIR)/wii/libogc/include
DEFINCS := -I$(DEFAULTINCDIR)
INCLUDES := $(DEFINCS) \
-I$(BASEDIR)/wii/libogc \
-I$(DEFAULTINCDIR)/netif \
-I$(DEFAULTINCDIR)/ipv4 \
-I$(DEFAULTINCDIR)/sdcard \
-I$(DEFAULTINCDIR)/ogc \
-I$(DEFAULTINCDIR)/ogc/machine \
-I$(DEFAULTINCDIR)/bte \
-I$(DEFAULTINCDIR)/sdcard \
-I$(DEFAULTINCDIR)/wiikeyboard \
-I$(DEFAULTINCDIR)/wiiuse \
-I$(DEFAULTINCDIR)/di
MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -ffunction-sections -fdata-sections
ifeq ($(PLATFORM),wii)
MACHDEP += -DHW_RVL
endif
ifeq ($(PLATFORM),cube)
MACHDEP += -DHW_DOL
endif
CFLAGS := -DLIBOGC_INTERNAL -DNDEBUG -O2 -fno-strict-aliasing -mregnames -Wall $(MACHDEP) $(INCLUDES)
ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDES)
#---------------------------------------------------------------------------------
VPATH := $(LWIPDIR) \
$(LWIPDIR)/arch/gc \
$(LWIPDIR)/arch/gc/netif \
$(LWIPDIR)/core \
$(LWIPDIR)/core/ipv4 \
$(LWIPDIR)/netif \
$(OGCDIR) \
$(DBDIR) \
$(DBDIR)/uIP \
$(BTEDIR) \
$(WIIUSEDIR) \
$(SDCARDDIR) \
$(LIBWIIKEYB) \
$(STUBSDIR)
#---------------------------------------------------------------------------------
SOURCES_LWIP := $(LWIPDIR)/network.c \
$(LWIPDIR)/netio.c \
$(LWIPDIR)/arch/gc/netif/gcif.c \
$(LWIPDIR)/core/inet.c \
$(LWIPDIR)/core/mem.c \
$(LWIPDIR)/core/dhcp.c \
$(LWIPDIR)/core/raw.c \
$(LWIPDIR)/core/memp.c \
$(LWIPDIR)/core/netif.c \
$(LWIPDIR)/core/pbuf.c \
$(LWIPDIR)/core/stats.c \
$(LWIPDIR)/core/sys.c \
$(LWIPDIR)/core/tcp.c \
$(LWIPDIR)/core/tcp_in.c \
$(LWIPDIR)/core/tcp_out.c \
$(LWIPDIR)/core/udp.c \
$(LWIPDIR)/core/ipv4/icmp.c \
$(LWIPDIR)/core/ipv4/ip.c \
$(LWIPDIR)/core/ipv4/ip_frag.c \
$(LWIPDIR)/core/ipv4/ip_addr.c \
$(LWIPDIR)/netif/etharp.c \
$(LWIPDIR)/netif/loopif.c
LWIPOBJ := $(SOURCES_LWIP:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_OGC := \
$(OGCDIR)/console.c \
$(OGCDIR)/lwp_priority.c \
$(OGCDIR)/lwp_queue.c \
$(OGCDIR)/lwp_threadq.c \
$(OGCDIR)/lwp_threads.c \
$(OGCDIR)/lwp_sema.c \
$(OGCDIR)/lwp_messages.c \
$(OGCDIR)/lwp.c \
$(OGCDIR)/lwp_stack.c \
$(OGCDIR)/lwp_mutex.c \
$(OGCDIR)/lwp_watchdog.c \
$(OGCDIR)/lwp_wkspace.c \
$(OGCDIR)/lwp_objmgr.c \
$(OGCDIR)/lwp_heap.c \
$(OGCDIR)/sys_state.c \
$(OGCDIR)/exception.c \
$(OGCDIR)/irq.c \
$(OGCDIR)/semaphore.c \
$(OGCDIR)/video.c \
$(OGCDIR)/pad.c \
$(OGCDIR)/exi.c \
$(OGCDIR)/mutex.c \
$(OGCDIR)/arqueue.c \
$(OGCDIR)/arqmgr.c \
$(OGCDIR)/system.c \
$(OGCDIR)/cond.c \
$(OGCDIR)/gx.c \
$(OGCDIR)/gu.c \
$(OGCDIR)/audio.c \
$(OGCDIR)/cache.c \
$(OGCDIR)/decrementer.c \
$(OGCDIR)/message.c \
$(OGCDIR)/card.c \
$(OGCDIR)/aram.c \
$(OGCDIR)/depackrnc1.c \
$(OGCDIR)/dsp.c \
$(OGCDIR)/si.c \
$(OGCDIR)/tpl.c \
$(OGCDIR)/ipc.c \
$(OGCDIR)/console_font_8x16.c \
$(OGCDIR)/timesupp.c \
$(OGCDIR)/lock_supp.c \
$(OGCDIR)/newlibc.c \
$(OGCDIR)/usbgecko.c \
$(OGCDIR)/usbmouse.c \
$(OGCDIR)/sbrk.c \
$(OGCDIR)/malloc_lock.c \
$(OGCDIR)/kprintf.c \
$(OGCDIR)/stm.c \
$(OGCDIR)/ios.c \
$(OGCDIR)/es.c \
$(OGCDIR)/isfs.c \
$(OGCDIR)/usb.c \
$(OGCDIR)/network_common.c \
$(OGCDIR)/sdgecko_io.c \
$(OGCDIR)/sdgecko_buf.c \
$(OGCDIR)/gcsd.c \
$(OGCDIR)/argv.c \
$(OGCDIR)/network_wii.c \
$(OGCDIR)/wiisd.c \
$(OGCDIR)/conf.c \
$(OGCDIR)/usbstorage.c \
$(OGCDIR)/texconv.c \
$(OGCDIR)/wiilaunch.c
SOURCES_OGC_ASM := $(OGCDIR)/cache_asm.S \
$(OGCDIR)/decrementer_handler.S \
$(OGCDIR)/depackrnc.S \
$(OGCDIR)/exception_handler.S \
$(OGCDIR)/gu_psasm.S \
$(OGCDIR)/irq_handler.S \
$(OGCDIR)/lwp_handler.S \
$(OGCDIR)/ogc_crt0.S \
$(OGCDIR)/system_asm.S \
$(OGCDIR)/video_asm.S
ifneq ($(BUILD_LITE), 1)
SOURCES_OGC += $(OGCDIR)/dvd.c
endif
OGCOBJ := $(SOURCES_OGC:.c=.o) $(SOURCES_OGC_ASM:.S=.o)
#---------------------------------------------------------------------------------
SOURCES_DB := \
$(DBDIR)/uIP/uip_ip.c \
$(DBDIR)/uIP/uip_tcp.c \
$(DBDIR)/uIP/uip_pbuf.c \
$(DBDIR)/uIP/uip_netif.c \
$(DBDIR)/uIP/uip_arp.c \
$(DBDIR)/uIP/uip_arch.c \
$(DBDIR)/uIP/uip_icmp.c \
$(DBDIR)/uIP/memb.c \
$(DBDIR)/uIP/memr.c \
$(DBDIR)/uIP/bba.c \
$(DBDIR)/tcpip.c \
$(DBDIR)/debug.c \
$(DBDIR)/debug_handler.c \
$(DBDIR)/debug_supp.c \
$(DBDIR)/geckousb.c
DBOBJ := $(SOURCES_DB:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_BTE := \
$(BTEDIR)/bte.c \
$(BTEDIR)/hci.c \
$(BTEDIR)/l2cap.c \
$(BTEDIR)/btmemb.c \
$(BTEDIR)/btmemr.c \
$(BTEDIR)/btpbuf.c \
$(BTEDIR)/physbusif.c
BTEOBJ := $(SOURCES_BTE:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_WIIUSE := \
$(WIIUSEDIR)/classic.c \
$(WIIUSEDIR)/dynamics.c \
$(WIIUSEDIR)/events.c \
$(WIIUSEDIR)/io.c \
$(WIIUSEDIR)/io_wii.c \
$(WIIUSEDIR)/ir.c \
$(WIIUSEDIR)/nunchuk.c \
$(WIIUSEDIR)/wiiuse.c \
$(WIIUSEDIR)/speaker.c \
$(WIIUSEDIR)/wpad.c \
$(WIIUSEDIR)/motion_plus.c
WIIUSEOBJ := $(SOURCES_WIIUSE:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_WIIKEYB = $(LIBWIIKEYB)/usbkeyboard.c \
$(LIBWIIKEYB)/keyboard.c \
$(LIBWIIKEYB)/ukbdmap.c \
$(LIBWIIKEYB)/wskbdutil.c
WIIKEYBLIBOBJ := $(SOURCES_WIIKEYB:.c=.o)
LIBRARIES := $(OGCLIB).a $(DBLIB).a
ifeq ($(PLATFORM),cube)
LIBRARIES += $(BBALIB).a
endif
ifeq ($(PLATFORM),wii)
LIBRARIES += $(BTELIB).a $(WIIUSELIB).a $(WIIKEYBLIB).a
endif
all: $(LIBRARIES)
#---------------------------------------------------------------------------------
$(BBALIB).a: $(LWIPOBJ)
#---------------------------------------------------------------------------------
$(OGCLIB).a: $(OGCOBJ)
#---------------------------------------------------------------------------------
$(DBLIB).a: $(DBOBJ)
#---------------------------------------------------------------------------------
$(WIIKEYBLIB).a: $(WIIKEYBLIBOBJ)
#---------------------------------------------------------------------------------
$(BTELIB).a: $(BTEOBJ)
#---------------------------------------------------------------------------------
$(WIIUSELIB).a: $(WIIUSEOBJ)
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
clean:
#---------------------------------------------------------------------------------
rm -fr $(LWIPOBJ) $(OGCOBJ) $(DBOBJ) $(BTEOBJ) $(WIIUSEOBJ) $(WIIKEYBLIBOBJ)
rm -f *.map