catch up with upsteam
[libogc.git] / Makefile
blob5542d3df103694d5c86acb8bce2f477cd98739bb
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 := 8
17 export LIBOGC_PATCH := 3
19 include $(DEVKITPPC)/base_rules
21 BUILD := build
23 DATESTRING := $(shell date +%Y%m%d)
24 VERSTRING := $(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)
26 #---------------------------------------------------------------------------------
27 ifeq ($(strip $(PLATFORM)),)
28 #---------------------------------------------------------------------------------
29 export BASEDIR := $(CURDIR)
30 export LWIPDIR := $(BASEDIR)/lwip
31 export OGCDIR := $(BASEDIR)/libogc
32 export MODDIR := $(BASEDIR)/libmodplay
33 export MADDIR := $(BASEDIR)/libmad
34 export SAMPLEDIR := $(BASEDIR)/libsamplerate
35 export DBDIR := $(BASEDIR)/libdb
36 export DIDIR := $(BASEDIR)/libdi
37 export BTEDIR := $(BASEDIR)/lwbt
38 export WIIUSEDIR := $(BASEDIR)/wiiuse
39 export TINYSMBDIR := $(BASEDIR)/libtinysmb
40 export LIBASNDDIR := $(BASEDIR)/libasnd
41 export LIBAESNDDIR := $(BASEDIR)/libaesnd
42 export LIBISODIR := $(BASEDIR)/libiso9660
43 export LIBWIIKEYB := $(BASEDIR)/libwiikeyboard
44 export STUBSDIR := $(BASEDIR)/lockstubs
45 export DEPS := $(BASEDIR)/deps
46 export LIBS := $(BASEDIR)/lib
48 export INCDIR := $(BASEDIR)/include
50 #---------------------------------------------------------------------------------
51 else
52 #---------------------------------------------------------------------------------
54 export LIBDIR := $(LIBS)/$(PLATFORM)
55 export DEPSDIR := $(DEPS)/$(PLATFORM)
57 #---------------------------------------------------------------------------------
58 endif
59 #---------------------------------------------------------------------------------
62 #---------------------------------------------------------------------------------
63 BBALIB := $(LIBDIR)/libbba
64 OGCLIB := $(LIBDIR)/libogc
65 MODLIB := $(LIBDIR)/libmodplay
66 MADLIB := $(LIBDIR)/libmad
67 DBLIB := $(LIBDIR)/libdb
68 DILIB := $(LIBDIR)/libdi
69 BTELIB := $(LIBDIR)/libbte
70 WIIUSELIB := $(LIBDIR)/libwiiuse
71 TINYSMBLIB := $(LIBDIR)/libtinysmb
72 ASNDLIB := $(LIBDIR)/libasnd
73 AESNDLIB := $(LIBDIR)/libaesnd
74 ISOLIB := $(LIBDIR)/libiso9660
75 WIIKEYBLIB := $(LIBDIR)/libwiikeyboard
76 STUBSLIB := $(LIBDIR)/libgclibstubs
78 #---------------------------------------------------------------------------------
79 DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
80 INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
81 -I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine \
82 -I$(BASEDIR)/gc/modplay \
83 -I$(BASEDIR)/gc/bte \
84 -I$(BASEDIR)/gc/sdcard -I$(BASEDIR)/gc/wiiuse \
85 -I$(BASEDIR)/gc/di
87 MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
90 ifeq ($(PLATFORM),wii)
91 MACHDEP += -DHW_RVL
92 endif
94 ifeq ($(PLATFORM),cube)
95 MACHDEP += -DHW_DOL
96 endif
98 CFLAGS := -DLIBOGC_INTERNAL -O2 -mregnames -Wall $(MACHDEP) -fno-strict-aliasing $(INCLUDES) -Wa,-mgekko
99 ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY -Wa,-mgekko $(INCLUDES)
101 #---------------------------------------------------------------------------------
102 VPATH := $(LWIPDIR) \
103 $(LWIPDIR)/arch/gc \
104 $(LWIPDIR)/arch/gc/netif \
105 $(LWIPDIR)/core \
106 $(LWIPDIR)/core/ipv4 \
107 $(LWIPDIR)/netif \
108 $(OGCDIR) \
109 $(MODDIR) \
110 $(MADDIR) \
111 $(SAMPLEDIR) \
112 $(DBDIR) \
113 $(DBDIR)/uIP \
114 $(DIDIR) \
115 $(BTEDIR) \
116 $(WIIUSEDIR) \
117 $(SDCARDDIR) \
118 $(TINYSMBDIR) \
119 $(LIBASNDDIR) \
120 $(LIBAESNDDIR) \
121 $(LIBISODIR) \
122 $(LIBWIIKEYB) \
123 $(STUBSDIR)
126 #---------------------------------------------------------------------------------
127 LWIPOBJ := network.o netio.o gcif.o \
128 inet.o mem.o dhcp.o raw.o \
129 memp.o netif.o pbuf.o stats.o \
130 sys.o tcp.o tcp_in.o tcp_out.o \
131 udp.o icmp.o ip.o ip_frag.o \
132 ip_addr.o etharp.o loopif.o
134 #---------------------------------------------------------------------------------
135 OGCOBJ := \
136 console.o lwp_priority.o lwp_queue.o lwp_threadq.o lwp_threads.o lwp_sema.o \
137 lwp_messages.o lwp.o lwp_handler.o lwp_stack.o lwp_mutex.o \
138 lwp_watchdog.o lwp_wkspace.o lwp_objmgr.o lwp_heap.o sys_state.o \
139 exception_handler.o exception.o irq.o irq_handler.o semaphore.o \
140 video_asm.o video.o pad.o dvd.o exi.o mutex.o arqueue.o arqmgr.o \
141 cache_asm.o system.o system_asm.o cond.o \
142 gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
143 message.o card.o aram.o depackrnc.o decrementer_handler.o \
144 depackrnc1.o dsp.o si.o tpl.o ipc.o ogc_crt0.o \
145 console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o usbmouse.o \
146 sbrk.o malloc_lock.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
147 sdgecko_io.o sdgecko_buf.o gcsd.o argv.o network_wii.o wiisd.o conf.o usbstorage.o \
148 texconv.o wiilaunch.o
150 #---------------------------------------------------------------------------------
151 MODOBJ := freqtab.o mixer.o modplay.o semitonetab.o gcmodplay.o
153 #---------------------------------------------------------------------------------
154 MADOBJ := mp3player.o bit.o decoder.o fixed.o frame.o huffman.o \
155 layer12.o layer3.o stream.o synth.o timer.o \
156 version.o
158 #---------------------------------------------------------------------------------
159 DBOBJ := uip_ip.o uip_tcp.o uip_pbuf.o uip_netif.o uip_arp.o uip_arch.o \
160 uip_icmp.o memb.o memr.o bba.o tcpip.o debug.o debug_handler.o \
161 debug_supp.o geckousb.o
162 #---------------------------------------------------------------------------------
163 DIOBJ := di.o stubasm.o stubload.o
165 #---------------------------------------------------------------------------------
166 BTEOBJ := bte.o hci.o l2cap.o btmemb.o btmemr.o btpbuf.o physbusif.o
168 #---------------------------------------------------------------------------------
169 WIIUSEOBJ := classic.o dynamics.o events.o guitar_hero_3.o io.o io_wii.o ir.o \
170 nunchuk.o wiiboard.o wiiuse.o speaker.o wpad.o motion_plus.o
172 #---------------------------------------------------------------------------------
173 TINYSMBOBJ := des.o md4.o ntlm.o smb.o smb_devoptab.o
175 #---------------------------------------------------------------------------------
176 ASNDLIBOBJ := asndlib.o
178 #---------------------------------------------------------------------------------
179 AESNDLIBOBJ := aesndlib.o
181 #---------------------------------------------------------------------------------
182 ISOLIBOBJ := iso9660.o
184 #---------------------------------------------------------------------------------
185 WIIKEYBLIBOBJ := usbkeyboard.o keyboard.o ukbdmap.o wskbdutil.o
189 all: wii cube
191 #---------------------------------------------------------------------------------
192 wii: gc/ogc/libversion.h
193 #---------------------------------------------------------------------------------
194 @[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
195 @[ -d $(LIBS)/wii ] || mkdir -p $(LIBS)/wii
196 @[ -d $(DEPS)/wii ] || mkdir -p $(DEPS)/wii
197 @[ -d wii ] || mkdir -p wii
198 @$(MAKE) PLATFORM=wii libs -C wii -f $(CURDIR)/Makefile
200 #---------------------------------------------------------------------------------
201 cube: gc/ogc/libversion.h
202 #---------------------------------------------------------------------------------
203 @[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
204 @[ -d $(LIBS)/cube ] || mkdir -p $(LIBS)/cube
205 @[ -d $(DEPS)/cube ] || mkdir -p $(DEPS)/cube
206 @[ -d cube ] || mkdir -p cube
207 @$(MAKE) PLATFORM=cube libs -C cube -f $(CURDIR)/Makefile
210 #---------------------------------------------------------------------------------
211 gc/ogc/libversion.h : Makefile
212 #---------------------------------------------------------------------------------
213 @echo "#ifndef __LIBVERSION_H__" > $@
214 @echo "#define __LIBVERSION_H__" >> $@
215 @echo >> $@
216 @echo "#define _V_MAJOR_ $(LIBOGC_MAJOR)" >> $@
217 @echo "#define _V_MINOR_ $(LIBOGC_MINOR)" >> $@
218 @echo "#define _V_PATCH_ $(LIBOGC_PATCH)" >> $@
219 @echo >> $@
220 @echo "#define _V_DATE_ __DATE__" >> $@
221 @echo "#define _V_TIME_ __TIME__" >> $@
222 @echo >> $@
223 @echo '#define _V_STRING "libOGC Release '$(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)'"' >> $@
224 @echo >> $@
225 @echo "#endif // __LIBVERSION_H__" >> $@
227 #---------------------------------------------------------------------------------
228 $(BBALIB).a: $(LWIPOBJ)
229 #---------------------------------------------------------------------------------
230 $(OGCLIB).a: $(OGCOBJ)
231 #---------------------------------------------------------------------------------
232 $(MP3LIB).a: $(MP3OBJ)
233 #---------------------------------------------------------------------------------
234 $(MODLIB).a: $(MODOBJ)
235 #---------------------------------------------------------------------------------
236 $(MADLIB).a: $(MADOBJ)
237 #---------------------------------------------------------------------------------
238 $(DBLIB).a: $(DBOBJ)
239 #---------------------------------------------------------------------------------
240 $(DILIB).a: $(DIOBJ)
241 #---------------------------------------------------------------------------------
242 $(TINYSMBLIB).a: $(TINYSMBOBJ)
243 #---------------------------------------------------------------------------------
244 $(ASNDLIB).a: $(ASNDLIBOBJ)
245 #---------------------------------------------------------------------------------
246 $(AESNDLIB).a: $(AESNDLIBOBJ)
247 #---------------------------------------------------------------------------------
248 $(ISOLIB).a: $(ISOLIBOBJ)
249 #---------------------------------------------------------------------------------
250 $(WIIKEYBLIB).a: $(WIIKEYBLIBOBJ)
251 #---------------------------------------------------------------------------------
252 $(BTELIB).a: $(BTEOBJ)
253 #---------------------------------------------------------------------------------
254 $(WIIUSELIB).a: $(WIIUSEOBJ)
255 #---------------------------------------------------------------------------------
257 .PHONY: libs wii cube install-headers install dist docs
259 #---------------------------------------------------------------------------------
260 install-headers:
261 #---------------------------------------------------------------------------------
262 @mkdir -p $(INCDIR)
263 @mkdir -p $(INCDIR)/ogc/machine
264 @mkdir -p $(INCDIR)/bte
265 @mkdir -p $(INCDIR)/wiiuse
266 @mkdir -p $(INCDIR)/modplay
267 @mkdir -p $(INCDIR)/sdcard
268 @mkdir -p $(INCDIR)/di
269 @mkdir -p $(INCDIR)/wiikeyboard
270 @cp ./gc/*.h $(INCDIR)
271 @cp ./gc/ogc/*.h $(INCDIR)/ogc
272 @cp ./gc/ogc/machine/*.h $(INCDIR)/ogc/machine
273 @cp ./gc/bte/*.h $(INCDIR)/bte
274 @cp ./gc/wiiuse/*.h $(INCDIR)/wiiuse
275 @cp ./gc/modplay/*.h $(INCDIR)/modplay
276 @cp ./gc/sdcard/*.h $(INCDIR)/sdcard
277 @cp ./gc/di/*.h $(INCDIR)/di
278 @cp ./gc/wiikeyboard/*.h $(INCDIR)/wiikeyboard
280 #---------------------------------------------------------------------------------
281 install: install-headers
282 #---------------------------------------------------------------------------------
283 @mkdir -p $(DEVKITPRO)/libogc
284 @cp -frv include $(DEVKITPRO)/libogc
285 @cp -frv lib $(DEVKITPRO)/libogc
286 @cp -frv libogc_license.txt $(DEVKITPRO)/libogc
289 #---------------------------------------------------------------------------------
290 dist: install-headers
291 #---------------------------------------------------------------------------------
292 @tar --exclude=*CVS* --exclude=.svn --exclude=wii --exclude=cube --exclude=*deps* \
293 --exclude=*.bz2 --exclude=*include* --exclude=*lib/* --exclude=*docs/*\
294 -cvjf libogc-src-$(VERSTRING).tar.bz2 *
295 @tar -cvjf libogc-$(VERSTRING).tar.bz2 include lib libogc_license.txt
298 LIBRARIES := $(OGCLIB).a $(MODLIB).a $(MADLIB).a $(DBLIB).a \
299 $(TINYSMBLIB).a $(ASNDLIB).a $(AESNDLIB).a $(ISOLIB).a
301 ifeq ($(PLATFORM),cube)
302 LIBRARIES += $(BBALIB).a
303 endif
304 ifeq ($(PLATFORM),wii)
305 LIBRARIES += $(BTELIB).a $(WIIUSELIB).a $(DILIB).a $(WIIKEYBLIB).a
306 endif
308 #---------------------------------------------------------------------------------
309 libs: $(LIBRARIES)
310 #---------------------------------------------------------------------------------
312 #---------------------------------------------------------------------------------
313 clean:
314 #---------------------------------------------------------------------------------
315 rm -fr wii cube
316 rm -fr $(DEPS)
317 rm -fr $(LIBS)
318 rm -fr $(INCDIR)
319 rm -f *.map
321 #---------------------------------------------------------------------------------
322 docs: install-headers
323 #---------------------------------------------------------------------------------
324 doxygen libogc.dox
326 -include $(DEPSDIR)/*.d