fixity fix
[libogc.git] / Makefile
blobba0d43f3e72dee161174e9151f675bbf35f0a689
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 := 6
17 export LIBOGC_PATCH := 0
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)$(shell date +%m)$(shell date +%d)
35 #---------------------------------------------------------------------------------
36 ifeq ($(strip $(PLATFORM)),)
37 #---------------------------------------------------------------------------------
38 export BASEDIR := $(CURDIR)
39 export LWIPDIR := $(BASEDIR)/lwip
40 export OGCDIR := $(BASEDIR)/libogc
41 export MODDIR := $(BASEDIR)/libmodplay
42 export MADDIR := $(BASEDIR)/libmad
43 export SAMPLEDIR := $(BASEDIR)/libsamplerate
44 export DBDIR := $(BASEDIR)/libdb
45 export BTEDIR := $(BASEDIR)/lwbt
46 export WIIUSEDIR := $(BASEDIR)/wiiuse
47 export TINYSMBDIR := $(BASEDIR)/libtinysmb
48 export LIBZDIR := $(BASEDIR)/libz
49 export STUBSDIR := $(BASEDIR)/lockstubs
50 export DEPS := $(BASEDIR)/deps
51 export LIBS := $(BASEDIR)/lib
53 export INCDIR := $(BASEDIR)/include
55 #---------------------------------------------------------------------------------
56 else
57 #---------------------------------------------------------------------------------
59 export LIBDIR := $(LIBS)/$(PLATFORM)
60 export DEPSDIR := $(DEPS)/$(PLATFORM)
62 #---------------------------------------------------------------------------------
63 endif
64 #---------------------------------------------------------------------------------
67 #---------------------------------------------------------------------------------
68 BBALIB := $(LIBDIR)/libbba
69 OGCLIB := $(LIBDIR)/libogc
70 MODLIB := $(LIBDIR)/libmodplay
71 MADLIB := $(LIBDIR)/libmad
72 DBLIB := $(LIBDIR)/libdb
73 BTELIB := $(LIBDIR)/libbte
74 WIIUSELIB := $(LIBDIR)/libwiiuse
75 TINYSMBLIB := $(LIBDIR)/libtinysmb
76 ZLIB := $(LIBDIR)/libz
77 STUBSLIB := $(LIBDIR)/libgclibstubs
79 #---------------------------------------------------------------------------------
80 DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
81 INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
82 -I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine -I$(BASEDIR)/gc/tinysmb \
83 -I$(BASEDIR)/gc/modplay -I$(BASEDIR)/gc/mad \
84 -I$(BASEDIR)/gc/z -I$(BASEDIR)/gc/lwbt \
85 -I$(BASEDIR)/gc/sdcard
87 MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
89 ifeq ($(PLATFORM),wii)
90 MACHDEP += -DHW_RVL
91 endif
93 ifeq ($(PLATFORM),cube)
94 MACHDEP += -DHW_DOL
95 endif
97 CFLAGS := -DLIBOGC_INTERNAL -DGAMECUBE -O2 -Wall $(MACHDEP) -fno-strict-aliasing $(INCLUDES)
100 #---------------------------------------------------------------------------------
101 VPATH := $(LWIPDIR) \
102 $(LWIPDIR)/arch/gc \
103 $(LWIPDIR)/arch/gc/netif \
104 $(LWIPDIR)/core \
105 $(LWIPDIR)/core/ipv4 \
106 $(LWIPDIR)/netif \
107 $(OGCDIR) \
108 $(MODDIR) \
109 $(MADDIR) \
110 $(SAMPLEDIR) \
111 $(DBDIR) \
112 $(DBDIR)/uIP \
113 $(BTEDIR) \
114 $(WIIUSEDIR) \
115 $(SDCARDDIR) \
116 $(TINYSMBDIR) \
117 $(LIBZDIR) \
118 $(STUBSDIR)
121 #---------------------------------------------------------------------------------
122 LWIPOBJ := network.o netio.o gcif.o \
123 inet.o mem.o dhcp.o raw.o \
124 memp.o netif.o pbuf.o stats.o \
125 sys.o tcp.o tcp_in.o tcp_out.o \
126 udp.o icmp.o ip.o ip_frag.o \
127 ip_addr.o etharp.o loopif.o
129 #---------------------------------------------------------------------------------
130 OGCOBJ := \
131 console.o lwp_priority.o lwp_queue.o lwp_threadq.o lwp_threads.o lwp_sema.o \
132 lwp_messages.o lwp.o lwp_handler.o lwp_stack.o lwp_mutex.o \
133 lwp_watchdog.o lwp_wkspace.o lwp_objmgr.o lwp_heap.o sys_state.o \
134 exception_handler.o exception.o irq.o irq_handler.o semaphore.o \
135 video_asm.o video.o pad.o dvd.o exi.o mutex.o arqueue.o arqmgr.o \
136 cache_asm.o system.o system_asm.o cond.o \
137 gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
138 message.o card.o aram.o depackrnc.o decrementer_handler.o \
139 depackrnc1.o dsp.o si.o tdf.o ipc.o ogc_crt0.o \
140 console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o \
141 sbrk.o malloc_lock.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
142 sdgecko_io.o sdgecko_buf.o argv.o network_wii.o wiisd.o conf.o
144 #---------------------------------------------------------------------------------
145 MODOBJ := freqtab.o mixer.o modplay.o semitonetab.o gcmodplay.o
147 #---------------------------------------------------------------------------------
148 MADOBJ := mp3player.o bit.o decoder.o fixed.o frame.o huffman.o \
149 layer12.o layer3.o stream.o synth.o timer.o \
150 version.o
152 #---------------------------------------------------------------------------------
153 DBOBJ := uip_ip.o uip_tcp.o uip_pbuf.o uip_netif.o uip_arp.o uip_arch.o \
154 uip_icmp.o memb.o memr.o bba.o tcpip.o debug.o debug_handler.o \
155 debug_supp.o geckousb.o
157 #---------------------------------------------------------------------------------
158 BTEOBJ := bte.o hci.o l2cap.o btmemb.o btmemr.o btpbuf.o physbusif.o
160 #---------------------------------------------------------------------------------
161 WIIUSEOBJ := classic.o dynamics.o events.o guitar_hero_3.o io.o io_wii.o ir.o \
162 nunchuk.o wiiuse.o wpad.o
164 #---------------------------------------------------------------------------------
165 TINYSMBOBJ := des.o lmhash.o smb.o
167 #---------------------------------------------------------------------------------
168 ZLIBOBJ := adler32.o compress.o crc32.o gzio.o uncompr.o \
169 deflate.o trees.o zutil.o inflate.o infback.o \
170 inftrees.o inffast.o
172 #---------------------------------------------------------------------------------
173 # Build rules:
174 #---------------------------------------------------------------------------------
175 %.o : %.c
176 #---------------------------------------------------------------------------------
177 @echo $(notdir $<)
178 @$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
180 #---------------------------------------------------------------------------------
181 %.o : %.cpp
182 #---------------------------------------------------------------------------------
183 @echo $(notdir $<)
184 @$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
186 #---------------------------------------------------------------------------------
187 %.o : %.S
188 #---------------------------------------------------------------------------------
189 @echo $(notdir $<)
190 @$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -D_LANGUAGE_ASSEMBLY -Wa,-mgekko -c $< -o $@
192 #---------------------------------------------------------------------------------
193 %.o : %.s
194 #---------------------------------------------------------------------------------
195 @echo $(notdir $<)
196 @$(AS) -mgekko -Qy $< -o $@
198 #---------------------------------------------------------------------------------
199 %.a:
200 #---------------------------------------------------------------------------------
201 $(AR) -rc $@ $^
203 #---------------------------------------------------------------------------------
204 all: gc/ogc/libversion.h
205 #---------------------------------------------------------------------------------
206 @[ -d $(LIBS)/wii ] || mkdir -p $(LIBS)/wii
207 @[ -d $(LIBS)/cube ] || mkdir -p $(LIBS)/cube
208 @[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
209 @[ -d $(DEPS)/wii ] || mkdir -p $(DEPS)/wii
210 @[ -d $(DEPS)/cube ] || mkdir -p $(DEPS)/cube
211 @[ -d wii ] || mkdir -p wii
212 @[ -d cube ] || mkdir -p cube
213 @$(MAKE) PLATFORM=cube libs -C cube -f $(CURDIR)/Makefile
214 @$(MAKE) PLATFORM=wii libs -C wii -f $(CURDIR)/Makefile
216 #---------------------------------------------------------------------------------
217 gc/ogc/libversion.h : Makefile
218 #---------------------------------------------------------------------------------
219 @echo "#ifndef __LIBVERSION_H__" > $@
220 @echo "#define __LIBVERSION_H__" >> $@
221 @echo >> $@
222 @echo "#define _V_MAJOR_ $(LIBOGC_MAJOR)" >> $@
223 @echo "#define _V_MINOR_ $(LIBOGC_MINOR)" >> $@
224 @echo "#define _V_PATCH_ $(LIBOGC_PATCH)" >> $@
225 @echo >> $@
226 @echo "#define _V_DATE_ __DATE__" >> $@
227 @echo "#define _V_TIME_ __TIME__" >> $@
228 @echo >> $@
229 @echo '#define _V_STRING "libOGC Release '$(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)'"' >> $@
230 @echo >> $@
231 @echo "#endif // __LIBVERSION_H__" >> $@
233 #---------------------------------------------------------------------------------
234 $(BBALIB).a: $(LWIPOBJ)
235 #---------------------------------------------------------------------------------
236 $(OGCLIB).a: $(OGCOBJ)
237 #---------------------------------------------------------------------------------
238 $(MP3LIB).a: $(MP3OBJ)
239 #---------------------------------------------------------------------------------
240 $(MODLIB).a: $(MODOBJ)
241 #---------------------------------------------------------------------------------
242 $(MADLIB).a: $(MADOBJ)
243 #---------------------------------------------------------------------------------
244 $(DBLIB).a: $(DBOBJ)
245 #---------------------------------------------------------------------------------
246 $(TINYSMBLIB).a: $(TINYSMBOBJ)
247 #---------------------------------------------------------------------------------
248 $(ZLIB).a: $(ZLIBOBJ)
249 #---------------------------------------------------------------------------------
250 $(BTELIB).a: $(BTEOBJ)
251 #---------------------------------------------------------------------------------
252 $(WIIUSELIB).a: $(WIIUSEOBJ)
253 #---------------------------------------------------------------------------------
255 .PHONY: libs install-headers install dist docs
257 #---------------------------------------------------------------------------------
258 install-headers:
259 #---------------------------------------------------------------------------------
260 @mkdir -p $(INCDIR)
261 @mkdir -p $(INCDIR)/ogc/machine
262 @mkdir -p $(INCDIR)/bte
263 @mkdir -p $(INCDIR)/wiiuse
264 @mkdir -p $(INCDIR)/modplay
265 @mkdir -p $(INCDIR)/mad
266 @mkdir -p $(INCDIR)/sdcard
267 @cp ./gc/*.h $(INCDIR)
268 @cp ./gc/ogc/*.h $(INCDIR)/ogc
269 @cp ./gc/ogc/machine/*.h $(INCDIR)/ogc/machine
270 @cp ./gc/lwbt/*.h $(INCDIR)/bte
271 @cp ./gc/wiiuse/*.h $(INCDIR)/wiiuse
272 @cp ./gc/modplay/*.h $(INCDIR)/modplay
273 @cp ./gc/mad/*.h $(INCDIR)/mad
274 @cp ./gc/sdcard/*.h $(INCDIR)/sdcard
276 #---------------------------------------------------------------------------------
277 install: install-headers
278 #---------------------------------------------------------------------------------
279 @mkdir -p $(DEVKITPRO)/libogc
280 @cp -frv include $(DEVKITPRO)/libogc
281 @cp -frv lib $(DEVKITPRO)/libogc
282 @cp -frv libogc_license.txt $(DEVKITPRO)/libogc
285 #---------------------------------------------------------------------------------
286 dist: install-headers
287 #---------------------------------------------------------------------------------
288 @tar --exclude=*CVS* --exclude=wii --exclude=cube --exclude=*deps* \
289 --exclude=*.bz2 --exclude=*include* --exclude=*lib/* --exclude=*docs/*\
290 -cvjf libogc-src-$(DATESTRING).tar.bz2 *
291 @tar -cvjf libogc-$(DATESTRING).tar.bz2 include lib libogc_license.txt
294 LIBRARIES := $(OGCLIB).a $(MODLIB).a $(MADLIB).a $(DBLIB).a $(ZLIB).a $(TINYSMBLIB).a
296 ifeq ($(PLATFORM),cube)
297 LIBRARIES += $(BBALIB).a
298 endif
299 ifeq ($(PLATFORM),wii)
300 LIBRARIES += $(BTELIB).a $(WIIUSELIB).a
301 endif
303 #---------------------------------------------------------------------------------
304 libs: $(LIBRARIES)
305 #---------------------------------------------------------------------------------
307 #---------------------------------------------------------------------------------
308 clean:
309 #---------------------------------------------------------------------------------
310 rm -fr wii cube
311 rm -fr $(DEPS)
312 rm -fr $(LIBS)
313 rm -fr $(INCDIR)
314 rm -f *.map
316 #---------------------------------------------------------------------------------
317 docs: install-headers
318 #---------------------------------------------------------------------------------
319 doxygen libogc.dox
321 -include $(DEPSDIR)/*.d