prevent c++ name mangling
[libogc.git] / Makefile
blobfc3e37eb7925e74e165a919b4c4fd400f0b5a2e7
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 STUBSDIR := $(BASEDIR)/lockstubs
53 export DEPS := $(BASEDIR)/deps
54 export LIBS := $(BASEDIR)/lib
56 export INCDIR := $(BASEDIR)/include
58 #---------------------------------------------------------------------------------
59 else
60 #---------------------------------------------------------------------------------
62 export LIBDIR := $(LIBS)/$(PLATFORM)
63 export DEPSDIR := $(DEPS)/$(PLATFORM)
65 #---------------------------------------------------------------------------------
66 endif
67 #---------------------------------------------------------------------------------
70 #---------------------------------------------------------------------------------
71 BBALIB := $(LIBDIR)/libbba
72 OGCLIB := $(LIBDIR)/libogc
73 MODLIB := $(LIBDIR)/libmodplay
74 MADLIB := $(LIBDIR)/libmad
75 DBLIB := $(LIBDIR)/libdb
76 DILIB := $(LIBDIR)/libdi
77 BTELIB := $(LIBDIR)/libbte
78 WIIUSELIB := $(LIBDIR)/libwiiuse
79 TINYSMBLIB := $(LIBDIR)/libtinysmb
80 ZLIB := $(LIBDIR)/libz
81 ASNDLIB := $(LIBDIR)/libasnd
82 STUBSLIB := $(LIBDIR)/libgclibstubs
84 #---------------------------------------------------------------------------------
85 DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
86 INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
87 -I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine \
88 -I$(BASEDIR)/gc/modplay -I$(BASEDIR)/gc/mad \
89 -I$(BASEDIR)/gc/z -I$(BASEDIR)/gc/bte \
90 -I$(BASEDIR)/gc/sdcard -I$(BASEDIR)/gc/wiiuse \
91 -I$(BASEDIR)/gc/di
93 MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
95 ifeq ($(PLATFORM),wii)
96 MACHDEP += -DHW_RVL
97 endif
99 ifeq ($(PLATFORM),cube)
100 MACHDEP += -DHW_DOL
101 endif
103 CFLAGS := -DLIBOGC_INTERNAL -DGAMECUBE -O2 -Wall $(MACHDEP) -fno-strict-aliasing $(INCLUDES)
106 #---------------------------------------------------------------------------------
107 VPATH := $(LWIPDIR) \
108 $(LWIPDIR)/arch/gc \
109 $(LWIPDIR)/arch/gc/netif \
110 $(LWIPDIR)/core \
111 $(LWIPDIR)/core/ipv4 \
112 $(LWIPDIR)/netif \
113 $(OGCDIR) \
114 $(MODDIR) \
115 $(MADDIR) \
116 $(SAMPLEDIR) \
117 $(DBDIR) \
118 $(DBDIR)/uIP \
119 $(DIDIR) \
120 $(BTEDIR) \
121 $(WIIUSEDIR) \
122 $(SDCARDDIR) \
123 $(TINYSMBDIR) \
124 $(LIBZDIR) \
125 $(LIBASNDDIR) \
126 $(STUBSDIR)
129 #---------------------------------------------------------------------------------
130 LWIPOBJ := network.o netio.o gcif.o \
131 inet.o mem.o dhcp.o raw.o \
132 memp.o netif.o pbuf.o stats.o \
133 sys.o tcp.o tcp_in.o tcp_out.o \
134 udp.o icmp.o ip.o ip_frag.o \
135 ip_addr.o etharp.o loopif.o
137 #---------------------------------------------------------------------------------
138 OGCOBJ := \
139 console.o lwp_priority.o lwp_queue.o lwp_threadq.o lwp_threads.o lwp_sema.o \
140 lwp_messages.o lwp.o lwp_handler.o lwp_stack.o lwp_mutex.o \
141 lwp_watchdog.o lwp_wkspace.o lwp_objmgr.o lwp_heap.o sys_state.o \
142 exception_handler.o exception.o irq.o irq_handler.o semaphore.o \
143 video_asm.o video.o pad.o dvd.o exi.o mutex.o arqueue.o arqmgr.o \
144 cache_asm.o system.o system_asm.o cond.o \
145 gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
146 message.o card.o aram.o depackrnc.o decrementer_handler.o \
147 depackrnc1.o dsp.o si.o tpl.o ipc.o ogc_crt0.o \
148 console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o \
149 sbrk.o malloc_lock.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
150 sdgecko_io.o sdgecko_buf.o gcsd.o argv.o network_wii.o wiisd.o conf.o usbstorage.o \
151 texconv.o wiilaunch.o
153 #---------------------------------------------------------------------------------
154 MODOBJ := freqtab.o mixer.o modplay.o semitonetab.o gcmodplay.o
156 #---------------------------------------------------------------------------------
157 MADOBJ := mp3player.o bit.o decoder.o fixed.o frame.o huffman.o \
158 layer12.o layer3.o stream.o synth.o timer.o \
159 version.o
161 #---------------------------------------------------------------------------------
162 DBOBJ := uip_ip.o uip_tcp.o uip_pbuf.o uip_netif.o uip_arp.o uip_arch.o \
163 uip_icmp.o memb.o memr.o bba.o tcpip.o debug.o debug_handler.o \
164 debug_supp.o geckousb.o
165 #---------------------------------------------------------------------------------
166 DIOBJ := di.o di_read.o stubasm.o stubload.o
168 #---------------------------------------------------------------------------------
169 BTEOBJ := bte.o hci.o l2cap.o btmemb.o btmemr.o btpbuf.o physbusif.o
171 #---------------------------------------------------------------------------------
172 WIIUSEOBJ := classic.o dynamics.o events.o guitar_hero_3.o io.o io_wii.o ir.o \
173 nunchuk.o wiiboard.o wiiuse.o wpad.o
175 #---------------------------------------------------------------------------------
176 TINYSMBOBJ := des.o md4.o ntlm.o smb.o smb_devoptab.o
178 #---------------------------------------------------------------------------------
179 ZLIBOBJ := adler32.o compress.o crc32.o gzio.o uncompr.o \
180 deflate.o trees.o zutil.o inflate.o infback.o \
181 inftrees.o inffast.o
183 #---------------------------------------------------------------------------------
184 ASNDLIBOBJ := asndlib.o
186 #---------------------------------------------------------------------------------
187 # Build rules:
188 #---------------------------------------------------------------------------------
189 %.o : %.c
190 #---------------------------------------------------------------------------------
191 @echo $(notdir $<)
192 @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
194 #---------------------------------------------------------------------------------
195 %.o : %.cpp
196 #---------------------------------------------------------------------------------
197 @echo $(notdir $<)
198 @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -Wa,-mgekko -c $< -o $@
200 #---------------------------------------------------------------------------------
201 %.o : %.S
202 #---------------------------------------------------------------------------------
203 @echo $(notdir $<)
204 @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -D_LANGUAGE_ASSEMBLY -Wa,-mgekko -c $< -o $@
206 #---------------------------------------------------------------------------------
207 %.o : %.s
208 #---------------------------------------------------------------------------------
209 @echo $(notdir $<)
210 @$(AS) -mgekko -Qy $< -o $@
212 #---------------------------------------------------------------------------------
213 %.a:
214 #---------------------------------------------------------------------------------
215 $(AR) -rc $@ $^
217 all: wii cube
219 #---------------------------------------------------------------------------------
220 wii: gc/ogc/libversion.h
221 #---------------------------------------------------------------------------------
222 @[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
223 @[ -d $(LIBS)/wii ] || mkdir -p $(LIBS)/wii
224 @[ -d $(DEPS)/wii ] || mkdir -p $(DEPS)/wii
225 @[ -d wii ] || mkdir -p wii
226 @$(MAKE) PLATFORM=wii libs -C wii -f $(CURDIR)/Makefile
228 #---------------------------------------------------------------------------------
229 cube: gc/ogc/libversion.h
230 #---------------------------------------------------------------------------------
231 @[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
232 @[ -d $(LIBS)/cube ] || mkdir -p $(LIBS)/cube
233 @[ -d $(DEPS)/cube ] || mkdir -p $(DEPS)/cube
234 @[ -d cube ] || mkdir -p cube
235 @$(MAKE) PLATFORM=cube libs -C cube -f $(CURDIR)/Makefile
238 #---------------------------------------------------------------------------------
239 gc/ogc/libversion.h : Makefile
240 #---------------------------------------------------------------------------------
241 @echo "#ifndef __LIBVERSION_H__" > $@
242 @echo "#define __LIBVERSION_H__" >> $@
243 @echo >> $@
244 @echo "#define _V_MAJOR_ $(LIBOGC_MAJOR)" >> $@
245 @echo "#define _V_MINOR_ $(LIBOGC_MINOR)" >> $@
246 @echo "#define _V_PATCH_ $(LIBOGC_PATCH)" >> $@
247 @echo >> $@
248 @echo "#define _V_DATE_ __DATE__" >> $@
249 @echo "#define _V_TIME_ __TIME__" >> $@
250 @echo >> $@
251 @echo '#define _V_STRING "libOGC Release '$(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)'"' >> $@
252 @echo >> $@
253 @echo "#endif // __LIBVERSION_H__" >> $@
255 #---------------------------------------------------------------------------------
256 $(BBALIB).a: $(LWIPOBJ)
257 #---------------------------------------------------------------------------------
258 $(OGCLIB).a: $(OGCOBJ)
259 #---------------------------------------------------------------------------------
260 $(MP3LIB).a: $(MP3OBJ)
261 #---------------------------------------------------------------------------------
262 $(MODLIB).a: $(MODOBJ)
263 #---------------------------------------------------------------------------------
264 $(MADLIB).a: $(MADOBJ)
265 #---------------------------------------------------------------------------------
266 $(DBLIB).a: $(DBOBJ)
267 #---------------------------------------------------------------------------------
268 $(DILIB).a: $(DIOBJ)
269 #---------------------------------------------------------------------------------
270 $(TINYSMBLIB).a: $(TINYSMBOBJ)
271 #---------------------------------------------------------------------------------
272 $(ZLIB).a: $(ZLIBOBJ)
273 #---------------------------------------------------------------------------------
274 $(ASNDLIB).a: $(ASNDLIBOBJ)
275 #---------------------------------------------------------------------------------
276 $(BTELIB).a: $(BTEOBJ)
277 #---------------------------------------------------------------------------------
278 $(WIIUSELIB).a: $(WIIUSEOBJ)
279 #---------------------------------------------------------------------------------
281 .PHONY: libs wii cube install-headers install dist docs
283 #---------------------------------------------------------------------------------
284 install-headers:
285 #---------------------------------------------------------------------------------
286 @mkdir -p $(INCDIR)
287 @mkdir -p $(INCDIR)/ogc/machine
288 @mkdir -p $(INCDIR)/bte
289 @mkdir -p $(INCDIR)/wiiuse
290 @mkdir -p $(INCDIR)/modplay
291 @mkdir -p $(INCDIR)/mad
292 @mkdir -p $(INCDIR)/sdcard
293 @mkdir -p $(INCDIR)/di
294 @cp ./gc/*.h $(INCDIR)
295 @cp ./gc/ogc/*.h $(INCDIR)/ogc
296 @cp ./gc/ogc/machine/*.h $(INCDIR)/ogc/machine
297 @cp ./gc/bte/*.h $(INCDIR)/bte
298 @cp ./gc/wiiuse/*.h $(INCDIR)/wiiuse
299 @cp ./gc/modplay/*.h $(INCDIR)/modplay
300 @cp ./gc/mad/*.h $(INCDIR)/mad
301 @cp ./gc/sdcard/*.h $(INCDIR)/sdcard
302 @cp ./gc/di/*.h $(INCDIR)/di
304 #---------------------------------------------------------------------------------
305 install: install-headers
306 #---------------------------------------------------------------------------------
307 @mkdir -p $(DEVKITPRO)/libogc
308 @cp -frv include $(DEVKITPRO)/libogc
309 @cp -frv lib $(DEVKITPRO)/libogc
310 @cp -frv libogc_license.txt $(DEVKITPRO)/libogc
313 #---------------------------------------------------------------------------------
314 dist: install-headers
315 #---------------------------------------------------------------------------------
316 @tar --exclude=*CVS* --exclude=wii --exclude=cube --exclude=*deps* \
317 --exclude=*.bz2 --exclude=*include* --exclude=*lib/* --exclude=*docs/*\
318 -cvjf libogc-src-$(VERSTRING).tar.bz2 *
319 @tar -cvjf libogc-$(VERSTRING).tar.bz2 include lib libogc_license.txt
322 LIBRARIES := $(OGCLIB).a $(MODLIB).a $(MADLIB).a $(DBLIB).a $(ZLIB).a $(TINYSMBLIB).a $(ASNDLIB).a
324 ifeq ($(PLATFORM),cube)
325 LIBRARIES += $(BBALIB).a
326 endif
327 ifeq ($(PLATFORM),wii)
328 LIBRARIES += $(BTELIB).a $(WIIUSELIB).a $(DILIB).a
329 endif
331 #---------------------------------------------------------------------------------
332 libs: $(LIBRARIES)
333 #---------------------------------------------------------------------------------
335 #---------------------------------------------------------------------------------
336 clean:
337 #---------------------------------------------------------------------------------
338 rm -fr wii cube
339 rm -fr $(DEPS)
340 rm -fr $(LIBS)
341 rm -fr $(INCDIR)
342 rm -f *.map
344 #---------------------------------------------------------------------------------
345 docs: install-headers
346 #---------------------------------------------------------------------------------
347 doxygen libogc.dox
349 -include $(DEPSDIR)/*.d