aboutsummaryrefslogtreecommitdiffstats
path: root/cfe/build/broadcom/bcm947xx/compressed/Makefile
blob: 1c4ecd99e10259b4f7d28d9ed8e7397ce7723573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
# Makefile for compressed self-booting CFE on Broadcom BCM947XX boards
#
# Copyright 2006, Broadcom Corporation
# All Rights Reserved.                
#                                     
# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;   
# the contents of this file may not be disclosed to third parties, copied
# or duplicated in any form, in whole or in part, without the prior      
# written permission of Broadcom Corporation.                            
#
# $Id: Makefile,v 1.1.1.1 2008/07/21 09:14:10 james26_jang Exp $
#

CROSS_COMPILE	:= $(TOOLPREFIX)
CC		:= $(GCC)
LD		:= $(GLD)
LOADADDR	:= $(CFG_TEXT_START)

# The self-decompresor uses the minimal OSL, get rid of _CFE_ and vxworks
CFLAGS		:= $(subst -D_CFE_,,$(CFLAGS)) -fdata-sections
CFLAGS		+= -D_MINOSL_ -Uvxworks -U__vxworks

# Link at 3 MB offset in RAM
TEXT_START	:= 0x80001000

OBJCOPY		:= $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
OBJCOPYSREC	:= $(CROSS_COMPILE)objcopy -O srec -R .reginfo -R .note -R .comment -R .mdebug -S

SYSTEM		:= ../cfe

vpath %.c $(SRCBASE)/shared
vpath %.S $(SRCBASE)/shared
vpath %.lds.in $(SRCBASE)/shared

CFLAGS		+= -DLOADADDR=$(LOADADDR)
CFLAGS		+= -ffunction-sections $(call check_gcc, -fvtable-gc, )

OBJECTS		:= boot.o sbsdram.o load.o sflash.o hndmips.o hndchipc.o sbutils.o \
		   min_osl.o bcmutils.o bcmstdlib.o sromstubs.o nvramstubs.o hndpmu.o

# Default to gzip, bzip2 not worth it for small binaries
COMPRESS	:= gzip -c9

ifneq ($(findstring gzip,$(COMPRESS)),)
CFLAGS		+= -DUSE_GZIP
else
ifneq ($(findstring bzip2,$(COMPRESS)),)
CFLAGS		+= -DUSE_BZIP2
else
COMPRESS	:= cat
endif
endif

all: cfez.bin

# Don't build dependencies, this may die if $(CC) isn't gcc
dep:

cfez.bin: cfez
	$(OBJCOPY) $< $@
	$(OBJCOPYSREC) $< cfez.srec

	@if [ "$(CFEZ_MAXSIZE)" != "" ]; then \
		if [ "`wc -c < cfez.bin`" -gt "$(CFEZ_MAXSIZE)" ]; then \
			echo "*** ERROR *** : cfez.bin bootrom image size: `wc -c < cfez.bin` exceeds limit: $(CFEZ_MAXSIZE)"; \
			exit 127; \
		fi; \
	fi; \

# Link the loader and the kernel binary together
cfez: cfez.lds $(OBJECTS) piggy.o
	$(LD) -static -Map cfez.map --gc-sections -no-warn-mismatch -T cfez.lds -o $@ $(OBJECTS) piggy.o

cfez.lds: hndrte.lds.in Makefile
	sed -e s/TEXT_START/$(TEXT_START)/ \
	    -e s/TARGET_ARCH/mips/ < $< > $@

# Create a linkable version of the (possibly compressed) kernel binary
piggy.o: piggz piggy.lds

ifeq ($(CFG_LITTLE), 1)
	$(LD) -no-warn-mismatch -T piggy.lds -r -o $@ -b binary piggz -b elf32-tradlittlemips 
else
	$(LD) -no-warn-mismatch -T piggy.lds -r -o $@ -b binary piggz -b elf32-bigmips
endif

piggy.lds:
	@echo "SECTIONS { .data : { input_len = .; LONG(input_data_end - input_data) input_data = .; *(.data) input_data_end = .; }}" > $@

piggz: piggy
	$(COMPRESS) $< > $@

piggy: $(SYSTEM)
	$(OBJCOPY) $< $@

mrproper: clean

clean:
	rm -f cfez cfez.bin cfez.srec piggz piggy *.lds *.o *.map

%.o : %.S
	$(GCC) $(CFLAGS) -o $@ $<
bues.ch cgit interface