############################################################################## 
#
# Copyright (c) 2002 Xilinx, Inc.  All rights reserved.
#
# Xilinx, Inc.
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 
# COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
# ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 
# STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
# IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 
# FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.  
# XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 
# THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 
# ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 
# FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 
# AND FITNESS FOR A PARTICULAR PURPOSE.
# 
# File   : Makefile
# Company: Xilinx
#
# Top level Makefile
#
# $Id: Makefile_mb.sh,v 1.1.2.5 2003/04/01 00:38:11 mohan Exp $
#
##############################################################################

#
# Processor architecture
# microblaze
#
ARCH = microblaze

SYSTEMDIR = ../../..

TOPDIR = .



ARCH_PREFIX = mb
ARCH_DEFINE = MB_XILKERNEL
LFLAGS = -Wl,-defsym -Wl,_STACK_SIZE=0x600 -xl-mode-xmdstub 


#
# gnu tools for Makefile
#
CC = $(ARCH_PREFIX)-gcc 
AR = $(ARCH_PREFIX)-ar
CP = cp

# export ARCH ARCH_PREFIX ARCH_DEFINE CC AR CP

#
# Compiler, linker and other options.
#
CFLAGS = -D${ARCH_DEFINE} -O2 -g

MYCFLAGS = 

#
# System project directories.
#


LIBDIR = $(SYSTEMDIR)/lib
INCLUDEDIR = $(SYSTEMDIR)/include
CODEDIR = $(SYSTEMDIR)/code
KERNELEXEC = ${TOPDIR}/xilkernel.elf
LIBSYSCALL = ${TOPDIR}/libw.a

INCLUDES = -I${TOPDIR}/include -I$(INCLUDEDIR)
LIBS = -L${TOPDIR} -L$(LIBDIR)

KERNEL_OBJS = ${TOPDIR}/src/sys/*.o ${TOPDIR}/src/ipc/*.o ${TOPDIR}/src/arch/${ARCH}/*.o
INCLUDEFILES = ${TOPDIR}/include/*

SUBDIRS = dir_src 

libs: dir_syscall rellibs

kernel: execs release

execs: ${SUBDIRS} kernel_exec

kernel_exec: 
	$(CC) -o $(KERNELEXEC) $(KERNEL_OBJS) $(LFLAGS) $(LIBS) 

dir_src:
	(cd src; $(MAKE) CFLAGS="$(CFLAGS)" ARCH="$(ARCH)" CC="$(CC)" AR="$(AR)" all)

dir_syscall:
	(cd syscall; $(MAKE) CFLAGS="$(CFLAGS)" ARCH="$(ARCH)" CC="$(CC)" AR="$(AR)" all)

dir_test:
	(cd test/arch/$(ARCH); $(MAKE) CFLAGS="$(CFLAGS)" ARCH="$(ARCH)" CC="$(CC)" AR="$(AR)" all)

include: 
	$(CP) -rf $(INCLUDEFILES) $(INCLUDEDIR)

rellibs: 
	$(CP)  libw.a $(LIBDIR)

release: 
	$(CP)  xilkernel.elf $(CODEDIR)

clean:
	(cd src; $(MAKE) ARCH="$(ARCH)" clean)
	(cd syscall; $(MAKE) ARCH="$(ARCH)" clean)
	(cd test/arch/$(ARCH); $(MAKE) clean)
	rm -f ${KERNELEXEC} ${LIBSYSCALL}
