1# 2# Makefile for Broadcom BCM947XX boards 3# 4# Copyright (C) 2011, Broadcom Corporation. All Rights Reserved. 5# 6# Permission to use, copy, modify, and/or distribute this software for any 7# purpose with or without fee is hereby granted, provided that the above 8# copyright notice and this permission notice appear in all copies. 9# 10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 15# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17# 18# $Id: Makefile 341899 2012-06-29 04:06:38Z $ 19# 20 21include ../common.mak 22 23# Default mips 24ifeq ($(ARCH),) 25ARCH := mips 26endif 27 28ifeq ($(ARCH), arm) 29 TEXT_START ?= 0x00700000 30 LOADADDR := 0x00001000 31 CROSS_COMPILE ?= arm-uclibc-linux-2.6.36- 32 VMLINUZ_LDS_IN := cfez_arm.lds.in 33 ELF32_LITTLE := elf32-littlearm 34 ELF32_BIG := elf32-bigarm 35 LDLIBS := -L $(shell dirname `$(CROSS_COMPILE)gcc $(CFLAGS) -print-libgcc-file-name`) -lgcc 36else 37 # Link at 3 MB offset in RAM 38 TEXT_START ?= 0x80300000 39 LOADADDR := 0x80001000 40 CROSS_COMPILE ?= mipsel-linux- 41 VMLINUZ_LDS_IN := hndrte.lds.in 42 ELF32_LITTLE := elf32-tradlittlemips 43 ELF32_BIG ?= elf32-bigmips 44 LDLIBS := 45endif 46 47OBJCOPY-arm := $(CROSS_COMPILE)objcopy -O binary -R .note -R .note.gnu.build-id -R .comment -S 48OBJCOPY-mips := $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S 49OBJCOPY := $(OBJCOPY-$(ARCH)) 50 51OBJCOPYSREC := $(CROSS_COMPILE)objcopy -O srec -R .reginfo -R .note -R .comment -R .mdebug -S 52 53vpath %.c $(SRCBASE)/shared 54vpath %.S $(SRCBASE)/shared 55vpath %.lds.in $(SRCBASE)/shared 56 57# The self-decompresor is standalone, get rid of the linux flags 58CFLAGS := $(subst -Dlinux,,$(CFLAGS)) 59CFLAGS += -Ulinux -D_MINOSL_ -ffreestanding 60ifdef CONFIG_MCOUNT 61CFLAGS := $(subst -pg,,$(CFLAGS)) 62endif 63CFLAGS += -ffunction-sections $(call check_gcc, -fvtable-gc, ) 64 65SYSTEM ?= $(LINUXDIR)/vmlinux 66 67# Note: siutils.o appeared seperately on purpose to solve post reference problem of GCC 68OBJS-mips = boot.o sisdram.o sbsdram.o aisdram.o sflash.o hndmips.o sbutils.o aiutils.o siutils.o nicpci.o 69# We should not compile sbutils.o but need add more compile directive in siutils.c 70OBJS-arm = bootarm.o aisdram_ca9.o siutils.o hndarm_ca9.o pcieinit_ca9.o sbutils.o aiutils.o nicpci.o 71ifeq ($(or $(RTCONFIG_BUILDBCM7),$(RTCONFIG_BCM7),$(RTCONFIG_BCM_794),$(RTCONFIG_BCM_7114),$(RTCONFIG_BCM9),$(RTCONFIG_BCM10)),y) 72OBJS-arm += pcie_core.o 73endif 74OBJECTS := $(OBJS-$(ARCH)) 75OBJECTS += load.o hndchipc.o hndpmu.o min_osl.o bcmutils.o \ 76 bcmstdlib.o sromstubs.o nvramstubs.o 77 78CFLAGS-mips = -DLOADADDR=$(LOADADDR) -march=mips32 -Wa,-mips32 -Wa,--trap -G 0 -mno-abicalls -fno-pic -pipe -msoft-float 79ASFLAGS-mips = -D__ASSEMBLY__ -DLOADADDR=$(LOADADDR) -march=mips32 -Wa,-mips32 -Wa,--trap -G 0 -mno-abicalls -fno-pic -pipe 80CFLAGS-arm = -DLOADADDR=$(LOADADDR) -Ulinux -pipe -g -DSTANDALONE -O0 -D__KERNEL__ -msoft-float -marm -mabi=aapcs-linux \ 81 -mno-thumb-interwork -fno-common -ffixed-r8 -msoft-float -march=armv6k -D__ARM_ARCH_7A__ -DBCMCHIPTYPE=3 \ 82 -DBCMPMUCTL=0 -DCFG_CRU=1 83ASFLAGS-arm = -D_LANGUAGE_ASSEMBLY -DLOADADDR=$(LOADADDR) -Ulinux -pipe -g -DSTANDALONE -O0 -D__KERNEL__ -msoft-float \ 84 -marm -mabi=aapcs-linux -mno-thumb-interwork -fno-common -ffixed-r8 -msoft-float -march=armv6k -D__ARM_ARCH_7A__ \ 85 -DBCMCHIPTYPE=3 -DBCMPMUCTL=0 -DCFG_CRU=1 86CFLAGS += $(CFLAGS-$(ARCH)) 87ASFLAGS += $(ASFLAGS-$(ARCH)) 88 89# Default to lzma_4k 90COMPRESS ?= $(SRCBASE)/ctools/lzma_4k e 91CFLAGS += -DUSE_LZMA -D_LZMA_NO_SYSTEM_SIZE_T -DBCMLZMA -I$(SRCBASE)/tools/misc/lzma_src/C 92 93CFLAGS += -I$(SRCBASE)/include -DBCMDRIVER 94ifeq ($(RTCONFIG_BCMARM),y) 95ifeq ($(RTCONFIG_BCM7),y) 96CFLAGS += ${WLAN_StdIncPathA} 97endif 98CFLAGS += -I$(SRCBASE)/common/include 99endif 100ASFLAGS += -I$(SRCBASE)/include 101 102all: zImage vmlinuz vmlinuz-gzip 103 104# Don't build dependencies, this may die if $(CC) isn't gcc 105dep: 106 107zImage: vmlinux 108 $(OBJCOPY) $< $@ 109 110# Link the loader and the kernel binary together 111vmlinux: vmlinux.lds $(OBJECTS) piggy.o 112 $(LD) -static --gc-sections -no-warn-mismatch -T vmlinux.lds -o $@ $(OBJECTS) $(LDLIBS) piggy.o 113 114vmlinux.lds: $(VMLINUZ_LDS_IN) Makefile 115 sed -e s/TEXT_START/$(TEXT_START)/ \ 116 -e s/TARGET_ARCH/mips/ < $< > $@ 117 118# Create a linkable version of the (possibly compressed) kernel binary 119piggy.o: piggz piggy.lds 120 $(LD) -no-warn-mismatch -T piggy.lds -r -o $@ -b binary piggz -b $(ELF32_LITTLE) 121 122piggy.lds: 123 @echo "SECTIONS { .data : { input_len = .; LONG(input_data_end - input_data) input_data = .; *(.data) input_data_end = .; }}" > $@ 124 125# Create an lzma version named vmlinuz 126vmlinuz: piggy 127 $(COMPRESS) $< $@ 128 129# Create a gzip version named vmlinuz-gzip 130vmlinuz-gzip: piggy 131 gzip -c9 $< > $@ 132 133piggz: piggy 134 $(COMPRESS) $< $@ 135 136piggy: $(SYSTEM) 137 $(OBJCOPY) $< $@ 138 139mrproper: clean 140 141clean: 142 rm -f vmlinux vmlinuz vmlinuz-gzip zImage piggz piggy *.lds *.o 143