1 # Copyright 2008-2009 Segher Boessenkool <segher@kernel.crashing.org>
2 # Copyright 2011 roto <roto@mozy.org>
3 # Copyright 2011 Bernhard Urban <lewurm@gmail.com>
4 # This code is licensed to you under the terms of the GNU GPL, version 2;
5 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
10 # What toolchain prefix should we use
13 # Where are the tools (http://git.infradead.org/users/segher/wii.git)
14 TOOLS ?= $(HOME)/wii/segher
16 # End of configuration.
20 # Set CC, LD, OBJCOPY based on CROSS, unless they are set already
22 ifeq ($(origin CC), default)
23 CC := $(CROSS)gcc -m32
25 ifeq ($(origin LD), default)
28 OBJCOPY ?= $(CROSS)objcopy
31 # The compiler flags we need.
33 CFLAGS := -Wall -W -Os -ffreestanding -mno-eabi -mno-sdata -mcpu=750
36 # Build with "V=1" to see the commands executed; be quiet otherwise.
42 MAKEFLAGS += --no-print-directory
46 targets := rlge.bin rlgp.bin rlgj.bin
48 ppms := $(targets:%.bin=%-icon.ppm) generic-banner.ppm
49 assets := title.bin $(ppms)
51 loader := ../loader/loader.bin
54 titleid = $(shell perl titleid.pl $(1))
58 D=$(call titleid,$(1)); \
59 $(TOOLS)/twintig $$D $@ toc-$1
65 $(targets): %.bin: toc-% FILE_V28 $(assets)
67 $(Q)$(call twintig,$*)
69 FILE_V28: head.bin exploit.bin $(loader)
72 $(Q)$(TOOLS)/lego-cksum $@ 32380 #32328 #32688
76 $(Q)$(OBJCOPY) -Obinary $< $@
78 exploit.bin: exploit.elf
80 $(Q)$(OBJCOPY) -Obinary $< $@
82 exploit.elf: lego.lds exploit.o
88 $(Q)$(LD) -e 0 $< -o $@
92 $(Q)$(CC) $(CFLAGS) -c $< -o $@
94 head.o: head.s head.b exploit2.s exploit.bin
97 -Wa,--defsym,exploitlen=$(shell wc -c exploit.bin | awk '{ print $$1 }') \
100 title.bin: ../.version
102 $(Q)perl make-title-bin.pl > $@
105 $(Q)$(MAKE) -C .. .version
107 $(ppms): %.ppm: %.png
112 $(Q)dd if=/dev/zero bs=18256 count=1 2>/dev/null > $@
116 $(Q)echo FAILURE > $@
119 $(Q)$(MAKE) -C ../loader
124 -rm -f $(targets) FILE_V28
125 -rm -f exploit.bin exploit.elf exploit.o
126 -rm -f head.bin head.elf head.o