# $Id: Makefile,v 1.19 2003/06/27 17:12:48 kwalker Exp $

# Copyright 2001, 2003
# Broadcom Corporation. All rights reserved.
#
# This software is furnished under license and may be used and copied only
# in accordance with the following terms and conditions.  Subject to these
# conditions, you may download, copy, install, use, modify and distribute
# modified or unmodified copies of this software in source and/or binary
# form. No title or ownership is transferred hereby.
#
# 1) Any source code used, modified or distributed must reproduce and
#    retain this copyright notice and list of conditions as they appear in
#    the source file.
#
# 2) No right is granted to use any trade name, trademark, or logo of
#    Broadcom Corporation.  The "Broadcom Corporation" name may not be
#    used to endorse or promote products derived from this software
#    without the prior written permission of Broadcom Corporation.
#
# 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
#    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
#    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
#    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
#    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
#    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
#    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#    OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

VERSION_MAJOR = 2
VERSION_MINOR = 4
VERSION_MINUTE = 2

DISK_SUPPORT=0

all: sibyl sibyl.bin

include make.config

CPPFLAGS += -Ilib/c -Ilib/net -Ilib/cfe -I./include -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MINUTE=$(VERSION_MINUTE)
LDFLAGS  += -Llib/net -Llib/c -Llib/cfe




# all objects built in this directory 
ALL_OBJS =             \
	init.o         \
	main.o         \
	getfile.o      \
	parse_config.o \
	port.o         

ifeq ($(strip ${DISK_SUPPORT}),1)
ALL_OBJS += partition.o ext2_fileops.o
CPPFLAGS += -DCONFIG_BLOCKDEV -I../e2fsprogs/lib/ext2fs -I../e2fsprogs/lib -I../e2fsprogs/include/linux
DISKLIB = ../e2fsprogs/lib/libembext2fs.a
LDFLAGS += -L../e2fsprogs/lib -lembext2fs
else
ALL_OBJS += tftp_fileops.o
endif

disk: sibyl.bin
	mkbootimage -S 1 sibyl.bin disk.img

sibyl.dis: sibyl
	$(OBJDUMP) --disassemble-all sibyl > sibyl.dis


sibyl.bin: sibyl
	$(OBJCOPY) --remove-section=reginfo --output-target=binary $^ $@


sibyl: $(ALL_OBJS) libs 
	$(LD) -T ld.script -Map sibyl.map -static -o $@ $(ALL_OBJS) $(LDFLAGS) -lstandalone -lnet -lcfe ${DISKLIB}

instimage: instimage.c Makefile
	gcc -o instimage instimage.c

../e2fsprogs/lib/libembext2fs.a:
	(cd ../e2fsprogs && BUILD)

.PHONY: libs

libs:
	(cd lib && $(MAKE)) 


clean: common_clean
	rm -f sibyl sibyl.bin sibyl.dis sibyl.map instimage
	(cd lib && $(MAKE) clean)

ifneq ($(MAKECMDGOALS),clean)
sinclude $(ALL_OBJS:.o=.d)
endif

