s/PS3DEV/PS3LINUXDEV/g
[asbestos.git] / stage2 / Makefile
blob1cf0ac1cd15224013792176e4ef53376135a15e8
1 # Stage2 Makefile
3 # Copyright (C) 2010-2011 Hector Martin "marcan" <hector@marcansoft.com>
5 # This code is licensed to you under the terms of the GNU GPL, version 2;
6 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
8 include ../common/ppu.mak
10 DTC = $(PS3LINUXDEV)/bin/dtc
11 LZMA = lzma
13 STUB_LDFLAGS := $(LDFLAGS) -Wl,--gc-sections -Wl,-T,uncompress/stub.ld
14 LDFLAGS += -Wl,--gc-sections
15 STUB_CFLAGS := $(CFLAGS) -Os -Wall -ffunction-sections -I. -Iuncompress/
16 CFLAGS += -Os -Wall -I. -ffunction-sections -fdata-sections \
17 -Ilwip/src/include -Ilwip/src/include/ipv4 -Ilwip/arch/include -Ilibfdt
18 ASFLAGS = -D__ASSEMBLY__ -I.
20 DEPDIR = .deps
22 LWIP_OBJS = \
23 $(addprefix lwip/src/core/,\
24 dhcp.o init.o mem.o memp.o netif.o pbuf.o raw.o stats.o sys.o \
25 tcp.o tcp_in.o tcp_out.o udp.o) \
26 $(addprefix lwip/src/core/ipv4/,\
27 autoip.o icmp.o ip.o ip_addr.o ip_frag.o inet_chksum.o) \
28 $(addprefix lwip/src/api/,\
29 tcpip.o err.o netifapi.o api_lib.o api_msg.o sockets.o) \
30 lwip/src/netif/etharp.o
32 FDT_OBJS = $(addprefix libfdt/,\
33 fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_sw.o fdt_wip.o)
35 CORE_OBJS = main.o debug.o hvcall.o string.o printf.o device.o malloc.o \
36 time.o tftp.o gelic_netif.o exceptions.o exc_vector.o mm.o netrpc.o \
37 cleanup.o devtree.o kernel.o kbootconf.o network.o diskio.o ff.o \
38 $(LWIP_OBJS) $(FDT_OBJS)
40 OBJS = start.o $(CORE_OBJS)
41 OBJS_NATIVE = start_native.o $(CORE_OBJS)
43 STUB_OBJS = uncompress/stub_start.o uncompress/unlzma.o
45 all: stage2.bin stage2_native.bin
47 .PRECIOUS: stage2_raw.bin
49 stage2.bin : uncompress/stub.bin stage2_raw.lzma
50 cat uncompress/stub.bin stage2_raw.lzma > $@
52 %.lzma: %.bin
53 @echo " LZMA $@"
54 @$(LZMA) -c $< > $@.tmp
55 @dd if=$@.tmp bs=1 count=1 > $@ 2>/dev/null
56 @dd if=$@.tmp bs=13 skip=1 >> $@ 2>/dev/null
57 @rm $@.tmp
59 %.bin: %.elf
60 @echo " OBJCOPY $@"
61 @$(PREFIX)objcopy -O binary $< $@
63 uncompress/stub.elf: $(STUB_OBJS) uncompress/stub.ld
64 @echo " LINK $@"
65 @$(PREFIX)gcc $(STUB_LDFLAGS) -o $@ $(STUB_OBJS)
67 stage2_native.elf: $(OBJS_NATIVE) stage2_native.ld
68 @echo " LINK $@"
69 @$(PREFIX)gcc $(LDFLAGS) -Wl,-T,stage2_native.ld -o tmp_$@ $(OBJS_NATIVE)
70 @# move everything down to zero, it will relocate itself on startup
71 @# this could be done in the linker script for lma, but Sony fails and needs it for vma.
72 @$(PREFIX)objcopy --adjust-vma -0xc00000 tmp_$@ $@
73 @rm -f tmp_$@
75 stage2_raw.elf: $(OBJS) stage2.ld
76 @echo " LINK $@"
77 @$(PREFIX)gcc $(LDFLAGS) -Wl,-T,stage2.ld -o $@ $(OBJS)
79 %.S: %.dts
80 @echo " DTC $<"
81 @$(DTC) -o $@ -O asm $<
83 %.o: %.S
84 @echo " ASSEMBLE $<"
85 @mkdir -p $(DEPDIR)
86 @$(PREFIX)gcc $(ASFLAGS) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -c -o $@ $<
88 %.o: %.c
89 @echo " COMPILE $<"
90 @mkdir -p $(DEPDIR)
91 @$(PREFIX)gcc $(CFLAGS) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -c -o $@ $<
93 clean:
94 rm -rf $(DEPDIR)
95 rm -f $(OBJS) *.elf *.bin *.lzma
96 rm -f $(STUB_OBJS)
98 -include $(DEPDIR)/*
100 .PHONY: clean