#
# Toplevel Makefile for the BCM947xx Linux Router release
#
# Copyright 2005, Broadcom Corporation
# All Rights Reserved.
# 
# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
#
# $Id$
#

SRCBASE := $(shell pwd)
RELEASEDIR := $(shell (cd $(SRCBASE)/.. && pwd -P))
PATH := $(RELEASEDIR)/tools:/opt/brcm/hndtools-mipsel-linux-3.2.3/bin:/opt/brcm/hndtools-mipsel-uclibc-3.2.3/bin/:$(PATH)

install: all
	install -d $(RELEASEDIR)/image
	$(MAKE) -C router install
	-cp router/mipsel/linux.trx $(RELEASEDIR)/image/linux-glibc.trx
	-cp router/mipsel-uclibc/linux.trx $(RELEASEDIR)/image/linux.trx
	-cp router/mipsel-uclibc/linux.bin $(RELEASEDIR)/image/linux.bin
	echo -n -e '\001' >> $(RELEASEDIR)/image/linux.trx
ifneq ($(wildcard pmon),)
	cp pmon/pmon_lg.bin $(RELEASEDIR)/image/
endif
ifneq ($(wildcard cfe),)
	cp cfe/build/broadcom/bcm947xx/cfe.bin $(RELEASEDIR)/image/
        # Make CFE again for self-decompression support
	$(MAKE) -C cfe
	cp cfe/build/broadcom/bcm947xx/compressed/cfez.bin $(RELEASEDIR)/image/
endif
	rm -rf shared/nvram/*4320*.txt 
	cp shared/nvram/*.txt $(RELEASEDIR)/image/

all clean:
	##-cp router/None_GPL/kmemory/kmemory.o linux/linux/driver/char/kmemory/kmemory.o
	$(MAKE) -C router $@
ifneq ($(wildcard pmon),)
	$(MAKE) -C pmon $@
endif
ifneq ($(wildcard cfe),)
	$(MAKE) -C cfe $@
endif

.PHONY: all clean install
