import of davy's libwiikeyboard
[libogc.git] / Makefile
blobaaa721a1639bc789485ace01a4000505774cab09
1 #---------------------------------------------------------------------------------
2 .SUFFIXES:
3 #---------------------------------------------------------------------------------
5 ifeq ($(strip $(DEVKITPRO)),)
6 $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
7 endif
9 ifeq ($(strip $(DEVKITPPC)),)
10 $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
11 endif
13 export PATH := $(DEVKITPPC)/bin:$(PATH)
15 export LIBOGC_MAJOR := 1
16 export LIBOGC_MINOR := 7
17 export LIBOGC_PATCH := 1
19 #---------------------------------------------------------------------------------
20 PREFIX := powerpc-gekko
21 #---------------------------------------------------------------------------------
23 CC := $(PREFIX)-gcc
24 CXX := $(PREFIX)-g++
25 AS := $(PREFIX)-as
26 AR := $(PREFIX)-ar
27 LD := $(PREFIX)-ld
28 OBJCOPY := $(PREFIX)-objcopy
30 BUILD := build
32 GCC_VERSION := $(shell $(DEVKITPPC)/bin/$(CC) -dumpversion)
33 DATESTRING := $(shell date +%Y%m%d)
34 VERSTRING := $(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)
36 #---------------------------------------------------------------------------------
37 ifeq ($(strip $(PLATFORM)),)
38 #---------------------------------------------------------------------------------
39 export BASEDIR := $(CURDIR)
40 export LWIPDIR := $(BASEDIR)/lwip
41 export OGCDIR := $(BASEDIR)/libogc
42 export MODDIR := $(BASEDIR)/libmodplay
43 export MADDIR := $(BASEDIR)/libmad
44 export SAMPLEDIR := $(BASEDIR)/libsamplerate
45 export DBDIR := $(BASEDIR)/libdb
46 export DIDIR := $(BASEDIR)/libdi
47 export BTEDIR := $(BASEDIR)/lwbt
48 export WIIUSEDIR := $(BASEDIR)/wiiuse
49 export TINYSMBDIR := $(BASEDIR)/libtinysmb
50 export LIBZDIR := $(BASEDIR)/libz
51 export LIBASNDDIR := $(BASEDIR)/libasnd
52 export LIBWIIKEYB := $(BASEDIR)/libwiikeyboard
53 export STUBSDIR := $(BASEDIR)/lockstubs
54 export DEPS := $(BASEDIR)/deps
55 export LIBS := $(BASEDIR)/lib
57 export INCDIR := $(BASEDIR)/include
59 #---------------------------------------------------------------------------------
60 else
61 #---------------------------------------------------------------------------------
63 export LIBDIR := $(LIBS)/$(PLATFORM)
64 export DEPSDIR := $(DEPS)/$(PLATFORM)
66 #---------------------------------------------------------------------------------
67 endif
68 #---------------------------------------------------------------------------------
71 #---------------------------------------------------------------------------------
72 BBALIB := $(LIBDIR)/libbba
73 OGCLIB := $(LIBDIR)/libogc
74 MODLIB := $(LIBDIR)/libmodplay
75 MADLIB := $(LIBDIR)/libmad
76 DBLIB := $(LIBDIR)/libdb
77 DILIB := $(LIBDIR)/libdi
78 BTELIB := $(LIBDIR)/libbte
79 WIIUSELIB := $(LIBDIR)/libwiiuse
80 TINYSMBLIB := $(LIBDIR)/libtinysmb
81 ZLIB := $(LIBDIR)/libz
82 ASNDLIB := $(LIBDIR)/libasnd
83 WIIKEYBLIB := $(LIBDIR)/libwiikeyboard
84 STUBSLIB := $(LIBDIR)/libgclibstubs
86 #---------------------------------------------------------------------------------
87 DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
88 INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
89 -I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine \
90 -I$(BASEDIR)/gc/modplay -I$(BASEDIR)/gc/mad \
91 -I$(BASEDIR)/gc/z -I$(BASEDIR)/gc/bte \
92 -I$(BASEDIR)/gc/sdcard -I$(BASEDIR)/gc/wiiuse \
93 -I$(BASEDIR)/gc/di
95 MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
97 ifeq ($(PLATFORM),wii)
98 MACHDEP += -DHW_RVL
99 endif
101 ifeq ($(PLATFORM),cube)
102 MACHDEP += -DHW_DOL
103 endif
105 CFLAGS := -DLIBOGC_INTERNAL -DGAMECUBE -O2 -Wall $(MACHDEP) -fno-strict-aliasing $(INCLUDES)
108 #---------------------------------------------------------------------------------
109 VPATH := $(LWIPDIR) \
110 $(LWIPDIR)/arch/gc \
111 $(LWIPDIR)/arch/gc/netif \
112 $(LWIPDIR)/core \
113 $(LWIPDIR)/core/ipv4 \
114 $(LWIPDIR)/netif \
115 $(OGCDIR) \
116 $(MODDIR) \
117 $(MADDIR) \
118 $(SAMPLEDIR) \
119 $(DBDIR) \
120 $(DBDIR)/uIP \
121 $(DIDIR) \
122 $(BTEDIR) \
123 $(WIIUSEDIR) \
124 $(SDCARDDIR) \
125 $(TINYSMBDIR) \
126 $(LIBZDIR) \
127 $(LIBASNDDIR) \
128 $(LIBWIIKEYB) \
129 $(STUBSDIR)
132 #---------------------------------------------------------------------------------
133 LWIPOBJ := network.o netio.o gcif.o \
134 inet.o mem.o dhcp.o raw.o \
135 memp.o netif.o pbuf.o stats.o \
136 sys.o tcp.o tcp_in.o tcp_out.o \
137 udp.o icmp.o ip.o ip_frag.o \
138 ip_addr.o etharp.o loopif.o
140 #---------------------------------------------------------------------------------
141 OGCOBJ := \
142 console.o lwp_priority.o lwp_queue.o lwp_threadq.o lwp_threads.o lwp_sema.o \
143 lwp_messages.o lwp.o lwp_handler.o lwp_stack.o lwp_mutex.o \
144 lwp_watchdog.o lwp_wkspace.o lwp_objmgr.o lwp_heap.o sys_state.o \
145 exception_handler.o exception.o irq.o irq_handler.o semaphore.o \
146 video_asm.o video.o pad.o dvd.o exi.o mutex.o arqueue.o arqmgr.o \
147 cache_asm.o system.o system_asm.o cond.o \
148 gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
149 message.o card.o aram.o depackrnc.o decrementer_handler.o \
150 depackrnc1.o dsp.o si.o tpl.o ipc.o ogc_crt0.o \
151 console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o \
152 sbrk.o malloc_lock.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
153 sdgecko_io.o sdgecko_buf.o gcsd.o argv.o network_wii.o wiisd.o conf.o usbstorage.o \
154 texconv.o wiilaunch.o
156 #---------------------------------------------------------------------------------
157 MODOBJ := freqtab.o mixer.o modplay.o semitonetab.o gcmodplay.o
159 #---------------------------------------------------------------------------------
160 MADOBJ := mp3player.o bit.o decoder.o fixed.o frame.o huffman.o \
161 layer12.o layer3.o stream.o synth.o timer.o \
162 version.o
164 #---------------------------------------------------------------------------------
165 DBOBJ := uip_ip.o uip_tcp.o uip_pbuf.o uip_netif.o uip_arp.o uip_arch.o \
166 uip_icmp.o memb.o memr.o bba.o tcpip.o debug.o debug_handler.o \
167 debug_supp.o geckousb.o
168 #---------------------------------------------------------------------------------
169 DIOBJ := di.o di_read.o stubasm.o stubload.o di_iso9660.o
171 #---------------------------------------------------------------------------------
172 BTEOBJ := bte.o hci.o l2cap.o btmemb.o btmemr.o btpbuf.o physbusif.o
174 #---------------------------------------------------------------------------------
175 WIIUSEOBJ := classic.o dynamics.o events.o guitar_hero_3.o io.o io_wii.o ir.o \
176 nunchuk.o wiiboard.o wiiuse.o wpad.o
178 #---------------------------------------------------------------------------------
179 TINYSMBOBJ := des.o md4.o ntlm.o smb.o smb_devoptab.o
181 #---------------------------------------------------------------------------------
182 ZLIBOBJ := adler32.o compress.o crc32.o gzio.o uncompr.o \
183 deflate.o trees.o zutil.o inflate.o infback.o \
184 inftrees.o inffast.o
186 #---------------------------------------------------------------------------------
187 ASNDLIBOBJ := asndlib.o
189 #---------------------------------------------------------------------------------
190 WIIKEYBLIBOBJ := keyboard.o usbkeyboard.o
192 #---------------------------------------------------------------------------------
193 # Build rules:
194 #---------------------------------------------------------------------------------
195 %.o : %.c
196 #---------------------------------------------------------------------------------
197 @echo $(notdir $<)
198 @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
200 #---------------------------------------------------------------------------------
201 %.o : %.cpp
202 #---------------------------------------------------------------------------------
203 @echo $(notdir $<)
204 @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
206 #---------------------------------------------------------------------------------
207 %.o : %.S
208 #---------------------------------------------------------------------------------
209 @echo $(notdir $<)
210 @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -D_LANGUAGE_ASSEMBLY -Wa,-mgekko -c $< -o $@
212 #---------------------------------------------------------------------------------
213 %.o : %.s
214 #---------------------------------------------------------------------------------
215 @echo $(notdir $<)
216 @$(AS) -mgekko -Qy $< -o $@
218 #---------------------------------------------------------------------------------
219 %.a:
220 #---------------------------------------------------------------------------------
221 $(AR) -rc $@ $^
223 all: wii cube
225 #---------------------------------------------------------------------------------
226 wii: gc/ogc/libversion.h
227 #---------------------------------------------------------------------------------
228 @[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
229 @[ -d $(LIBS)/wii ] || mkdir -p $(LIBS)/wii
230 @[ -d $(DEPS)/wii ] || mkdir -p $(DEPS)/wii
231 @[ -d wii ] || mkdir -p wii
232 @$(MAKE) PLATFORM=wii libs -C wii -f $(CURDIR)/Makefile
234 #---------------------------------------------------------------------------------
235 cube: gc/ogc/libversion.h
236 #---------------------------------------------------------------------------------
237 @[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
238 @[ -d $(LIBS)/cube ] || mkdir -p $(LIBS)/cube
239 @[ -d $(DEPS)/cube ] || mkdir -p $(DEPS)/cube
240 @[ -d cube ] || mkdir -p cube
241 @$(MAKE) PLATFORM=cube libs -C cube -f $(CURDIR)/Makefile
244 #---------------------------------------------------------------------------------
245 gc/ogc/libversion.h : Makefile
246 #---------------------------------------------------------------------------------
247 @echo "#ifndef __LIBVERSION_H__" > $@
248 @echo "#define __LIBVERSION_H__" >> $@
249 @echo >> $@
250 @echo "#define _V_MAJOR_ $(LIBOGC_MAJOR)" >> $@
251 @echo "#define _V_MINOR_ $(LIBOGC_MINOR)" >> $@
252 @echo "#define _V_PATCH_ $(LIBOGC_PATCH)" >> $@
253 @echo >> $@
254 @echo "#define _V_DATE_ __DATE__" >> $@
255 @echo "#define _V_TIME_ __TIME__" >> $@
256 @echo >> $@
257 @echo '#define _V_STRING "libOGC Release '$(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)'"' >> $@
258 @echo >> $@
259 @echo "#endif // __LIBVERSION_H__" >> $@
261 #---------------------------------------------------------------------------------
262 $(BBALIB).a: $(LWIPOBJ)
263 #---------------------------------------------------------------------------------
264 $(OGCLIB).a: $(OGCOBJ)
265 #---------------------------------------------------------------------------------
266 $(MP3LIB).a: $(MP3OBJ)
267 #---------------------------------------------------------------------------------
268 $(MODLIB).a: $(MODOBJ)
269 #---------------------------------------------------------------------------------
270 $(MADLIB).a: $(MADOBJ)
271 #---------------------------------------------------------------------------------
272 $(DBLIB).a: $(DBOBJ)
273 #---------------------------------------------------------------------------------
274 $(DILIB).a: $(DIOBJ)
275 #---------------------------------------------------------------------------------
276 $(TINYSMBLIB).a: $(TINYSMBOBJ)
277 #---------------------------------------------------------------------------------
278 $(ZLIB).a: $(ZLIBOBJ)
279 #---------------------------------------------------------------------------------
280 $(ASNDLIB).a: $(ASNDLIBOBJ)
281 #---------------------------------------------------------------------------------
282 $(WIIKEYBLIB).a: $(WIIKEYBLIBOBJ)
283 #---------------------------------------------------------------------------------
284 $(BTELIB).a: $(BTEOBJ)
285 #---------------------------------------------------------------------------------
286 $(WIIUSELIB).a: $(WIIUSEOBJ)
287 #---------------------------------------------------------------------------------
289 .PHONY: libs wii cube install-headers install dist docs
291 #---------------------------------------------------------------------------------
292 install-headers:
293 #---------------------------------------------------------------------------------
294 @mkdir -p $(INCDIR)
295 @mkdir -p $(INCDIR)/ogc/machine
296 @mkdir -p $(INCDIR)/bte
297 @mkdir -p $(INCDIR)/wiiuse
298 @mkdir -p $(INCDIR)/modplay
299 @mkdir -p $(INCDIR)/mad
300 @mkdir -p $(INCDIR)/sdcard
301 @mkdir -p $(INCDIR)/di
302 @mkdir -p $(INCDIR)/wiikeyboard
303 @cp ./gc/*.h $(INCDIR)
304 @cp ./gc/ogc/*.h $(INCDIR)/ogc
305 @cp ./gc/ogc/machine/*.h $(INCDIR)/ogc/machine
306 @cp ./gc/bte/*.h $(INCDIR)/bte
307 @cp ./gc/wiiuse/*.h $(INCDIR)/wiiuse
308 @cp ./gc/modplay/*.h $(INCDIR)/modplay
309 @cp ./gc/mad/*.h $(INCDIR)/mad
310 @cp ./gc/sdcard/*.h $(INCDIR)/sdcard
311 @cp ./gc/di/*.h $(INCDIR)/di
312 @cp ./gc/wiikeyboard/*.h $(INCDIR)/wiikeyboard
314 #---------------------------------------------------------------------------------
315 install: install-headers
316 #---------------------------------------------------------------------------------
317 @mkdir -p $(DEVKITPRO)/libogc
318 @cp -frv include $(DEVKITPRO)/libogc
319 @cp -frv lib $(DEVKITPRO)/libogc
320 @cp -frv libogc_license.txt $(DEVKITPRO)/libogc
323 #---------------------------------------------------------------------------------
324 dist: install-headers
325 #---------------------------------------------------------------------------------
326 @tar --exclude=*CVS* --exclude=wii --exclude=cube --exclude=*deps* \
327 --exclude=*.bz2 --exclude=*include* --exclude=*lib/* --exclude=*docs/*\
328 -cvjf libogc-src-$(VERSTRING).tar.bz2 *
329 @tar -cvjf libogc-$(VERSTRING).tar.bz2 include lib libogc_license.txt
332 LIBRARIES := $(OGCLIB).a $(MODLIB).a $(MADLIB).a $(DBLIB).a $(ZLIB).a $(TINYSMBLIB).a $(ASNDLIB).a
334 ifeq ($(PLATFORM),cube)
335 LIBRARIES += $(BBALIB).a
336 endif
337 ifeq ($(PLATFORM),wii)
338 LIBRARIES += $(BTELIB).a $(WIIUSELIB).a $(DILIB).a $(WIIKEYBLIB).a
339 endif
341 #---------------------------------------------------------------------------------
342 libs: $(LIBRARIES)
343 #---------------------------------------------------------------------------------
345 #---------------------------------------------------------------------------------
346 clean:
347 #---------------------------------------------------------------------------------
348 rm -fr wii cube
349 rm -fr $(DEPS)
350 rm -fr $(LIBS)
351 rm -fr $(INCDIR)
352 rm -f *.map
354 #---------------------------------------------------------------------------------
355 docs: install-headers
356 #---------------------------------------------------------------------------------
357 doxygen libogc.dox
359 -include $(DEPSDIR)/*.d